【问题标题】:Error keeps popping up: Configuration for rule "react/jsx-uses-react" is invalid错误不断弹出:规则“re​​act/jsx-uses-react”的配置无效
【发布时间】:2018-01-28 00:09:10
【问题描述】:

当我在 Sublime text 3 中保存任何 js 文件时,下面粘贴的错误不断弹出。 我尝试重新安装 eslint、eslint-plugin-import、eslint-config-airbnb、eslint-plugin-react,但没有结果。

有什么想法吗?

error: Error: C:\Users\user_name\node_modules\eslint-config-airbnb\rules\react.js:
  Configuration for rule "react/jsx-uses-react" is invalid:
  Value "[object Object]" should NOT have more than 0 items.

Referenced from: C:\Users\user_name\node_modules\eslint-config-airbnb\index.js
Referenced from: C:\Users\user_name\.eslintrc
Error: C:\Users\user_name\node_modules\eslint-config-airbnb\rules\react.js:
  Configuration for rule "react/jsx-uses-react" is invalid:
  Value "[object Object]" should NOT have more than 0 items.

Referenced from: C:\Users\user_name\node_modules\eslint-config-airbnb\index.js
Referenced from: C:\Users\user_name\.eslintrc
    at validateRuleOptions (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-validator.js:113:15)
    at Object.keys.forEach.id (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-validator.js:153:9)
    at Array.forEach (native)
    at validateRules (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-validator.js:152:30)
    at Object.validate (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-validator.js:230:5)
    at loadFromDisk (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-file.js:549:19)
    at load (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-file.js:592:20)
    at configExtends.reduceRight.e (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-file.js:421:36)
    at Array.reduceRight (native)
    at applyExtends (C:\Users\user_name\Dev\node_modules\eslint\lib\config\config-file.js:403:28)
(node:11548) DeprecationWarning: [eslint] The 'ecmaFeatures' config file property is deprecated, and has no effect. (found in C:\Users\user_name\node_modules\eslint-config-airbnb\rules\react.js)

【问题讨论】:

    标签: sublimetext3 eslint eslint-config-airbnb


    【解决方案1】:

    我在使用 Atom 时遇到了这个问题。你需要配置 eslint 来支持 jsx。将此添加到您的 .eslintrc 文件中。特别是parserOptions 字段!确保您也正确安装了eslint-plugin-react

    eslint-plugin-react on github

    {
      "extends": [
        "eslint:recommended",
        "plugin:react/recommended"
      ],
      "parserOptions": {
        "ecmaVersion": 6,
        "ecmaFeatures": {
            "jsx": true
        }
      },
      "plugins": [
        "react"
      ],
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-07
      • 2019-09-02
      • 2019-02-09
      • 2019-08-18
      • 2020-04-23
      • 2021-02-23
      • 2020-09-03
      • 2017-01-24
      相关资源
      最近更新 更多