-
Notifications
You must be signed in to change notification settings - Fork 27k
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
New ESLint "flat" configuration file does not work with next/core-web-vitals
#64114
Comments
Hi, IMHO we need to wait until all the deps of The deps: "dependencies": {
"@next/eslint-plugin-next": "14.2.0-canary.60",
"@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.5.0 || 5.0.0-canary-7118f5dd7-20230705"
}, |
…changes (#64141) This is a hotfix since it breaks `next lint`, I'll start to implement eslint v9 for canary. x-ref: #64114 x-ref: [eslint v9 release](https://github.com/eslint/eslint/releases/tag/v9.0.0) Fixes #64136 --------- Co-authored-by: Zack Tanner <[email protected]>
Until the fixed version of ESLint needs to downgrade to v8.57.0 Remove the ESLint v9 Install the v8.57.0 |
Thank you ! |
Support for the "new" config format shouldn't be tied to version 9 support. 8.57.0 can also use the flat config format and my company would like to migrate our configurations to the new format in preparation for moving to eslint 9. This is the only plugin that we use that doesn't work with the newer format. |
ESLint published a new package to help with dependency plugins that are not yet converted to the Flat config: Could this help with the migration of the |
@daanvosdewael yes this helps, I was able to use ESLint 9 with core-web-vitals on my project, here is a guide on how to implement it Also for a TLDR; check my comment here |
@Adesh-Pandey try this see if it works. i setup using tseslint.config() via module export it worked
import { FlatCompat } from "@eslint/eslintrc";
import { fixupConfigRules } from "@eslint/compat";
const flatCompat = new FlatCompat();
= [
...fixupConfigRules(
flatCompat.extends('next/core-web-vitals')
),
] |
@kevinlaw91 your resolution failed in Next.js 15: kaiyuanshe/kaiyuanshe.github.io#345 (comment) |
The following worked for me: ...fixupConfigRules(
flatCompat.extends("plugin:@next/next/core-web-vitals")
), |
[fix] Activity Forum entry [fix] ESLint 9 compatibility of Next.js 15 (vercel/next.js#64114 (comment))
[fix] Activity Forum entry [fix] ESLint 9 compatibility of Next.js 15 (vercel/next.js#64114 (comment))
Could you try this? Before Node v20.11.0: import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { FlatCompat } from '@eslint/eslintrc'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
})
const eslintConfig = [
...compat.extends('next/core-web-vitals', 'next/typescript'),
]
export default eslintConfig After Node v20.11.0: import { FlatCompat } from '@eslint/eslintrc'
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
})
const eslintConfig = [
...compat.extends('next/core-web-vitals', 'next/typescript'),
]
export default eslintConfig |
what should be the syntax for a mono-repo project using several directories in config? |
@devjiwonchoi this worked for me! |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/pensive-star-go8s7s
To Reproduce
npm run dev
and observe the error showing that...compat.extends("next/core-web-vitals")
does not work.Current vs. Expected behavior
Current behavior: It is impossible to use the new ESLint "flat config" in a Next.js project (due to
next/core-web-vitals
).Expected behavior: It should work.
Which area(s) are affected? (Select all that apply)
ESLint (eslint-config-next)
Additional context
In case it is not clear, I have imported
...compat.extends("next/core-web-vitals")
inpage.tsx
only for the purpose of showing that it does not work. The file with the actual ESLint configuration iseslint.config.js
.I have followed the official ESLint Configuration Migration Guide, where it is mentioned that
FlatCompat
should be used for an npm package which is in eslintrc format. In this case, I believe that the problem is thatnext/core-web-vitals
is not an npm package. I also tried...compat.extends("eslint-config-next")
, but that does not work either.For extra context, ESLint is moving from
.eslintrc.json
toeslint.config.js
, and all other shareable ESLint configs I am using (e.g.,typescript-eslint
,eslint-config-prettier
) already support this, even without needing to useFlatCompat
.NEXT-3293
The text was updated successfully, but these errors were encountered: