错误不断弹出:规则“re​​act / jsx-uses-react”的配置无效

时间:2017-08-19 12:06:19

标签: sublimetext3 eslint eslint-config-airbnb

当我在Sublime文本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)

1 个答案:

答案 0 :(得分:0)

我遇到了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"
  ],
}