Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next lint fails when using ESLint v8 flat config #75298

Open
allybee opened this issue Jan 24, 2025 · 0 comments
Open

next lint fails when using ESLint v8 flat config #75298

allybee opened this issue Jan 24, 2025 · 0 comments
Labels
Linting Related to `next lint` or ESLint with Next.js.

Comments

@allybee
Copy link

allybee commented Jan 24, 2025

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/xenodochial-voice-lfgj88?workspaceId=ws_XCEs1GT1FEw6tFStZG4Cnd

To Reproduce

  1. Open the terminal
  2. Run linting using Next.js and observe that it fails to run, indicating there are invalid ESLint config options
$ pnpm exec next lint

Invalid Options:
- Unknown options: useEslintrc, extensions, resolvePluginsRelativeTo, rulePaths, ignorePath, reportUnusedDisableDirectives
- 'extensions' has been removed.
- 'resolvePluginsRelativeTo' has been removed.
- 'ignorePath' has been removed.
- 'rulePaths' has been removed. Please define your rules using plugins.
- 'reportUnusedDisableDirectives' has been removed. Please use the 'overrideConfig.linterOptions.reportUnusedDisableDirectives' option instead.
  1. Run linting using ESLint that it runs successfully
$ pnpm exec eslint .

Current vs. Expected behavior

Current behavior

next lint does not work with an ESLint flat config (e.g., eslint.config.js) on eslint@^8.21.0.
It does work successfully with eslint@^9.

Expected behavior

It is expected that next lint runs successfully with a valid ESLint flat config on eslint@^8 and eslint@^9.

ESLint introduced the flat config in v8.21.0 and it is the default format in v9.x.
Although ESLint v8.x has reached end-of-life, some widely used shared configs have not yet migrated to v9.x (e.g., eslint-config-airbnb). Flat config compatibility with next lint and ESLint v8.x allows codebases tied to ESLint v8.x to avoid or move away from the deprecated eslintrc format.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4242
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.2.0-canary.25 // Latest available version is detected (15.2.0-canary.25).
  eslint: 8.57.1
  eslint-config-next: 15.1.6
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Linting

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

I believe the culprit is the following ESLint v9.x version check:

https://github.com/vercel/next.js/blob/v15.2.0-canary.25/packages/next/src/lib/eslint/runLintCheck.ts#L178-L193

Patching it to support ESLint versions greater than v8.21.0 worked in my case:

-        if (_semver.default.gte(eslintVersion, '9.0.0') && useFlatConfig) {
+        if (_semver.default.gte(eslintVersion, '8.21.0') && useFlatConfig) {
             for (const option of [
                 'useEslintrc',
                 'extensions',
@github-actions github-actions bot added the Linting Related to `next lint` or ESLint with Next.js. label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linting Related to `next lint` or ESLint with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant