Skip to content

fix(analyzer): respect overrides that disable rules when using --only#10151

Open
blackwell-systems wants to merge 5 commits into
biomejs:mainfrom
blackwell-systems:fix/suppress-only-respects-overrides
Open

fix(analyzer): respect overrides that disable rules when using --only#10151
blackwell-systems wants to merge 5 commits into
biomejs:mainfrom
blackwell-systems:fix/suppress-only-respects-overrides

Conversation

@blackwell-systems
Copy link
Copy Markdown

Summary

Fixes #10113. When --only was specified, LintVisitor::finish() and AssistsVisitor::finish() skipped populating disabled_rules from the merged override configuration. This caused --suppress with --only to add suppression comments to files where the target rule was disabled by an override.

Root cause

In crates/biome_service/src/file_handlers/mod.rs, both LintVisitor::finish() and AssistsVisitor::finish() had:

if !has_only_filter {
    self.enabled_rules.extend(rules.as_enabled_rules());
    self.disabled_rules.extend(rules.as_disabled_rules());
}

When --only is active, has_only_filter is true, so the entire block is skipped. This means disabled_rules never receives the override-disabled rules from the merged config. Since AnalysisFilter::match_rule gives disabled_rules precedence over enabled_rules, the missing entries allow the rule to fire on files where it should be off.

Fix

Move disabled_rules.extend(rules.as_disabled_rules()) outside the !has_only_filter guard. The enabled_rules population stays gated (we don't want all enabled rules when --only is set), but disabled rules from overrides should always be respected.

Applied to both LintVisitor::finish() and AssistsVisitor::finish() for consistency.

Test plan

When --only was specified, LintVisitor::finish() and
AssistsVisitor::finish() skipped populating disabled_rules from
the merged override configuration. This caused --suppress with
--only to add suppression comments to files where the rule was
disabled by an override.

Move disabled_rules.extend(rules.as_disabled_rules()) outside the
!has_only_filter guard so overrides that disable rules are always
respected, regardless of whether --only is active.

Fixes biomejs#10113
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

🦋 Changeset detected

Latest commit: f90d70c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions Bot added the A-Project Area: project label Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

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: 06e008ab-ee01-42eb-8992-4970fadb787e

📥 Commits

Reviewing files that changed from the base of the PR and between cc72075 and a25e150.

📒 Files selected for processing (1)
  • crates/biome_cli/tests/cases/suppressions.rs

Walkthrough

The change makes disabled-rule overrides from configuration always included when building the disabled-rules set used by suppression logic. LintVisitor::finish and AssistsVisitor::finish now extend self.disabled_rules with rules.as_disabled_rules() regardless of an active --only filter. A regression test ensures --suppress with --only does not insert suppression comments into files where the rule is disabled via an override. A patch-level changeset documents the behaviour.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the primary fix: respecting override rules that disable rules when --only flag is used.
Description check ✅ Passed The description clearly explains the bug, root cause, fix, and test plan—well-documented and directly related to the changeset.
Linked Issues check ✅ Passed The PR fully addresses issue #10113 by fixing disabled-rule overrides to be respected when --only is used with --suppress.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the --only/--suppress override bug; no unrelated modifications detected.

✏️ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@crates/biome_service/src/file_handlers/mod.rs`:
- Around line 1704-1707: Add a regression test that reproduces the --suppress +
--only override-disabled case by constructing input with an override that
disables a rule and invoking the suppression path (the code that uses
self.disabled_rules.extend(rules.as_disabled_rules()) in file_handlers::mod.rs),
then assert that no suppression comment is added to that file; place the test
alongside existing tests exercising lint/assist visitors (covering the same
logic touched around lines 1704 and 1995–1998) so future changes cannot regress
this behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2736d680-f154-4fb9-9226-efa0f67e582a

📥 Commits

Reviewing files that changed from the base of the PR and between e94acb2 and 6bf7453.

📒 Files selected for processing (2)
  • .changeset/fix-suppress-only-overrides.md
  • crates/biome_service/src/file_handlers/mod.rs

Comment thread crates/biome_service/src/file_handlers/mod.rs
Test verifies that when a biome config disables a rule via an override
(e.g., noDebugger: "off" for foo/**), running --suppress --only does
not add suppression comments to files matching the override path.
@github-actions github-actions Bot added the A-CLI Area: CLI label Apr 28, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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_cli/tests/cases/suppressions.rs (1)

354-357: Optional: make the positive assertion more specific.

contains("biome-ignore") is a bit broad; matching the rule ID makes this test harder to false-pass.

Suggested tweak
-    assert!(
-        regular_content.contains("biome-ignore"),
-        "regular file should receive a suppression comment"
-    );
+    assert!(
+        regular_content.contains("biome-ignore lint/suspicious/noDebugger"),
+        "regular file should receive a noDebugger suppression comment"
+    );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_cli/tests/cases/suppressions.rs` around lines 354 - 357, The
assertion using regular_content.contains("biome-ignore") is too broad; update
the test to assert the exact suppression string including the rule ID to avoid
false positives — for example, check regular_content for the full token like
"biome-ignore=RULE_ID" (or the actual rule id used in the test) or use a
stricter substring/regex match; modify the assertion that references
regular_content in suppressions.rs accordingly so it matches the full
suppression marker rather than just "biome-ignore".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_cli/tests/cases/suppressions.rs`:
- Around line 354-357: The assertion using
regular_content.contains("biome-ignore") is too broad; update the test to assert
the exact suppression string including the rule ID to avoid false positives —
for example, check regular_content for the full token like
"biome-ignore=RULE_ID" (or the actual rule id used in the test) or use a
stricter substring/regex match; modify the assertion that references
regular_content in suppressions.rs accordingly so it matches the full
suppression marker rather than just "biome-ignore".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ffdcec1-d56f-4073-9588-745d42f75368

📥 Commits

Reviewing files that changed from the base of the PR and between 6bf7453 and cc72075.

⛔ Files ignored due to path filters (1)
  • crates/biome_cli/tests/snapshots/main_cases_suppressions/suppress_only_respects_override_disabling_rule.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (1)
  • crates/biome_cli/tests/cases/suppressions.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 --suppress with --only ignores overrides that disable a rule

1 participant