ESLint 9 ignores or breaks the Next.js lint config
ESLint 9 is not working properly with Next 15Short answer
ESLint 9 uses the flat config format by default and looks for eslint.config.js or .mjs, not an old .eslintrc file. For Next.js either write eslint.config.mjs, using eslint-config-next directly on Next.js 16 or FlatCompat on 15, and run the ESLint CLI. Next.js 16 also removes the next lint command.
Fix it fast
1Find out which cause you have
See which config files exist and which ESLint and Next.js versions are installed.
ls -a | grep -i eslint npx eslint --version npm ls eslint eslint-config-next2Match what you see, then jump to its fix
- 1
Only .eslintrc.json or .eslintrc.js exists, and ESLint does not apply the Next.js rules.The project still uses an .eslintrc fileFix - 2
You use extends: ['next/core-web-vitals'] and ESLint 9 rejects or ignores it.Next.js 15 with a shareable config in the old formatFix - 3
next lint no longer works after upgrading, or the eslint key in next.config is flagged.You still run next lint on Next.js 16Fix - 4
A long .eslintrc.json with many plugins and overrides.An old eslintrc file is kept and you want to convert itFix
- 1
What does the error look like?
ESLint 9 is not working properly with Next 15
Cause 1 of 4
The project still uses an .eslintrc file
1Check
Flat config has been the default format since ESLint v9.0.0, so ESLint looks for eslint.config.js and its variants.
ls -a | grep -iE "eslintrc|eslint.config"2Fix
Create eslint.config.mjs. On Next.js 16 use the flat config that eslint-config-next exports.
// eslint.config.mjs (eslint-config-next 16)
import { defineConfig, globalIgnores } from 'eslint/config'
import nextVitals from 'eslint-config-next/core-web-vitals'
export default defineConfig([
...nextVitals,
globalIgnores(['.next/**', 'out/**', 'build/**', 'next-env.d.ts']),
])3Verify
Run ESLint on the project and see Next.js rules applied.
npx eslint .Confirmed by nextjs.org
Cause 2 of 4
Next.js 15 with a shareable config in the old format
1Check
Shareable configs written for the old format must be translated. The ESLint migration guide uses FlatCompat from @eslint/eslintrc for that, and the Next.js 15 docs use it for the next configs.
npm ls @eslint/eslintrc2Fix
Install @eslint/eslintrc and wrap the Next.js config with FlatCompat in eslint.config.mjs.
// eslint.config.mjs (Next.js 15)
import { FlatCompat } from '@eslint/eslintrc'
const compat = new FlatCompat({ baseDirectory: import.meta.dirname })
export default [
...compat.config({
extends: ['next/core-web-vitals', 'next/typescript'],
}),
]3Verify
Lint a file that breaks a rule on purpose, for example an img element, and see the warning.
npx eslint appConfirmed by nextjs.org
Cause 3 of 4
You still run next lint on Next.js 16
1Check
Starting with Next.js 16, next lint is removed, and the eslint option in the Next config is no longer needed.
grep -n "next lint\|eslint" package.json next.config.*2Fix
Call ESLint directly from your scripts and delete the eslint option from the Next config.
// package.json
"scripts": {
"lint": "eslint ."
}3Verify
Run the script.
npm run lintConfirmed by nextjs.org
Cause 4 of 4
An old eslintrc file is kept and you want to convert it
1Check
ESLint ships a migrator that turns an eslintrc file into a flat config as a starting point. Its output may need manual edits.
ls .eslintrc*2Fix
Run the migrator, then review the generated file and remove what Next.js already provides.
npx @eslint/migrate-config .eslintrc.json3Verify
Run ESLint and compare its results with the old setup.
npx eslint .Confirmed by eslint.org
How do I stop it coming back?
- Upgrade ESLint and eslint-config-next together, not one at a time.
- Keep one config file only, so it is clear which one ESLint reads.
- Run the lint script in CI, because a config that ESLint cannot read can fail quietly in an editor.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
next build stops because of ESLint errors, and next lint is gone
next build fails because ESLint reports errors
In Next.js 15, next build runs ESLint when it is installed and fails on errors.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
Firebase Auth says the API key is not valid
Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.)
The apiKey your app sends is either empty, wrong, or blocked.
4 causes, each with a fix