0

我有一个.eslintrc.json像这样的 eslint 配置文件(可能是 .eslintrc):

{  
  "env": {
    "browser": true,
    "es6": true
  },
  "extends": [
      "eslint:recommended",
      "plugin:react/recommended",
      "plugin:@typescript-eslint/eslint-recommended",
      "airbnb-typescript-prettier"
  ],
  "plugins": [
    "@typescript-eslint"
  ],
  "globals": {
      "Atomics": "readonly",
      "SharedArrayBuffer": "readonly"
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
      "ecmaFeatures": {
          "jsx": true
      },
      "ecmaVersion": 2018,
      "sourceType": "module"
  },
  "overrides": [
    {
        "files": ["*.js", "*.jsx"],
        "processor": "babel-eslint"
    }
  ],
  "rules": {
    "react/prop-types": 0,
    "semi": ["error", "never"]
  }
}

我得到了一个持续的错误

Error: ESLint configuration of processor in '.eslintrc.json#overrides[0]' is invalid: 'babel-eslint' was not found
4

1 回答 1

0

虽然官方eslint 站点建议使用此配置,但您需要使用parser属性来overrides代替,processor如下所示:

...
  "overrides": [
  {
    "files": ["*.js", "*.jsx"],
    "parser": "babel-eslint"
  }
],
...

有了这个改变,一切都很好。

于 2020-06-21T20:37:30.297 回答