Skip to content

Commit 6ec1112

Browse files
ddmoney420claudecamc314
authored
fix(linter): mark unused disable directive fix as suggestion (#18703)
## Summary Changes the auto-fix for "unused disable directives" from a safe fix to a suggestion, preventing unintended removal of directives needed byother linters. Fixes #17522 ## Problem The auto-fix for unused disable directives would automatically remove `eslint-disable` or `oxlint-disable` comments when running `oxlint --fix`. However, these directives might be: 1. Needed for ESLint when both linters are used 2. For JS plugins not yet supported by oxlint ## Solution Changed the fix kind from `FixKind::Fix` to `FixKind::Suggestion` in: - `crates/oxc_linter/src/context/host.rs` (line 323) - `crates/oxc_linter/src/disable_directives.rs` (lines 118 and 141) ## Behavior Change - **Before**: `oxlint --fix` automatically removes unused disable directives - **After**: The fix is a suggestion (requires `--fix-suggestions` to apply) ## Test plan - [x] All 11 tests in the `disable_directives` module pass - [ ] Verify `--fix` no longer auto-removes disable directives - [ ] Verify `--fix-suggestions` still applies the fix when desired 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: ddmoney420 <ddmoney420@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Cameron <cameron.clark@hey.com>
1 parent 5bd6758 commit 6ec1112

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

crates/oxc_linter/src/context/host.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ impl<'a> ContextHost<'a> {
320320
.with_label(span)
321321
.with_severity(rule_severity),
322322
PossibleFixes::Single(
323-
Fix::delete(span).with_kind(FixKind::Fix).with_message(fix_message),
323+
Fix::delete(span)
324+
.with_kind(FixKind::Suggestion)
325+
.with_message(fix_message),
324326
),
325327
));
326328
}

crates/oxc_linter/src/disable_directives.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl RuleCommentRule {
115115
self.name_span.start - comma_before_offset,
116116
self.name_span.end,
117117
))
118-
.with_kind(FixKind::Fix);
118+
.with_kind(FixKind::Suggestion);
119119
}
120120

121121
let after_source = &source_text[self.name_span.end as usize..comment_span.end as usize];
@@ -138,7 +138,7 @@ impl RuleCommentRule {
138138
self.name_span.start,
139139
self.name_span.end + comma_after_offset,
140140
))
141-
.with_kind(FixKind::Fix);
141+
.with_kind(FixKind::Suggestion);
142142
}
143143

144144
unreachable!(

0 commit comments

Comments
 (0)