I have Eslint working in a TypeScript Next.js project, but I want to switch to the new "flat config" approach that Eslint offers.
I created /eslint.config.js
to look something like this: https://stackoverflow.com/a/74819187/470749
How can I migrate the extends: ['next/core-web-vitals'],
to the flat config, which doesn't support extends
?
Other than missing 'next/core-web-vitals', if I run eslint pages/*
, I see the errors that I expect.
But my VSCode no longer shows errors.
I see "eslint.experimental.useFlatConfig": true,
in my VSC settings, and I've restarted VSC, but it still doesn't work.
How can I get the flat config to run automatically in VSC?
I had already seen in the terminal TypeError: Could not find the rule "canonical/filename-match-exported".
, but I'd ignored it.
Seeing it again in ESLint Show Output Channel made me wonder whether VSC was aborting there and not bothering to run any more rules.
And that seems to be the case.
Once I removed /* eslint-disable canonical/filename-match-exported */
from the files that had those comments, VSC started honoring my ESLint rules (even in tsx files).
It seems like a bug (or questionable design choice) that the VSC ESLint extension would fail in a nearly silent way if it can't find a rule definition.