【问题标题】:eslint-plugin-react does not find a ruleeslint-plugin-react 没有找到规则
【发布时间】:2023-03-27 00:06:01
【问题描述】:

Sublime Text 3 eslinter 显示代码第一行的错误消息说找不到 react/jsx-quotes 的规则。这是 eslint 的配置文件(.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”),但没有奏效。我错过了什么?

【问题讨论】:

标签: reactjs eslint


【解决方案1】:

代替

"react/jsx-quotes": 1,

使用这个配置

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

【讨论】:

  • 这对我不起作用 - 我似乎根本无法让这些规则中的任何一个起作用。
猜你喜欢
  • 2018-04-21
  • 1970-01-01
  • 2018-07-04
  • 1970-01-01
  • 2019-09-07
  • 2016-05-27
  • 2020-07-13
  • 2019-07-30
  • 2020-08-13
相关资源
最近更新 更多