Skip to content

Apply fixable rule customizations per problem - #2251

Open
Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-rule-customization-fixable-cache
Open

Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-rule-customization-fixable-cache

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown

eslint.rules.customizations entries with fixable are matched against each problem (problem.fix !== undefined, added in #1841), but RuleSeverities.getOverride caches the result by rule ID only. The first problem of a rule therefore decides the override for every later problem of that rule, across documents, until settings or watched files change. Some rules report both kinds. For eqeqeq, typeof a == 'string' gets a fix and a == b does not. With { "rule": "*", "fixable": true, "severity": "off" }, if the fixable problem is seen first, the non-fixable a == b error is hidden as well. In the reverse order, the fixable problem keeps its original severity.

This adds the problem's fixability to the cache key and keeps the per-problem behavior from #1841. Open #2175 also changes this cache key, so whichever lands second will need a small rebase.

  • Ran: npm run compile, npm run lint (no errors), npm test (client 27/27, server 10/10).
  • Checked: the new tests in server/src/tests/eslint.test.ts fail on main ('off' !== undefined, undefined !== 'off') and pass with this change.

RuleSeverities cached the override by rule ID only, so the fixable filter was evaluated for the first problem of a rule and reused for all later problems of that rule. Include the problem's fixability in the cache key.
Copilot AI balanced review requested due to automatic review settings October 24, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The localized change consistently updates cache access and includes regression coverage for both reported failure cases.

No open issues 🎉

What changed in this PR

This PR fixes order-dependent severity customizations in the ESLint server by caching overrides per rule and problem fixability, preserving the per-problem behavior introduced in #1841.

Changes:

  • Include fixability in all severity-cache reads and writes.
  • Add regression tests covering fixable-first and non-fixable-first encounter orders.
File Description
server/​src/​tests/​eslint.test.ts Tests both encounter orders for fixability-based customizations.
server/​src/​eslint.ts Includes problem fixability in the severity-override cache key.

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants