fix(linter/type-aware): use correct span for disable directives#19576
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
84cb938 to
89b58d0
Compare
5ffaa96 to
97c9a13
Compare
There was a problem hiding this comment.
Pull request overview
This pull request fixes an issue where eslint-disable-next-line comments were not being respected for the no-unnecessary-condition rule in type-aware linting. The root cause was that the disable directive checking was using the diagnostic's main span field, but for type-aware diagnostics with labeled ranges, the actual code location being flagged is in the labeled_ranges field.
Changes:
- Modified span selection logic in
should_skip_diagnosticto use the first labeled range when available - Added test case demonstrating the fix with a disable comment that should suppress the diagnostic
- Updated snapshot to reflect that the suppressed diagnostic no longer appears
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/tsgolint.rs | Updated should_skip_diagnostic to use first labeled range for span when checking disable directives |
| apps/oxlint/fixtures/tsgolint/no-unnecessary-condition.ts | Added test case with disable comment to verify the fix |
| apps/oxlint/src/snapshots/fixtures__tsgolint_--type-aware@oxlint.snap | Updated snapshot showing diagnostic is now correctly suppressed |
Merging this PR will not alter performance
Comparing Footnotes
|
97c9a13 to
d19f671
Compare
Merge activity
|
d19f671 to
50fc70d
Compare
# Oxlint ### 🚀 Features - 46177dd linter: Implement unicorn/prefer-module (#19603) (camc314) - 42f78bb linter: Implement unicorn/prefer-ternary (#19605) (camc314) ### 🐛 Bug Fixes - 43df857 react/exhaustive-deps: Normalize .current callback deps (#19610) (camc314) - 574f48f linter/no-throw-literal: Close warning block (#19612) (camc314) - 79fe3b4 linter/prefer-mock-return-shorthand: Avoid unsafe autofixes for call-like returns (#19581) (camc314) - 85045e8 linter: Check protected members in explicit-module-boundary-types (#19594) (camc314) - e38115e linter: Catch missing return type on exported arrow/function expressions (#19587) (Peter Wagenet) - 419d3fd linter: Fix false negatives in typescript/no-require-imports (#19589) (Peter Wagenet) - 7958b56 linter: Fix syntax error reporting in some output formatters. (#19590) (connorshea) - 024f51c linter: Add help text to more eslint diagnostics (#19591) (Anthony Amaro) - a8489a1 linter: Warning `eslint/no-throw-literal` rule to be deprecated, better use `typescript/only-throw-error` (#19593) (Said Atrahouch) - 50fc70d linter/type-aware: Use correct span for disable directives (#19576) (camc314) - 421a99c linter: Add help guidance to eslint diagnostic messages (#19562) (Anthony Amaro) - e81364a linter: Add help text to eslint rule diagnostics (#19560) (Anthony Amaro) - 89b58d0 linter: Add help text to more eslint rule diagnostics (#19561) (Anthony Amaro) - 74f7833 linter/jest/prefer-mock-return-shorthand: Preserve typed arrow returns (#19556) (camc314) - bdd6f34 linter: Restrict prefer-import-in-mock to mock calls (#19555) (camc314) ### 📚 Documentation - a331993 linter: Improve docs for `eslint/radix` rule. (#19611) (connorshea) ### 🛡️ Security - c67f9dc linter: Update ajv version. (#19613) (connorshea) # Oxfmt ### 🚀 Features - 984dc07 oxfmt: Strip `"experimental"SortXxx` prefix (#19567) (leaysgur) ### 🐛 Bug Fixes - d7b63a4 oxfmt: Update API types for `sortPackageJsonOptions` (#19569) (leaysgur) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>

fixes #19575