简体   繁体   English

在 nodejs 全局变量中错误地触发 eslint (no-undef)

[英]Incorrectly tigger eslint (no-undef) in nodejs globals

I providing two of my code sample that throws this error.我提供了两个引发此错误的代码示例。

在此处输入图像描述

And在此处输入图像描述

My eslintrc file is我的 eslintrc 文件是

{
    "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!感谢您的时间!

Just put "node": true in the env section只需将"node": true放在env部分

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM