gpt4 book ai didi

javascript - Eslint 报告依赖配置的 eslintrc 配置问题

转载 作者:行者123 更新时间:2023-11-29 21:00:29 26 4
gpt4 key购买 nike

我在运行以下 lint 命令时收到弃用警告

eslint src/js/**/*.js src/js/**/*.jsx webpack.config.js --quiet

警告:

DeprecationWarning: [eslint] The 'ecmaFeatures' config file property is deprecated, and has no effect. (found in /Users/me/Documents/my-project/node_modules/eslint-config-airbnb/rules/react.js

这似乎是在提示 react-a11y.jsreact.js 下的 eslint-config-airbnb 中列出的文件>。这些文件确实包含顶级配置

ecmaFeatures: {
jsx: true
}

这似乎是不正确的:github issue , docs .但是,似乎 ( docs ) node_modules 应该被 eslint 忽略,无论如何为了明确起见,我已经将以下内容添加到我的 .eslintignore/p>

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)

最佳答案

更新 babel-preset-react 和 eslint-plugin-react,解决了我的问题。如果这引发了新的错误,您将被迫更新几乎所有与 eslint 相关的内容。

关于javascript - Eslint 报告依赖配置的 eslintrc 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46719233/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com