fix(analyzer): respect overrides that disable rules when using --only#10151
fix(analyzer): respect overrides that disable rules when using --only#10151blackwell-systems wants to merge 5 commits into
Conversation
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 detectedLatest commit: f90d70c The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe 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)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. 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 `@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
📒 Files selected for processing (2)
.changeset/fix-suppress-only-overrides.mdcrates/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.
There was a problem hiding this comment.
🧹 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
⛔ Files ignored due to path filters (1)
crates/biome_cli/tests/snapshots/main_cases_suppressions/suppress_only_respects_override_disabling_rule.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (1)
crates/biome_cli/tests/cases/suppressions.rs
Summary
Fixes #10113. When
--onlywas specified,LintVisitor::finish()andAssistsVisitor::finish()skipped populatingdisabled_rulesfrom the merged override configuration. This caused--suppresswith--onlyto 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, bothLintVisitor::finish()andAssistsVisitor::finish()had:When
--onlyis active,has_only_filteristrue, so the entire block is skipped. This meansdisabled_rulesnever receives the override-disabled rules from the merged config. SinceAnalysisFilter::match_rulegivesdisabled_rulesprecedence overenabled_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_filterguard. Theenabled_rulespopulation stays gated (we don't want all enabled rules when--onlyis set), but disabled rules from overrides should always be respected.Applied to both
LintVisitor::finish()andAssistsVisitor::finish()for consistency.Test plan
cargo test --package biome_cli -- suppressions)--suppresswith--onlyignores overrides that disable a rule #10113: the override-disabled file no longer receives a suppression comment