ESLint introduced a new configuration system in 2022, named "flat config".
Documentation for the new "flat config". | Documentation for the old configuration system.
As you can see in the "flat config" documentation, the eslint.config.js file does not have an "env" key/property where you can specify the environment for the linter ("node" or "browser").
This is easy in the "old" configuration system (using .eslintrc.js or .eslintrc.json).
Without specifying the env property as node, I would have to manually add all the node global variables as follows.
eslint.config.js :
module.exports [
{
files: ["**/*.js"],
languageOptions: {
globals: {
console: "writable",
__dirname: "readable",
__filename: "readable",
process: "readable",
< … more global variables here … >
}
},
rules: {
// your rules here
}
}
]
Surely I am missing something?
Their blog of all places has more details on "env". This took a lot of time to find....
https://eslint.org/blog/2022/08/new-config-system-part-2/#reimagined-language-options
https://eslint.org/blog/2022/08/new-config-system-part-2/#goodbye-environments%2C-hello-globals
Then they show a rough example:
I imagine we just need:
And this works for me (I also added
parser: babelParserinsidelanguageOptionsESLint is jquerying things up if you ask me, not providing a clear migration path and preplanning their own demise if they launch ESLint 9.0 without eslintrc support and a "not-my-problem" approach to documenting how to migrate from
"env": { "node": true }. They didn't even document the plugins formatting which is "key-value" mapping strings to plugin objects. e.g.{ "html": yourHtmlPluginImport }