簡體   English   中英

在 nodejs 全局變量中錯誤地觸發 eslint (no-undef)

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

我提供了兩個引發此錯誤的代碼示例。

在此處輸入圖像描述

在此處輸入圖像描述

我的 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"
    }
}

感謝您的時間!

只需將"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