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 Doesn't Support ESLint 9 #64409

Closed
Tracked by #12 ...
dylandignan opened this issue Apr 12, 2024 · 110 comments · Fixed by #71218
Closed
Tracked by #12 ...

next-lint Doesn't Support ESLint 9 #64409

dylandignan opened this issue Apr 12, 2024 · 110 comments · Fixed by #71218
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Linting Related to `next lint` or ESLint with Next.js.

Comments

@dylandignan
Copy link

dylandignan commented Apr 12, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/vigilant-pine-6wmz8y

To Reproduce

  1. Add next lint script to package.json per https://nextjs.org/docs/app/building-your-application/configuring/eslint
  2. Add .eslintrc.json to project per https://nextjs.org/docs/app/building-your-application/configuring/eslint
{
  "extends": "next/core-web-vitals"
}
  1. Run lint and get an error
➜  /workspace git:(master) ✗ npm run lint

> lint
> 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.

Current vs. Expected behavior

Expected lint to run successfully, but it failed with errors.

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): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.2.1-canary.0 // Latest available version is detected (14.2.1-canary.0).
  eslint-config-next: 14.1.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

ESLint (eslint-config-next)

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

next dev (local), next build (local), next start (local)

Additional context

It looks like this is coming from https://github.com/vercel/next.js/blob/canary/packages/next/src/cli/next-lint.ts. This needs to be changed to support ESLint 9's flat config https://eslint.org/docs/latest/use/migrate-to-9.0.0#flat-config. The migration guide is at https://eslint.org/docs/latest/use/configure/migration-guide

NEXT-3112

@dylandignan dylandignan added the bug Issue was opened via the bug report template. label Apr 12, 2024
@davidjulakidze
Copy link

davidjulakidze commented Apr 13, 2024

Bumping this for visibility, it does not seem to prevent build but unsure of the impact.

✓ Compiled successfully
   Linting and checking validity of types  .. 
⨯ ESLint: Invalid Options: - Unknown options: useEslintrc, extensions - 'extensions' has been removed.
✓ Linting and checking validity of type
"next": "^14.2.0",
"eslint-config-next": "^14.2.0",
"eslint": "^9.0.0",
{
  "extends": "next/core-web-vitals"
}

@elmarsto
Copy link

Bumping this, it is breaking package update automation at my corp

@GabenGar
Copy link
Contributor

GabenGar commented Apr 16, 2024

Yeah it's breaking change because ESLint 9.0.0 is a major release with a ton of breaking changes. You better hope NextJS didn't adhoc around every single ESLint implementation detail, so the migration to the newest version wouldn't take forever on their end.
For now a "fix" is to update next and eslint-config-next to 14.2.1 which limits the range of required ESLint version to eslint@"^7.23.0 || ^8.0.0" and therefore will crash on install/update instead.

@SukkaW
Copy link
Contributor

SukkaW commented Apr 17, 2024

IMHO, the adoption should be done gradually in the following steps:

  • Migrate eslint-config-next, so it exposes both the legacy eslintrc config and the new flat config.
  • Change Next.js internal ESLint implementation, allows it to accept both the legacy config .eslintrc and the new flat config eslint.config.js.
  • Change next lint so that it can accept eslint.config.js
  • Change create-next-app built-in template to use eslint.config.js
  • Change Next.js example to use eslint.config.js

@BnAmN
Copy link

BnAmN commented Apr 17, 2024

IMHO, the adoption should be done gradually in the following steps:

  • Migrate eslint-config-next, so it exposes both the legacy eslintrc config and the new flat config.

  • Change Next.js internal ESLint implementation, allows it to accept both the legacy config .eslintrc and the new flat config eslint.config.js.

  • Change next lint so that it can accept eslint.config.js

  • Change create-next-app built-in template to use eslint.config.js

  • Change Next.js example to use eslint.config.js

I would like to add that the new flat config file can have multiple names:

  • eslint.config.js
  • eslint.config.mjs
  • eslint.config.cjs

Source: https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file

@JJozef
Copy link

JJozef commented Apr 21, 2024

Same error

image

package.json

"dependencies": {
    "next": "14.2.2"
},
"devDependencies": {
    "eslint": "^9.1.0",
    "eslint-config-next": "14.2.2"
}

.eslintrc.json

{
  "extends": ["next/core-web-vitals", "./node_modules/standard/eslintrc.json"],
  "rules": {
    "space-before-function-paren": "off"
  }
}

deploy

image

@Willem-Jaap
Copy link
Contributor

Not a fix but you can ignore eslint during build like so:

// next.config.js
module.exports = {
  eslint: {
    // Warning: This allows production builds to successfully complete even if
    // your project has ESLint errors.
    ignoreDuringBuilds: true,
  },
}

This way you have manual control over eslint, you can run a custom linting config before build.

@JJozef
Copy link

JJozef commented Apr 21, 2024

Not a fix but you can ignore eslint during build like so:

// next.config.js
module.exports = {
  eslint: {
    // Warning: This allows production builds to successfully complete even if
    // your project has ESLint errors.
    ignoreDuringBuilds: true,
  },
}

This way you have manual control over eslint, you can run a custom linting config before build.

I went back to version "eslint": "^8.41.0" and the error stopped.

@mirasayon
Copy link
Contributor

Same error

Screenshot 2024-04-22 204334

.eslintrc.json :
{ "extends": "next/core-web-vitals" }

I updated all the packages to the latest version but this still does not solve the problem

I don’t want to go back to the old version to fix it. If anyone knows how to solve the problem without going to the old version, please help me 🙏

@GabenGar
Copy link
Contributor

The only package update of relevance is eslint-config-next, which is tied to the version of next, aka wait for one of the newest nextjs versions. Until then you have to stick to old one.

@dalindev
Copy link

dalindev commented Apr 25, 2024

Same issue here, I thought I was crazy. Downgrade to an old version for now... 🤖 😸

devDependencies:
- eslint 9.1.1
+ eslint 8.57.0 (9.1.1 is available)

@sebalaini
Copy link

having the same problem here, I have a custom-shared lint config and my latest PR when linked locally to test it it fails, sebalaini/sebalaini-lints-config#6

@uzbeki
Copy link

uzbeki commented Oct 11, 2024

What is the timeline for Eslint 9 support feature? When is NextJS planning to ship it? Do you guys need help?

@Nickk4
Copy link

Nickk4 commented Oct 11, 2024

My guess is that Vercel is working hard to release Next 15, as the Next.js conference is just around the corner. Perhaps they'll then advice to update to Next 15, which I assume will support eslint 9.

@philsherry
Copy link

@Nickk4 My guess is that Vercel is working hard to release Next 15, as the Next.js conference is just around the corner. Perhaps they'll then advice to update to Next 15, which I assume will support eslint 9.

@samcx mentions Next 15 in this thread ☝️ but to say that it'll be shipping without ESLint 9. Whether that'll be quick enough to turn around now that all of the plugins that were holding things up are good to go, who knows.

@psychobolt
Copy link

psychobolt commented Oct 12, 2024

Adding more context, also need changing is the eslint options from

and I believe flatConfig would also need to be supported here instead of eslintrc

@tiavina-mika
Copy link

It looks like Vercel has underestimated ESLint. I think a dedicated team is needed for the migration as soon as possible. ESLint 8 has been deprecated for a week now, and all projects will start migrating to ESLint v9.

verissimor pushed a commit to Alternativa-Open-Source/aos-website that referenced this issue Oct 13, 2024
@feedthejim
Copy link
Contributor

feedthejim commented Oct 14, 2024

we're on it, gonna land very very soon, thank you all for your patience! And yes, it will be part of Next 15!

The reason why it took us so long to get to is that some of the upstream dependencies were also not up to date, so we were waiting on them.

@alnaranjo
Copy link

So wait until Next 15 is out? 🤦🏻‍♂️ By then eslint 10 might probably drop and the cycle starts all over

@wottpal
Copy link

wottpal commented Oct 14, 2024

Many of us switched over to Biome during that eslint-upgrade-mess. Is enabling third-party linters (or just Biome) via next lint also on the roadmap? See #59347 (and I mean w/o just blindly ignoring lint errors during build what currently seems to be the only option).

@feedthejim
Copy link
Contributor

So wait until Next 15 is out? 🤦🏻‍♂️ By then eslint 10 might probably drop and the cycle starts all over

I wouldn't be so pessimistic!

@feedthejim
Copy link
Contributor

Many of us switched over to Biome during that eslint-upgrade-mess. Is enabling third-party linters (or just Biome) via next lint also on the roadmap? See #59347 (and I mean w/o just blindly ignoring lint errors during build what currently seems to be the only option).

It is, but no ETA just yet.

@torokati44
Copy link

@feedthejim

we're on it, gonna land very very soon

I don't know about others, but to me, in this context, a simple "soon" is a matter of weeks, a "very soon" is a few days, and "very very soon" is about a couple hours... 😶

@feedthejim
Copy link
Contributor

We're planning on releasing an RC2 today and 15 in the following week, assuming there's no blockers.

@Kamahl19
Copy link

@feedthejim Wouldnt backporting this to v14 be better? Eslint 8 is already EOL while next v14 is still active dev.

@lorand-horvath
Copy link

lorand-horvath commented Oct 15, 2024

@Kamahl19 I had proposed a backport of eslint-plugin-react-hooks@5 to next v14 in #71291
but it's supposedly a breaking change, which I don't think it is. It supports eslint@9, yes, but also eslint@8, all the way back to eslint@3 even!

@leerob
Copy link
Member

leerob commented Oct 15, 2024

Update: ESLint 9 is now supported as of the Next.js 15 RC 2. v15 stable release coming soon 🙏

https://x.com/nextjs/status/1846276572812124565

@alnaranjo
Copy link

I wouldn't be so pessimistic!

It's not pessimism. But I don't see a good reason to upgrade to a version filled with experimental changes just for the sake of using eslint 9, at this rate I'm considering dropping next altogether.

@ZebraFlesh
Copy link

It would be nice to get the eslint v9 support back ported to v14. As it stands now, you can't upgrade to eslint@9 due to this issue, but having tried converting to flat configs in just v8, that gets really ugly really fast. Being able to use eslint@9 in next v14 would create a much smoother upgrade path to v15.

@SalahAdDin
Copy link

It would be nice to get the eslint v9 support back ported to v14. As it stands now, you can't upgrade to eslint@9 due to this issue, but having tried converting to flat configs in just v8, that gets really ugly really fast. Being able to use eslint@9 in next v14 would create a much smoother upgrade path to v15.

better to move to OxLint.

@KrustyC
Copy link

KrustyC commented Oct 15, 2024

Isn't Next 15 based on React 19? If so, how could it be released as stable without a stable release of React 19 first?

@Lordfirespeed
Copy link

Lordfirespeed commented Oct 15, 2024

Isn't Next 15 based on React 19?

Support for react 19, not dependent on.

@leerob
Copy link
Member

leerob commented Oct 15, 2024

Isn't Next 15 based on React 19? If so, how could it be released as stable without a stable release of React 19 first?

The release mentioned above is our second RC (Release Candidate) – not the final stable release. We're close to a stable release for v15 now (so if you try it out, please let us know).

Upgrading to Next.js v15 does not require React 19, but it does support it if desired. If you are using the Pages Router, you can continue to use React 18. If you are using the App Router, the React version is vendored using the canary channel for frameworks (which is v19+).

@sacru2red
Copy link

sacru2red commented Oct 16, 2024

Please do not write comments unrelated to the issue.

This involves sending spam messages to people who have subscribed to the issue.

@vercel vercel locked as resolved and limited conversation to collaborators Oct 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. Linting Related to `next lint` or ESLint with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.