简体   繁体   English

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

[英]Eslint reporting eslintrc configuration problems for dependency configs

I am getting a deprecation warning when running the following lint command运行以下 lint 命令时收到弃用警告

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

Warning:警告:

DeprecationWarning: [eslint] The 'ecmaFeatures' config file property is deprecated, and has no effect. DeprecationWarning: [eslint] 'ecmaFeatures' 配置文件属性已被弃用,并且无效。 (found in /Users/me/Documents/my-project/node_modules/eslint-config-airbnb/rules/react.js (在 /Users/me/Documents/my-project/node_modules/eslint-config-airbnb/rules/react.js 中找到

This seems like it is complaining about a file listed within the eslint-config-airbnb under react-a11y.js and react.js .这似乎是在抱怨react-a11y.jsreact.js下的eslint-config-airbnb列出的文件。 Those files do indeed include the top level configuration这些文件确实包含顶级配置

ecmaFeatures: {
  jsx: true
}

which appears to be incorrect: github issue , docs .这似乎是不正确的: github issuedocs However, it seems ( docs ) that node_modules should be ignored by eslint, and anyway just to be explicit, I've added the following to my .eslintignore然而,似乎( 文档),其node_modules应该由eslint被忽略了,反正只是要明确,我已经添加了下面我.eslintignore

node_modules/**/*.*
node_modules 

Why am I getting a warning for an issue located within node_modules?为什么我会收到关于 node_modules 中问题的警告? The only thing I can think is that the ignore list doesn't include configurations for eslint itself, but that seems pretty far fetched that it would potentially warning me about every out-of-date or misconfiguration of each eslintrc file in node_modules?我唯一能想到的是,忽略列表不包括 eslint 本身的配置,但这似乎很牵强,它可能会警告我 node_modules 中每个 eslintrc 文件的每个过时或错误配置?

In case it is relevant, my .eslintrc.json如果相关,我的.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
  }
}

How can I resolve this?我该如何解决这个问题?

Edit:编辑:

Upgrading to eslint-config-airbnb@latest (where it looks the top-level ecmaFeatures problem has been resolved ) causes what look like more severe errors:升级到eslint-config-airbnb@latest看起来顶级ecmaFeatures问题已经解决)会导致看起来更严重的错误:

 /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)

Update babel-preset-react and eslint-plugin-react, that solved the problem for me.更新 babel-preset-react 和 eslint-plugin-react,为我解决了问题。 If that raise new errors, you will be forced to update almost everything related to eslint.如果这引发了新的错误,您将被迫更新几乎所有与 eslint 相关的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 eslintrc 中的 ESLint 配置无效:- 意外的顶级属性“import/no-extraneous-dependencies” - ESLint configuration in .eslintrc is invalid: - Unexpected top-level property “import/no-extraneous-dependencies” 错误:.eslintrc.js 中的 ESLint 配置无效:-意外的顶级属性“文件” - Error: ESLint configuration in .eslintrc.js is invalid: - Unexpected top-level property "files" Eslint: --fix 未根据 .eslintrc 规则解决警告 - Eslint: --fix not resolving warnings according to .eslintrc rules 如何将jshint和jscs的配置转换为eslint? - How to convert configs from jshint and jscs to eslint? 带有 Babel 的 ESLint:在 .eslintrc 中未找到声明的 plugin-proposal-class-properties - ESLint with Babel: plugin-proposal-class-properties not found declared in .eslintrc ESLint 仅针对特定目录(eslintrc、create-react-app) - ESLint only target a specific directory (eslintrc, create-react-app) 根据 .eslintrc 文件中的规则,eslint 不会在 VSCode 中给出错误 - eslint not giving errors in VSCode according to rules in .eslintrc file 我应该如何将* .eslintrc *更新为ESLint以查看更改? - How should I update *.eslintrc* to ESLint see the changes? Gulp eslint 找不到我的 .eslintrc 文件 - Gulp eslint doesn't find my .eslintrc file ESLint不忽略.eslintrc.json中给定的全局变量 - ESLint not ignoring global variables given in .eslintrc.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM