2

它是 package.json 中的依赖项

"babel-eslint": "7.1.1",
"eslint": "3.17.1",
"eslint-config-airbnb": "14.1.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-react": "6.10.0",

当我npm run lint在一个Linux 3.13.0-107-generic

/home/ubuntu/webview/analytics2/node_modules/eslint-config-airbnb-base/rules/best-practices.js:
    Configuration for rule "no-unused-expressions" is invalid:
    Value "data["0"].allowTaggedTemplates" has additional properties.

Referenced from: /home/ubuntu/webview/analytics2/node_modules/eslint-config-airbnb-base/index.js
Referenced from: airbnb
Referenced from: /home/ubuntu/webview/analytics2/.eslintrc
Error: /home/ubuntu/webview/analytics2/node_modules/eslint-config-airbnb-base/rules/best-practices.js:
    Configuration for rule "no-unused-expressions" is invalid:
    Value "data["0"].allowTaggedTemplates" has additional properties.

Referenced from: /home/ubuntu/webview/analytics2/node_modules/eslint-config-airbnb-base/index.js
Referenced from: airbnb
Referenced from: /home/ubuntu/webview/analytics2/.eslintrc
    at validateRuleOptions (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-validator.js:109:15)
    at Object.keys.forEach.id (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-validator.js:156:13)
    at Array.forEach (native)
    at Object.validate (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-validator.js:155:35)
    at load (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-file.js:529:19)
    at configExtends.reduceRight.e (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-file.js:391:36)
    at Array.reduceRight (native)
    at applyExtends (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-file.js:362:28)
    at load (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-file.js:536:22)
    at configExtends.reduceRight.e (/home/ubuntu/webview/analytics2/node_modules/eslint/lib/config/config-file.js:391:36)

我想错误是由于Configuration for rule "no-unused-expressions" is invalid:上面的堆栈跟踪所示。

它的内容是.eslintrc

{
  "extends": "airbnb",
  "env": {
    "browser": true,
    "mocha": true,
    "node": true
  },
  "globals": {
    "expect": true,
    "URLSearchParams": true
  },
  "parser": "babel-eslint",
  "rules": {
    "max-len": [2, 80, 4, {"ignoreComments": true}],
    "valid-jsdoc": 2,
    "react/jsx-filename-extension": "off",
    "import/no-extraneous-dependencies": 0,
    "import/no-unresolved": 0,
    "import/extensions": 0
  },
  "plugins": [
    "react"
  ]
}

但是我无法在我的 OSX MBP 上重现此错误。

我该如何解决它的问题?

4

3 回答 3

9

我今天刚遇到同样的问题。我的建议是运行 npm outdated 并升级 eslint 相关包。

对我来说,将 eslint 升级到 3.18.0 并将 eslint-plugin-react 升级到 6.10.3 解决了这个问题。

于 2017-03-27T18:23:44.673 回答
1

我今天遇到了同样的问题。我更新了所有需要的软件包。但这没有帮助。然后我在 Node.js 解释器(版本)之间来回切换,它开始工作。

于 2017-03-27T21:53:11.563 回答
0

更新 react-scripts 模块对我有帮助。

于 2017-11-30T13:38:55.043 回答