Repository navigation
Labels
LintingRelated to `next lint` or ESLint with Next.js.UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).linear: nextConfirmed issue that is tracked by the Next.js team.
Description
Link to the code that reproduces this issue
https://github.com/bennajah/nextjs16
To Reproduce
- Create a
next.jsproject or clone this repo - Upgrade
eslintto v10 . - Run
eslint
Current vs. Expected behavior
After upgrading ESLint to v10 in a Next.js project, running bun eslint causes the following error:
PS C:\Users\benna\dev\my-app> bun lint
$ eslint
Oops! Something went wrong! :(
ESLint: 10.0.0
TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function
Occurred while linting C:\Users\benna\dev\my-app\app\layout.tsx
at resolveBasedir (C:\Users\benna\dev\my-app\node_modules\eslint-plugin-react\lib\util\version.js:31:100)
at detectReactVersion (C:\Users\benna\dev\my-app\node_modules\eslint-plugin-react\lib\util\version.js:85:19)
at getReactVersionFromContext (C:\Users\benna\dev\my-app\node_modules\eslint-plugin-react\lib\util\version.js:116:25)
at testReactVersion (C:\Users\benna\dev\my-app\node_modules\eslint-plugin-react\lib\util\version.js:181:28)
at usedPropTypesInstructions (C:\Users\benna\dev\my-app\node_modules\eslint-plugin-react\lib\util\usedPropTypes.js:307:36)
at Components.componentRule (C:\Users\benna\dev\my-app\node_modules\eslint-plugin-react\lib\util\Components.js:940:37)
at createRuleListeners (C:\Users\benna\dev\my-app\node_modules\eslint\lib\linter\linter.js:497:15)
at C:\Users\benna\dev\my-app\node_modules\eslint\lib\linter\linter.js:623:7
at Array.forEach (<anonymous>)
at runRules (C:\Users\benna\dev\my-app\node_modules\eslint\lib\linter\linter.js:557:31)Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 12244
Available CPU cores: 8
Binaries:
Node: 24.13.0
npm: 11.6.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.1.6 // Latest available version is detected (16.1.6).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Linting
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
No response
Reacted by Magnus Natrud Holta, marc-mpac, David Southmountain, El Mahdi Bennajah, David von Mühlenen, Georg Friedrich, Dušan Dodić, Keisuke Komeda, Alex Thomae, Yevgeniya Kobrina and 75 more
Reacted by Astronas and Aleksei Vesnin
Reacted by Syed Abdullah Yaqoob and Aleksei Vesnin
Reacted by Tiago Surjus Kaneta, Jon Haro, Dušan Dodić, Oscar Gauss Carvajal Yucra, Nad Alaba, yd-tw, Carlos Esteban Lopez Jaramillo, Marko Kosir, Evgeny Bobkin, Khiet Tam Nguyen and 10 more
Metadata
Metadata
Assignees
Labels
LintingRelated to `next lint` or ESLint with Next.js.UpstreamRelated to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).linear: nextConfirmed issue that is tracked by the Next.js team.
Activity
simonhudson commentedon Feb 11, 2026
Also seeing same error for
react/no-direct-mutation-staterule when running Lint in GH actionsjWytrzes commentedon Feb 12, 2026
Same here and also same with
react/no-direct-mutation-stateas mentionedEDIT: And when I turn off both of them it changes to
react/no-render-return-value, so probably it can go on like thatfix: downgrade eslint to ^9, skip flaky e2e test in CI
fix: downgrade eslint to ^9, skip flaky e2e test in CI
chore(deps-dev): Bump the development group with 8 updates (#2)
OscarGauss commentedon Feb 19, 2026
Temporary Fix for ESLint v10:
This error happens because
eslint-plugin-react(a dependency ofeslint-config-next) uses the legacycontext.getFilename()API for version auto-detection, which was removed in ESLint v10.To fix this, you must explicitly define your React version in your
eslint.config.mjssettings to bypass the auto-detection logic.I've created a Gist with the corrected configuration for Next.js + ESLint 10: "Next.js ESLint v10 Fix"
Key change:
Fix eslint-plugin-react auto-detection crash with ESLint v10
chore(deps): update dependency eslint to v10 (#1611)
fix: set react version in eslint settings to fix ESLint 10 compatibility
fix(eslint): add explicit react version
t6adev commentedon Feb 25, 2026
It should be work for some cases.
https://www.npmjs.com/package/@eslint/compat
44 remaining items
Fix lint by downgrading eslint due to imcompatibility
chore(deps): move eslint to v10 by composing plugins directly
build(deps-dev): bump the dev-dependencies group with 7 updates (#59)
chore(deps): next 16 + eslint-config-next 16 + flat config (eslint ke…
Upgrade remaining majors: swiper 14, lucide-react 1, @sanity/icons 5,…
Monorepo Phase 1: import site under apps/site with workspaces (#337)
chore(deps): update dependency eslint-plugin-react-you-might-not-need…
lusu007 commentedon Jul 29, 2026
@icyJoseph ESLint 9 reaches end of life on August 6, 2026, so users relying on
eslint-config-nextwill be left without a supported ESLint version next week (https://eslint.org/version-support/).What is the current plan for resolving the ESLint 10 compatibility issues? Given the approaching EOL date, this should be escalated and prioritized to avoid forcing users to remain on an unsupported ESLint release.
icyJoseph commentedon Jul 29, 2026
Hi, @lusu007 - I'd love to resolve this issue too. It is one of the most reacted ones.
From my notes, we still need jsx-eslint/eslint-plugin-react#3979 to land, right?
We considered kind of applying the workaround at the top, but that's probably not a good idea.
lusu007 commentedon Jul 29, 2026
Thanks for the response @icyJoseph. Yes,
jsx-eslint/eslint-plugin-react#3979seems to be the immediate blocker.However, this also highlights a broader dependency and governance problem: critical tooling used by projects like Next.js can be blocked by a very small number of external maintainers. With ESLint 9 reaching EOL next week, is there anything the Next.js team could do to help move this forward or provide some guidance on a fallback?
It may also be worth considering a more resilient long-term approach, since a similar situation could otherwise arise again with a future breaking ESLint release.
icyJoseph commentedon Jul 29, 2026
@lusu007 IIRC, the workaround from #89764 (comment) should do the trick? You can take ESLint 10, and prevent the version auto detection branch from crashing?
mmilanovic4 commentedon Jul 31, 2026
For JavaScript-only projects the
settings.react.versionpin isn't enough on its own — linting still fails before reaching the react rules:eslint-config-nextparses JS/JSX with Next's bundled@babel/eslint-parser(exposed aseslint-config-next/parser), whose scope manager predates ESLint 10'sScopeManager#addGlobals. TypeScript projects don't hit it becauseeslint-config-next/typescriptswaps in@typescript-eslint/parser.Overriding both works on
eslint@10.8.0/eslint-config-next@16.2.12:Needs
@typescript-eslint/parser@>=8.65.0— the first version declaringeslint: ^10in its peer range. Caveat: this drops Babel parsing for JS files, sonext/babel-specific syntax would no longer parse.To be clear, this is a stopgap and not something anyone should have to keep in their config long-term — I'm posting it mainly so JS projects aren't blocked in the meantime. Hoping
eslint-config-nextcan support ESLint 10 out of the box once jsx-eslint/eslint-plugin-react#3979 lands.KeroZelvin commentedon Aug 2, 2026
Confirming the two-part workaround above in a mixed JavaScript/TypeScript production app:
24.18.1, npm11.16.0,next/eslint-config-next16.2.12, and ESLint10.8.0.settings.react.versionto"19"cleared the initialcontextOrFilename.getFilenamecrash, but JavaScript and MJS files then failed atscopeManager.addGlobals.@typescript-eslint/parser@8.65.0only for**/*.{js,mjs,cjs,jsx}fixed that second failure while leaving the TypeScript parser configuration intact.npm ci, full lint,tsc --noEmit,next build, and the complete CI suite all passed; the same artifact completed its production release checks.The scoped override is important for mixed projects; applying the parser globally can unnecessarily replace the TypeScript config inherited from
eslint-config-next/typescript.One remaining caveat: npm still reports ESLint peer-range warnings from the bundled React, import, and jsx-a11y plugins. They did not block this release, but this is still a stopgap rather than out-of-the-box ESLint 10 support.
cbartens commentedon Aug 11, 2026
Adding a workaround for the reported crash, plus a second blocker that sits behind it.
Workaround for
contextOrFilename.getFilename is not a functioneslint-config-nextsetssettings.react.version = 'detect'(dist/index.js:143).eslint-plugin-reactonly callsdetectReactVersion()when the configured version is literally the string'detect'(lib/util/version.js:113-116), and that is the path that reaches the removedcontext.getFilename()(version.js:31).Pinning an explicit version after the config spread skips that branch entirely:
Confirmed on eslint 10.8.1 + eslint-config-next 16.3.0 + React 19.2.4: the
react/display-name/getFilenameerror no longer occurs.But this is not a full fix — a second blocker follows
With the above applied, linting fails at the next step:
ESLint 10 calls
scopeManager.addGlobals()whenever a config declareslanguageOptions.globalsunder a custom parser.eslint-config-nextdeclares 1174 globals, so this always fires.The parser is Next's own:
addGlobalsappears 0 times innext/dist/compiled/babel/eslint-parser.Why this points at the vendored Babel version
Babel has addressed this directly and ruled out a Babel 7 fix:
Both closed as duplicates pointing to Babel 8.
So
eslint-config-nextappears blocked on Next vendoring Babel 8's@babel/eslint-parser, independent of theeslint-plugin-reactissue in the title.For reference, this is not typescript-eslint:
@typescript-eslint/scope-managerimplementsaddGlobals(dist/ScopeManager.js:106) since ~8.55.0, per typescript-eslint#11762.Scope
In a pnpm monorepo, only the Next app is affected — packages using a plain typescript-eslint flat config (no
globalsblock) lint clean on eslint 10.8.1. So this is isolated toeslint-config-next, not a general ESLint 10 migration problem.nanduxdev commentedon Sep 16, 2026
Got the same error reacr/display-name:
Oops! Something went wrong! :(
ESLint: 10.10.0
TypeError: Error while loading rule 'react/display-name': contextOrFilename.getFilename is not a function
Occurred while linting /Users/nandannagane/Desktop/skill-trail/app/auth/layout.tsx