Replace eslint-plugin-react with @eslint-react for ESLint 10 - #44
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
eslint-plugin-react@7.37.5(its latest release) does not support ESLint 10 — the version we already require (eslint: ">=10.7").ESLint 10 is deliberately excluded, and the maintainer confirms this is intentional (jsx-eslint/eslint-plugin-react#4018). Consumers currently hit hard crashes:
TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function—
lib/util/version.jscallscontext.getFilename(), removed in ESLint 10. Only reachable whensettings.react.version === 'detect', which this config sets.TypeError: sourceCode.isSpaceBetweenTokens is not a functioninreact/jsx-tag-spacing— ESLint 10 renamed
SourceCode#isSpaceBetweenTokenstoisSpaceBetween.Pinning
settings.react.versiononly clears the first one, so the config cannot be salvaged through options. The upstream fix (jsx-eslint/eslint-plugin-react#4022) is still unmerged with no prerelease on npm, so this replaces the plugin instead of waiting.What changed
eslint-plugin-reactflat.recommended@eslint-react/eslint-pluginrecommended-typescriptreact/jsx-curly-brace-presence,react/jsx-tag-spacing@stylistic/eslint-plugin(same rules, same options)react/jsx-sort-propseslint-plugin-perfectionistsort-jsx-propsAll three replacements declare ESLint 10 support (
@stylisticpeer is^9.0.0 || ^10.0.0, the other two are unconstrained).Rules dropped as obsolete for React 19 + TypeScript, with no equivalent needed:
react/react-in-jsx-scope,react/jsx-uses-react— automatic JSX runtimereact/prop-types,react/sort-default-props— TypeScript /defaultPropsremovalreact/jsx-no-undef—tscand coreno-undefcover itreservedFirst: trueis preserved through a perfectionistreservedcustom group matching^(key|ref)$.Oxlint plugin
src/oxlint.tswrapped threeeslint-plugin-reactrules that oxlint has no native equivalent for.prop-typeswas always forcedoffbydevupRuleOverridesandsort-default-propsis obsolete, so only prop sorting remains — now sourced from perfectionist:devup/react/prop-types— removed (was alwaysoff)devup/react/sort-default-props— removed (obsolete)devup/react/jsx-sort-props→devup/perfectionist/sort-jsx-propsThe
react/*entries underrules:insrc/oxlint-config.tsare oxlint's built-in react plugin and are untouched.Dependencies
Ran
bunx @dependency-check-updates/cli -d -u --rm.typescriptwas bumped to^7.0by the tool and reverted to^6.0, because typescript-eslint throws on TS 7 (peer: >=4.8.4 <6.1.0, and it targets TS >= 7.1 per typescript-eslint#10940).Also picked up:
simple-import-sort13 → 14,oxlint1.73 → 1.79,typescript-eslint8.64 → 8.67,actions/setup-nodev6 → v7.eslint-plugin-reactis now absent frompackage.json,bun.lock, and every source file —bun why eslint-plugin-reactreports it is not in the lockfile.Breaking change note
Marked Minor in the changepack, but consumers who override any
react/*rule will need to update: with thereactplugin no longer registered, ESLint 10 fails config resolution withCould not find plugin react. Rule id mapping is in the changepack note.Verification
bun test— 83 pass, 100% line and function coverage maintainedbun run lint(oxlint) — exit 0bun run build(tsc+ 4 bundles) — exit 0devup-uiviabun link: with this branch itseslintrun goes from a hard crash to exit 0 (0 errors, 20 advisory@eslint-reactwarnings), after deleting the local workaround that strippedeslint-plugin-reactout ofconfigs.recommended.