My package.json
{
...
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js"
},
"dependencies": {
...
},
"engines": {
"node": "18.x"
},
"devDependencies": {
"@eslint/js": "^9.3.0",
"eslint": "^9.9.1",
"globals": "^15.3.0"
},
"eslintConfig": {}
}
Then i have on the root folder a file .eslintrc.cjs
module.exports =
{
"env" :
{
"browser" : true,
"es2021" : true
},
"extends" : "eslint:recommended",
"globals" :
{
"global" : "writable",
"isObject" : "readonly",
...
},
"overrides" :
[
{
"env" :
{
"node" : true
},
"files" : [ ".eslintrc.{js,cjs}" ],
"parserOptions" :
{
"sourceType": "script"
}
}
],
"parserOptions" :
{
"ecmaVersion" : "latest",
"sourceType" : "module"
},
"rules" :
{
}
}
and eslint.config.js
import globals from "globals";
import pluginJs from "@eslint/js";
export default [
{languageOptions: { globals: globals.browser }},
pluginJs.configs.recommended,
];
I have isObject
on another .js file as
globalThis.isObject = function(value)
{
if (typeof value === 'object' && value !== null && !Array.isArray(value))
return true
return false
}
I dont know whats happening, looks like its ignoring the eslintrc.cjs
file, because everywhere i have isObject(...)
eslint is throwing 'isObject' is not defined.
, this also happens with any other variables i define on the "globals"
array.
My nodejs project is working correctly, just the eslint errors.
Similar question for VS 17/19 but the option on the accept answer no longer exists on VS22.