Skip to content

Fix ESLint v10 RuleContext API removal (follow-up to #3972) - #3979

Draft
ledsun wants to merge 2 commits into
jsx-eslint:masterfrom
ledsun:update-deprecated-calls-v8
Draft

ledsun wants to merge 2 commits into
jsx-eslint:masterfrom
ledsun:update-deprecated-calls-v8

Conversation

@ledsun

@ledsun ledsun commented Feb 9, 2026 •

Copy link
Copy Markdown

This PR follows up on the feedback in the comments of #3972 and incorporates the requested changes.

I think this PR will fix #3977.

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we'll need regression tests - it might be as simple as adding eslint 10 to the GHA matrix.

@codecov

codecov Bot commented Feb 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.56%. Comparing base (c9a2de7) to head (4b25647).
⚠️ Report is 62 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3979      +/-   ##
==========================================
- Coverage   97.71%   97.56%   -0.15%     
==========================================
  Files         137      134       -3     
  Lines       10188    10177      -11     
  Branches     3797     3797              
==========================================
- Hits         9955     9929      -26     
- Misses        233      248      +15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ledsun
ledsun marked this pull request as ready for review February 11, 2026 12:08
Comment thread lib/util/eslint.js Resolved
Comment thread lib/util/version.js Resolved
Comment thread lib/util/makeNoMethodSetStateRule.js Resolved
Comment thread .github/workflows/node-18+.yml Resolved
Comment thread lib/util/version.js Resolved
Comment thread package.json Resolved
Comment thread .github/workflows/eslint-9+.yml Resolved
Comment thread .github/workflows/eslint-8-.yml Resolved
Comment thread .github/workflows/eslint-9+.yml Resolved
@karlnorling

Copy link
Copy Markdown

@ledsun do you have time to address the failing checks. I'm looking at updating to eslint 10 and we're using the eslint-plugin-react

@codler

This comment was marked as spam.

@rburgstaller

This comment was marked as off-topic.

@Aluisio

Aluisio commented Aug 20, 2026

Copy link
Copy Markdown

@ljharb The Next.js team is waiting for this plugin to be compatible with ESLint 10 so they can update @next/eslint-plugin-next to ESLint 10. Can you help us?

@ternaus ternaus mentioned this pull request Aug 21, 2026
@plthomasva

Copy link
Copy Markdown

Just so everyone commenting on this PR is aware, this has been superceded by #4022 which has a clean test result and has been validated by multiple non-maintainer reviewers. We're just waiting for @ljharb to review that PR at this point.

@coderabbitai coderabbitai Bot mentioned this pull request Aug 21, 2026
@rafa-plx

rafa-plx commented Sep 29, 2026 •

Copy link
Copy Markdown

Some news here? This PR also blocks the ESLint 10 usage for Nx workspaces

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this! The workflow and types changes look close, but adding ^10 to peerDependencies isn't safe yet: running the full test suite against eslint 10.13 (node 20, 22, and 24) gives ~833 failures:

  • ~800 runtime crashes: eslint 10 removed SourceCode#isSpaceBetweenTokens, which jsx-curly-spacing, jsx-tag-spacing, jsx-one-expression-per-line, jsx-space-before-closing, and jsx-equals-spacing all call, so those rules throw a TypeError for eslint 10 users. This needs a helper in lib/util/eslint.js; note that isSpaceBetween isn't a drop-in replacement, since isSpaceBetweenTokens also counts whitespace inside JSXText (which jsx-one-expression-per-line relies on), and isSpaceBetween doesn't exist before eslint 6.7.
  • @extends JSDoc detection: no-typos and prop-types no longer recognize /** @extends React.Component */, since getJSDocComment is gone.
  • stricter RuleTester: valid cases that have output or errors are now rejected (jsx-indent, jsx-indent-props, jsx-no-bind, require-optimization) - those are test bugs that can just be cleaned up.
  • jsx-no-undef: the tests' inline /*eslint no-undef:1*/ now also produces a core no-undef error.
  • sort-prop-types: tests that hardcode the legacy typescript-eslint-parser break with the typescript@5 this installs.

The eslint 10 CI jobs this PR adds would be red until those are fixed.

Comment thread package.json
},
"peerDependencies": {
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7"
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7 || ^10"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This shouldn't be added until the runtime incompatibilities (see the review summary) are fixed; otherwise eslint 10 users will hit crashes in several rules.

@plthomasva plthomasva Nov 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Addressed in #4022: all 5 runtime and test suite incompatibilities from the review summary have been resolved (7ce50e33, 8b91af32, 818c0cc1, 761917a4, bc825e04, 80145fd2) and verified against ESLint 10 in CI, making ^10 in peerDependencies safe.

node-version: ${{ matrix.node-version }}
after_install: |
npm install --no-save "eslint@${{ matrix.eslint }}" "@typescript-eslint/parser@${{ matrix.typescript-eslint == 8 && 8.17 || matrix.typescript-eslint }}" "babel-eslint@${{ matrix.babel-eslint }}"
npm install --no-save "eslint@${{ matrix.eslint }}" "@typescript-eslint/parser@${{ matrix.eslint == 10 && 'canary' || (matrix.typescript-eslint == 8 && 8.17 || matrix.typescript-eslint) }}" "babel-eslint@${{ matrix.babel-eslint }}" ${{ matrix.eslint == 10 && '"typescript@5"' || '' }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

canary is unpinned and changes from run to run; stable @typescript-eslint/parser 8 (8.72+) already supports eslint 10 in its peer deps, so this can use 8 instead.

@plthomasva plthomasva Nov 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Addressed in #4022 (3027ec92): removed unpinned 'canary' and pinned to @typescript-eslint/parser@8.17 (matching ESLint 9, to avoid the @typescript-eslint/parser >= 8.18 breaking change noted in 2c0b10cb / typescript-eslint/typescript-eslint#10480), with ESLint 10 peer dependency resolution handled via package.json overrides and --legacy-peer-deps.

- eslint: 10
node-version: 18
- eslint: 10
node-version: 19

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

eslint 10's engines are ^20.19.0 || ^22.13.0 || >=24, so node 21 and 23 need to be excluded too (and the comment above should be updated to match).

@plthomasva plthomasva Nov 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Addressed in #4022 (8b2254cc, 9a6650d8): excluded Node 21 and 23 in addition to 18 and 19 for eslint: 10, and updated the comment to # ESLint 10 supports Node.js ^20.19.0 || ^22.13.0 || >=24.

- eslint: 10
node-version: 19
- eslint: 10
babel-eslint: 8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is babel-eslint 8 excluded? If it's genuinely incompatible, a comment explaining that would help.

@plthomasva plthomasva Nov 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Addressed in #4022 (3b453326): removed the eslint: 10 / babel-eslint: 8 exclusion. It had only been added earlier in #3979 to stay under the 256-job matrix limit before the workflow was split into eslint-8-.yml and eslint-9+.yml, and babel-eslint: 8 works on ESLint 10 via the scopeManager.addGlobals shim in tests/helpers/ruleTester.js.

* @returns {import('eslint').Rule.RuleModule}
*/
module.exports = function makeNoMethodSetStateRule(methodName, shouldCheckUnsafeCb) {
const docs = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is needed (without it, eslint 10's types fail with TS2353 on category), but it looks like a no-op refactor at a glance - could you add a comment explaining why docs is hoisted, so nobody inlines it back?

@plthomasva plthomasva Nov 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Addressed in #4022 (3b453326): added an explanatory comment above const docs = { ... } noting that docs is hoisted to avoid TypeScript's excess-property check (TS2353) on category with ESLint 10's Rule.RuleMetaData['docs'] type.

@plthomasva

plthomasva commented Nov 22, 2026 •

Copy link
Copy Markdown

In reply to @ljharb's October 22 review summary (#pullrequestreview-5617437510), all 5 runtime/test items (as well as the 5 inline review comments) have now been addressed in #4022:

  • ~800 runtime crashes (SourceCode#isSpaceBetweenTokens): Addressed in fix: complete ESLint 10 compatibility #4022 (7ce50e33) by adding isSpaceBetween(sourceCode, first, second) in lib/util/eslint.js (delegating to isSpaceBetweenTokens when available for ESLint < 6.7–9, and falling back to isSpaceBetween + a getTokensBetween JSXText whitespace check on ESLint 10+) and updating all 5 rules + unit tests.
  • @extends JSDoc detection (getJSDocComment removal): Addressed in fix: complete ESLint 10 compatibility #4022 (8b91af32, 818c0cc1, cbd36dfd) by adding an ESLint 10+ getJSDocComment fallback in lib/util/componentUtil.js that mirrors ESLint 9's ast-utils.js node-remapping and line-adjacency (gap <= 1) semantics.
  • Stricter RuleTester rejecting output/errors on valid cases: Addressed in fix: complete ESLint 10 compatibility #4022 (761917a4) by removing invalid output and errors properties from valid test cases in jsx-indent, jsx-indent-props, jsx-no-bind, and require-optimization (plus stripTypeOnEslint10 in tests/helpers/ruleTester.js in 8b91af32).
  • jsx-no-undef inline /*eslint no-undef:1*/: Addressed in fix: complete ESLint 10 compatibility #4022 (8b91af32, 80145fd2) by mapping /*eslint no-undef:1*/ to /*eslint no-undef:0*/ on ESLint ≥ 10 in tests/lib/rules/jsx-no-undef.js and polyfilling scopeManager.addGlobals in tests/helpers/ruleTester.js.
  • sort-prop-types legacy typescript-eslint-parser with typescript@5: Addressed in fix: complete ESLint 10 compatibility #4022 (8b91af32, bc825e04) by replacing hardcoded parser: parsers.TYPESCRIPT_ESLINT in tests/lib/rules/sort-prop-types.js with features: ['types'] and guarding parsers.TYPESCRIPT_ESLINT in tests/helpers/parsers.js when running under ESLint ≥ 10 or @typescript-eslint/parser ≥ 6.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to ESLint v10 ESLint v10 compatibility