eslint-plugin-react on ESLint 10: getFilename is not a function
ESLint 10 breaks eslint-plugin-react 7.37.5 with 'contextOrFilename.getFilename is not a function' under settings.react.version 'detect'. Pin the version, or move to @eslint-react or react-x.
After upgrading to ESLint 10, linting stops with Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function. The cause is eslint-plugin-react 7.37.5, still the latest release (2025-04-03): its version lookup calls context.getFilename(), which ESLint 10 removed. The lookup only runs when settings.react.version is "detect", so pinning the version avoids the crash for the recommended rules. If you want to leave the plugin, @eslint-react/eslint-plugin and eslint-plugin-react-x support ESLint 10, at the price of renaming rules.
Covers ESLint 10 with flat config. Everything marked as run was run on 2026-11-20 with ESLint 10.14.0, eslint-plugin-react 7.37.5, npm 11.6.2 and Node 24.12.0. Last updated 2026-11-20. We publish eslint-plugin-react-features, a different plugin; this page does not recommend it, and why is at the end.
The error
TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a functionIt is tracked upstream as vercel/next.js#89764 (open) and under jsx-eslint/eslint-plugin-react#3977, "ESLint v10 compatibility" (open, locked). A pull request that completes ESLint 10 support, #4022, was still open when this page was written.
The install itself fails first if you use npm's default resolver, because 7.37.5 declares eslint peer ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7. Most people pass --legacy-peer-deps or add an overrides entry and then meet the crash above.
Which rules crash
We loaded each of the 103 rules of 7.37.5 alone, at error, and linted a small file with a class component and a forwardRef component:
settings.react.version | Rules that throw | In recommended? |
|---|---|---|
"detect" | 37 of 103 | yes, including display-name |
"18.3" (any explicit version) | 6 of 103 | none |
With an explicit version the six that still throw are forward-ref-uses-ref, jsx-curly-spacing, jsx-equals-spacing, jsx-filename-extension, jsx-one-expression-per-line and jsx-tag-spacing. This is a smoke test with one input file: a throw means the rule cannot run on ESLint 10, and a rule that did not throw has not been shown correct.
Workaround: pin the React version
Most shared configs set version: "detect". Override it with the React version you ship:
import react from 'eslint-plugin-react';
export default [
react.configs.flat.recommended,
{
settings: {
react: { version: '18.3' }, // not 'detect'
},
},
];We ran this configuration with react.configs.flat.recommended on ESLint 10.14.0: with version: "detect" it throws the error above, with version: "18.3" it lints without throwing. If a shared config such as eslint-config-next sets detect for you, your own settings object placed after it in the array wins, because flat config merges later objects over earlier ones. Do not enable the six rules listed above until a release fixes them.
Installing next to ESLint 10 needs a peer override:
npm install --save-dev eslint@10 eslint-plugin-react@7.37.5 --legacy-peer-depsThis is a workaround for an unreleased fix, not a fix: we found no announced release date, and the latest release still declares no ESLint 10 support in its peer range.
Alternatives, honestly
| Option | ESLint 10 | Keeps react/* names and settings.react? | Pick it when |
|---|---|---|---|
Stay on eslint-plugin-react 7.37.5 with the version pinned | recommended runs, six rules throw | Yes | You cannot rename rules and can wait for a release. The cheapest change. |
@eslint-react/eslint-plugin and eslint-plugin-react-x | Yes. Version 5.30.5 requires Node 20.19 or newer, peer eslint: * | No. Rules are renamed and split, and legacy class and propTypes rules are marked as legacy in its migration guide | New or modern code with function components and TypeScript, and you accept a rename |
eslint-plugin-react-hooks 7.1.1 | Yes, peer includes ^10.0.0 | Not applicable: hooks rules only | You only need rules-of-hooks and exhaustive-deps; it sits next to any choice above |
oxlint's built-in react plugin | Not an ESLint plugin | A subset by name; no settings.react | You are already moving off ESLint and the rules you use are covered |
@eslint-react/eslint-plugin and eslint-plugin-react-x are two packages from the same project and release line. They are not a drop-in replacement: the project's own guide maps each old rule to one or more new ones, and some old rules have no counterpart. Do not choose them to stay on ESLint 9, because version 5 expects ESLint 10.
What about eslint-plugin-react-features?
eslint-plugin-react-features is ours. We have not graded it against eslint-plugin-react's test cases, so we make no claim about how close it is, and we do not suggest it as a replacement. If you try it, treat every difference from eslint-plugin-react as a question for us in our issue tracker.
Related
- Flat config migration covers moving off
.eslintrc.
Building secure JavaScript with Interlace? Star the repo to get new rules and CWE coverage as we ship them — or follow the AI-code-security benchmarks behind them.
Upgrade to ESLint 10 with eslint-plugin-import
eslint-plugin-import has no ESLint 10 release (peer ^9), so installs fail with ERESOLVE. Swap it in one line with eslint-plugin-import-next, or use import-x.
Compatibility
Which lint engines, ESLint majors, and Node.js versions Interlace supports — and the policy that decides what stays in the matrix.