【问题标题】:ESLint 'module' is not defined. (no-undef) into PhpStormESLint 'module' 未定义。 (no-undef) 进入 PhpStorm
【发布时间】:2021-02-28 21:17:58
【问题描述】:

在 PhpStorm 中,我的 .eslintrc 文件中有此错误:

ESLint 'module' is not defined. (no-undef) into PHPStorm 

我已经尝试使用this StackOverflow question 修复它。但结果是一样的。再次出现 ESLint 错误。

这是我的 .eslintrc 文件:

/* eslint-env node */
{
  "root": false,
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint"
  ],
  "env": {
    "node": true,
    "browser": true,
    "commonjs": true,
    "es6": true,
    "amd": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:vue/base",
    "plugin:vue/essential",
    "plugin:vue/vue3-recommended",
    "plugin:vue/vue3-essential",
    "@vue/typescript/recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": 2020
  },
  "rules": {
    "no-console": "error",
    "no-debugger": "error",
    "no-unused-components": "off",
    "no-unused-vars": "off",
    "no-empty-function": "off",
    "prefer-const": "off",
    "@typescript-eslint/no-unused-vars": "off"
  },
  "overrides": [
    {
      "files": [
        "**/__tests__/*.{j,t}s?(x)",
        "**/tests/unit/**/*.spec.{j,t}s?(x)"
      ],
      "env": {
        "mocha": true
      }
    }
  ]
}

也许是 PhpStorm 的问题?

如何解决这个错误 ESLint ?

【问题讨论】:

  • 在使用您的配置时无法重现。它是你项目中唯一的 eslint 配置文件吗?您能否分享报告问题的代码 sn-p 以及错误的屏幕截图?

标签: phpstorm eslint eslintrc


【解决方案1】:

删除“es6”:“真”, 就像:

"env": {
  "node": true,
  "browser": true,
  "commonjs": true,
  "amd": true
}

【讨论】:

    猜你喜欢
    • 2018-07-13
    • 2017-10-29
    • 2023-03-12
    • 1970-01-01
    • 2020-06-29
    • 2021-10-16
    • 2018-06-09
    • 2018-10-02
    相关资源
    最近更新 更多