它是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上重现此错误。
如何解决问题?
答案 0 :(得分:8)
我今天刚遇到同样的问题。我的建议是运行npm过时并升级与eslint相关的包。
对我来说,它是将eslint升级到3.18.0并且eslint-plugin-react to 6.10.3解决了这个问题。
答案 1 :(得分:1)
我今天遇到了同样的问题。我做了所有需要的包的更新。但它没有任何帮助。然后我在Node.js解释器(版本)之间切换回来,它开始工作。
答案 2 :(得分:0)
更新react-scripts模块帮助了我。