Home > Software design >  Incorrectly tigger eslint (no-undef) in nodejs globals
Incorrectly tigger eslint (no-undef) in nodejs globals

Time:08-11

I providing two of my code sample that throws this error.

enter image description here

And enter image description here

My eslintrc file is

{
    "env": {
        "browser": true,
        "commonjs": true,
        "es2021": true
    },
    "extends": ["google"],
    "parserOptions": {
        "sourceType": "module"
    },
    "rules": {
        "linebreak-style": "off",
        "quotes": ["error", "double"],
        "indent": "off",
        "max-len": "off",
        "object-curly-spacing": "off",
        "curly": "off",
        "comma-dangle": "off",
        "camelcase": "off",
        "new-cap": "off",
        "no-undef": "error",
        "eqeqeq": "error"
    }
}

Thank you for your time!

CodePudding user response:

Just put "node": true in the env section

{
    "env": {
        "node": true,
        "browser": true,
        "commonjs": true,
        "es2021": true
    },
...
}
  • Related