运行以下lint命令时,我收到了弃用警告
eslint src/js/**/*.js src/js/**/*.jsx webpack.config.js --quiet
警告:
DeprecationWarning:[eslint]不推荐使用'ecmaFeatures'配置文件属性,该属性无效。 (见/Users/me/Documents/my-project/node_modules/eslint-config-airbnb/rules/react.js
这似乎是抱怨在eslint-config-airbnb
和react-a11y.js
下的react.js
中列出的文件。这些文件确实包括顶级配置
ecmaFeatures: {
jsx: true
}
似乎不正确:github issue,docs。但是,似乎(docs)node_modules
应该被eslint忽略,而且无论如何只是为了明确,我已将以下内容添加到我的 .eslintignore
node_modules/**/*.*
node_modules
为什么我收到node_modules中的问题警告?我唯一能想到的是,忽略列表不包含eslint本身的配置,但这似乎相当遥远,它可能会警告我node_modules中每个eslintrc文件的每个过时或错误配置?
如果相关,我的 .eslintrc.json
{
"env": {
"es6": true,
"browser": true,
"node": true,
"jest": true
},
"extends": ["airbnb", "prettier", "prettier/react"],
"parserOptions": {
"ecmaVersion": 2016,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"plugins": ["prettier", "react"],
"parser": "babel-eslint",
"rules": {
"no-param-reassign": 0
}
}
我该如何解决这个问题?
升级到eslint-config-airbnb@latest
(其中it looks the top-level ecmaFeatures
problem has been resolved)会导致更严重的错误:
/Users/me/Documents/my-project/node_modules/eslint-config-airbnb/rules/react.js: Configuration for rule "react/jsx-boolean-value" is invalid: Value "never,[object Object]" should NOT have more than 1 items. Referenced from: /Users/me/Documents/my-project/node_modules/eslint-config-airbnb/index.js Referenced from: /Users/me/Documents/my-project/.eslintrc.json Error: /Users/me/Documents/my-project/node_modules/eslint-config-airbnb/rules/react.js: Configuration for rule "react/jsx-boolean-value" is invalid: Value "never,[object Object]" should NOT have more than 1 items. Referenced from: /Users/me/Documents/my-project/node_modules/eslint-config-airbnb/index.js Referenced from: /Users/me/Documents/my-project/.eslintrc.json at validateRuleOptions (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-validator.js:113:15) at Object.keys.forEach.id (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-validator.js:153:9) at Array.forEach (native) at validateRules (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-validator.js:152:30) at Object.validate (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-validator.js:230:5) at loadFromDisk (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-file.js:549:19) at load (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-file.js:592:20) at configExtends.reduceRight (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-file.js:421:36) at Array.reduceRight (native) at applyExtends (/Users/me/Documents/my-project/node_modules/eslint/lib/config/config-file.js:403:28)
答案 0 :(得分:2)
更新babel-preset-react和eslint-plugin-react,这解决了我的问题。 如果这会引发新的错误,您将被迫更新与eslint相关的几乎所有内容。