Skip to content

refactor(organizeImports): require sortBareImports for bare matchers#10517

Merged
Conaclos merged 3 commits into
nextfrom
conaclos/organizeImports-require-sortBareImports-with-bare-matchers
Jun 3, 2026
Merged

refactor(organizeImports): require sortBareImports for bare matchers#10517
Conaclos merged 3 commits into
nextfrom
conaclos/organizeImports-require-sortBareImports-with-bare-matchers

Conversation

@Conaclos

Copy link
Copy Markdown
Member

Summary

I think that #10190 is not ready for v2.5
To avoid any blocking, I submitted this PR.

This PR errors on configurations that use bare kind matchers without settings sortBareImports to true.
The diagnostic points to #10190.

Test Plan

I added a test.

Docs

No change. The docs and changesets already speak about that.

@Conaclos Conaclos added this to the Biome v2.5 milestone May 31, 2026
@changeset-bot

changeset-bot Bot commented May 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6728f1c

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

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels May 31, 2026
@Conaclos Conaclos changed the title refactor(organizeImports): require sortBareImports when using bare ki… refactor(organizeImports): require sortBareImports for bare matchers May 31, 2026
@Conaclos Conaclos force-pushed the conaclos/organizeImports-require-sortBareImports-with-bare-matchers branch from b0744a3 to f5788a3 Compare May 31, 2026 12:02
@Conaclos Conaclos requested review from a team May 31, 2026 12:03
@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds detection for bare import matchers (value-based ImportKindMatcher and NegatableImportKindMatcher, and has_bare_matchers on GroupMatcher/ImportGroup/ImportGroups) and a DeserializableValidator on OrganizeImportsOptions that errors if bare matchers appear while sort_bare_imports is not explicitly true. Includes a test options JSON exercising a bare-kind group.

Possibly related PRs

  • biomejs/biome#10074: Introduced the bare import kind matcher and candidate.is_bare() used by this PR's detection logic.

Suggested reviewers

  • ematipico
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: requiring sortBareImports for bare matchers in the organiseImports configuration.
Description check ✅ Passed The description clearly relates to the changeset, explaining the purpose (preventing unready functionality), the solution (error on bare matchers without sortBareImports), and test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch conaclos/organizeImports-require-sortBareImports-with-bare-matchers

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

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention of the PR is good, but the new functions take self which is not necessarary

Comment thread crates/biome_rule_options/src/organize_imports/import_groups.rs
Comment thread crates/biome_rule_options/src/organize_imports/import_groups.rs Outdated
Comment thread crates/biome_rule_options/src/organize_imports/import_groups.rs Outdated
@Conaclos Conaclos requested a review from ematipico June 2, 2026 21:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/biome_rule_options/src/organize_imports/import_groups.rs (1)

31-33: ⚡ Quick win

Tighten these helper visibilities.

These look like internal plumbing for the validator/matcher path, so pub feels a bit generous. Exposing them widens the public API for free, which is rarely a bargain. pub(crate) for ImportGroups::has_bare_matchers and private methods for the other two should be enough here.

♻️ Proposed tweak
 impl ImportGroups {
@@
-    pub fn has_bare_matchers(&self) -> bool {
+    pub(crate) fn has_bare_matchers(&self) -> bool {
         self.0.iter().any(|group| group.has_bare_matchers())
     }
@@
 impl GroupMatcher {
@@
-    pub fn has_bare_matchers(&self) -> bool {
+    fn has_bare_matchers(&self) -> bool {
         match self {
             Self::Import(import_matcher) => import_matcher
                 .kind
                 .is_some_and(|kind_matcher| kind_matcher.kind.is_bare()),
             Self::Source(_source_matcher) => false,
         }
     }
@@
 impl ImportKindMatcher {
@@
-    pub const fn is_bare(&self) -> bool {
+    const fn is_bare(&self) -> bool {
         matches!(self, Self::Bare)
     }
 }

Also applies to: 149-156, 328-329

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/biome_rule_options/src/organize_imports/import_groups.rs` around lines
31 - 33, The helper visibility is too broad: change the public signature of
ImportGroups::has_bare_matchers from pub fn to pub(crate) fn and make the other
two helper methods mentioned in the review (the internal matcher/validator
helpers referenced at lines 149-156 and 328-329) private (remove pub) so they
are not exposed in the public API; update their declarations (method names
matching those ranges) accordingly and run tests to ensure no external call
sites rely on them.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/biome_rule_options/src/organize_imports/import_groups.rs`:
- Around line 31-33: The helper visibility is too broad: change the public
signature of ImportGroups::has_bare_matchers from pub fn to pub(crate) fn and
make the other two helper methods mentioned in the review (the internal
matcher/validator helpers referenced at lines 149-156 and 328-329) private
(remove pub) so they are not exposed in the public API; update their
declarations (method names matching those ranges) accordingly and run tests to
ensure no external call sites rely on them.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7b8c7178-7916-4402-9a97-3396a5595356

📥 Commits

Reviewing files that changed from the base of the PR and between adde1c3 and 6728f1c.

📒 Files selected for processing (1)
  • crates/biome_rule_options/src/organize_imports/import_groups.rs

@Conaclos Conaclos merged commit 8e254c5 into next Jun 3, 2026
26 checks passed
@Conaclos Conaclos deleted the conaclos/organizeImports-require-sortBareImports-with-bare-matchers branch June 3, 2026 08:42
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.

2 participants