Description
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/pensive-star-go8s7s
To Reproduce
- Run
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")
in page.tsx
only for the purpose of showing that it does not work. The file with the actual ESLint configuration is eslint.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 that next/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
to eslint.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 use FlatCompat
.