Next.js Discord

Discord Forum

Is there a way to use the new eslint.config.js with `next lint`?

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Northeast Congo LionOP
I saw that ESLint updated last year with a new config file structures and I tried adding eslint.config.js but next lint didn't pick it up. Is there any way to either get Next.js to use the new config file itself, or run ESLint directly using Next.js's options?

https://eslint.org/docs/latest/use/configure/configuration-files-new

4 Replies

Northeast Congo LionOP
What I've found so far in my research:
* next lint --config eslint.config.js returns an error that suggests it's trying to parse the config file as an older format.
* In the event I do get it to work, next lint is hooked into next build, so if I don't update next lint to use the new config file, next build may build even when the linter fails (https://nextjs.org/docs/pages/api-reference/next-config-js/eslint)

My goal is to load a plugin I've written locally. The docs for ESLint say that I need the new flat eslint.config.js format: https://eslint.org/docs/latest/extend/custom-rule-tutorial#step-8-use-the-plugin-locally Maybe there's another way to do it, or maybe I just bite the bullet and package my plugin so I can use the old format?
Northeast Congo LionOP
next lint --rulesdir works! The three major downsides I've found so far are that:

1. rulesdir is deprecated
2. VS Code has no idea I've set rulesdir
3. Neither does next build, so a linter fail won't stop the build.
Northeast Congo LionOP
Good idea; I should let the team know. I ended up packaging my custom rule in a plugin so I could use it with the old config file format.