Skip to content

fix(js): report organizeImports diagnostics on unsorted export chunks#9650

Closed
raashish1601 wants to merge 1 commit into
biomejs:mainfrom
raashish1601:contributor-10/issue-9530-organize-imports
Closed

fix(js): report organizeImports diagnostics on unsorted export chunks#9650
raashish1601 wants to merge 1 commit into
biomejs:mainfrom
raashish1601:contributor-10/issue-9530-organize-imports

Conversation

@raashish1601

Copy link
Copy Markdown
Contributor

Summary

  • report organizeImports diagnostics from the earliest recorded issue slot instead of the first import/export in the file
  • add a regression test that covers unsorted export specifiers after sorted bare imports

Closes #9530.

Testing

  • git diff --check
  • local cargo test -p biome_js_analyze --test quick_test organize_imports_reports_unsorted_exports_at_export_chunk -- --exact --nocapture is blocked in this environment by disk-space exhaustion during Rust compilation

@changeset-bot

changeset-bot Bot commented Mar 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ad57e8a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 29, 2026
@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d15160e9-fa10-41e3-a448-17d0a27cf8bf

📥 Commits

Reviewing files that changed from the base of the PR and between c17e08e and ad57e8a.

📒 Files selected for processing (2)
  • crates/biome_js_analyze/src/assist/source/organize_imports.rs
  • crates/biome_js_analyze/tests/quick_test.rs

Walkthrough

This PR fixes a diagnostic reporting location bug in the organiseImports rule. Previously, when exports were unsorted (e.g., export { b, a }), the rule reported the issue at the first import statement rather than at the problematic export. The fix updates OrganiseImports::text_range to compute the starting position from the earliest recorded issue (leading-newlines, unorganised items, or unsorted chunks) instead of always using the first import/export item's location. A test case validates the corrected behaviour.

Possibly related PRs

Suggested labels

A-Linter, L-JavaScript

Suggested reviewers

  • dyc3
  • ematipico
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the fix: reporting organizeImports diagnostics on unsorted export chunks rather than the first import.
Description check ✅ Passed The description clearly explains the change—using earliest recorded issue slot instead of first import/export—and mentions adding a regression test for unsorted exports.
Linked Issues check ✅ Passed The PR addresses issue #9530 by fixing diagnostic placement to report at the unsorted export chunk (line 8) instead of the first import (line 1), matching the expected behaviour outlined in the issue.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing organizeImports diagnostic reporting and adding a regression test; no extraneous modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq

codspeed-hq Bot commented Mar 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 168 skipped benchmarks1


Comparing raashish1601:contributor-10/issue-9530-organize-imports (ad57e8a) with main (5bfee36)

Open in CodSpeed

Footnotes

  1. 168 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Conaclos

Copy link
Copy Markdown
Member

Closing because the issue is already assigned and there is an ongoing fix: #9574

@Conaclos Conaclos closed this Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 organizeImports reported on first import for unsorted exports

2 participants