4

我有以下内容.eslintrc,每当我使用aribnb和/或airplus扩展名对项目进行 lint 处理时,都会收到以下错误:

// .eslintrc
{
  "parser": "babel-eslint",
  "rules": {
    "id-length": 0,
    "indent": [
      2,
      2,
      {
        "SwitchCase": 1
      }
    ],
    "quotes": [
      2,
      "single"
    ],
    "linebreak-style": [
      2,
      "unix"
    ],
    "semi": [
      2,
      "always"
    ],
    "no-duplicate-case": 1,
    "no-else-return": 0,
    "react/sort-comp": [
      1,
      {}
    ],
    "no-undef": 1,
    "no-unused-vars": [
      1,
      {
        "args": "none",
        "argsIgnorePattern": "store|action|next"
      }
    ],
    "object-curly-spacing": [
      1,
      "always"
    ],
    "react/no-did-mount-set-state": [
      1
    ]
  },
  "env": {
    "es6": true,
    "node": true,
    "browser": true
  },
  "globals": {
    "_": true,
    "__ENV__": true
  },
  "extends": [
    "airbnb",
    "airplus"
  ],
  "ecmaFeatures": {
    "jsx": true,
    "experimentalObjectRestSpread": true
  },
  "plugins": [
    "react"
  ]
}

...和错误:

> esw webpack src tools

.../node_modules/eslint-config-airbnb/rules/react.js:
    Configuration for rule "react/display-name" is invalid:
    Value "data["0"].acceptTranspilerName" has additional properties.

Referenced from: airbnb
Referenced from: airplus
Referenced from: /.../.eslintrc
Error: /.../node_modules/eslint-config-airbnb/rules/react.js:
    Configuration for rule "react/display-name" is invalid:
    Value "data["0"].acceptTranspilerName" has additional properties.

Referenced from: airbnb
Referenced from: airplus
Referenced from: .../.eslintrc
    at validateRuleOptions (.../node_modules/eslint/lib/config/config-validator.js:116:15)
    at .../node_modules/eslint/lib/config/config-validator.js:163:13
    ...
4

3 回答 3

7
npm install
npm info "eslint-config-airbnb-base@latest" peerDependencies
npm install -g install-peerdeps
install-peerdeps --dev eslint-config-airbnb-base

将 "extends": "airbnb-base" 添加到 .eslintrc 文件。最后,SUCCESS eslint-config-airbnb-base 及其 peerDeps 安装成功。

在这里发布快照

于 2017-11-08T11:20:36.083 回答
1

就我而言,.eslintrc.js父目录中有一个配置文件,因此 IntelijIdea 正在使用该配置文件。我删除了它,问题就解决了。

于 2021-07-11T12:25:08.797 回答
0

尝试添加"react/display-name": [0, { "ignoreTranspilerName": true }],

于 2016-07-11T10:49:57.210 回答