eslint-plugin-react没有找到规则

时间:2016-03-20 22:45:21

标签: reactjs eslint

Sublime Text 3 eslinter显示代码第一行的错误消息,指出无法找到react / jsx-quotes的规则。这是eslinter(.eslintrc)的配置文件:

{
  "ecmaFeatures": {
  "modules": true,
  "jsx": true
},
"env": {
        "browser": true,
        "node": true,
        "es6": true,
        "jasmine": true
      },
      "rules": {
        "strict": 0,
        "no-underscore-dangle": 0,
        "quotes": [2, "single"],
        "max-len": [1, 80, 4],
        "no-trailing-spaces": [2, { skipBlankLines: true }],
        "no-mixed-spaces-and-tabs": [2, "smart-tabs"],
        "no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
        "semi": [1, "always"],
        "no-unused-expressions": 1,
        "no-shadow": 0,
        "no-redeclare": 0,
        "new-cap": 0,

        "react/display-name": 0,
        "react/jsx-boolean-value": 1,
        "react/jsx-no-undef": 1,
        "react/jsx-quotes": 1,
        "react/jsx-sort-prop-types": 1,
        "react/jsx-sort-props": 0,
        "react/jsx-uses-react": 1,
        "react/jsx-uses-vars": 1,
        "react/no-did-mount-set-state": 0,
        "react/no-did-update-set-state": 0,
        "react/no-multi-comp": 0,
        "react/no-unknown-property": 1,
        "react/prop-types": 0,
        "react/react-in-jsx-scope": 1,
        "react/self-closing-comp": 1,
        "react/sort-comp": 1,
        "react/wrap-multilines": 1,
      },
      "plugins": [
        "react"
      ]
    }

我在全局和本地安装了eslint-plugin-react,此.eslintrc位于应用的根文件夹中。我遵循了几个建议(比如添加" parserOptions")但它没有用。我错过了什么?

1 个答案:

答案 0 :(得分:3)

而不是

"react/jsx-quotes": 1,

使用此配置

"jsx-quotes": [2, "prefer-double"]