fix(organizeImports): merge bare exports#9373
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
| /// If no group contains `candidate`, then the returned value corresponds to the index of the implicit group. | ||
| /// The index of the implicit group correspond to the number of groups. | ||
| pub fn index(&self, candidate: &ImportCandidate<'_>) -> u16 { | ||
| candidate.source.as_str(); |
There was a problem hiding this comment.
This was a useless code. Strangely, this was not reported by Clippy.
WalkthroughThis change makes organizeImports sort and merge adjacent bare Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/neat-papers-think.md:
- Around line 5-7: Update the changeset opener to the required bug-fix format by
replacing the current first sentence "Fixed
[`#7583`](https://github.com/biomejs/biome/issues/7583)." with "Fixed
[`#7583`](https://github.com/biomejs/biome/issues/7583): sorts named specifiers
inside bare exports and merges bare exports" (or similar concise description),
so the issue link is followed by a colon and the description; ensure the rest of
the blurb mentioning `organizeImports` remains unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 11d7de2f-19df-4fb0-93dd-2326ed5fc3ba
📒 Files selected for processing (2)
.changeset/neat-papers-think.mdcrates/biome_lsp/src/server.tests.rs
Merging this PR will not alter performance
Comparing Footnotes
|
08e9b65 to
f7f7387
Compare
Summary
Fix #7583. Follow-up of #9353.
organizeImportsnow merges bare exports:Here is an example of bare export merging:
Bare
exportare now sorted with other exports.Bare exports are placed after
export from. This is why I manually re-implementedOrd for ImportKey.Here is an example:
I chose this order because:
exportare often placed at the endexport fromstatements are betweenimportandexport.Imports are usually placed first, then bare exports should be placed last (
export fromare in-between).importwithattributes are placed aboveimportwithout attributes.Thus, placing exports with a
fromclause above exports without it follows the same logic.Finally, this PR solves another issue reported some weeks or months ago about a missing blank line between imports and a bare export. Unfortunately, I didn't find the issue or discussion that brought it up.
Here is an example of the fix:
import { A } from "package"; + export { A };Test Plan
I added several tests.
Docs
I edited the changeset of #9353 to cover this PR.