在执行导入React时,总是在Eslint(v 6.0.0)中获得``未找到规则'no-useless-catch'的定义''

时间:2020-01-08 08:50:33

标签: reactjs eslint eslintrc

我已经尝试过用Google搜索这个工具,但到目前为止还是无济于事...

在标准的React项目中,每个组件通常以import React from 'react'开头。对我来说,将Eslint v6.0.0配置为扩展:'standard', "eslint:recommended", "plugin:react/recommended",我总是在vscode中收到此警告:

Definition for rule 'no-useless-catch' was not foundeslint(no-useless-catch)

..表示JavaScript文件中的第一个import

vscode screenshot

关于为什么会这样的任何想法?我不想禁用该规则,因为它似乎很有用,但是我如何配置eslint在项目中的每个文件中都不要抱怨呢?

这是完整的eslintrc文件:

module.exports = {
  env: {
    browser: true,
    es6: true
  },
  parser: 'babel-eslint',
  extends: [
    'standard',
    "eslint:recommended",
    "plugin:react/recommended"
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly'
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true
    },
    ecmaVersion: 2018,
    sourceType: 'module'
  },
  plugins: [
    'react'
  ],
  rules: {
    "quotes": ["warn", "single"],
    "indent": ["warn", "tab", { "ignoreComments": true }],
    "no-tabs": 0,
    "padded-blocks": 0,
    "semi": ["warn", "never"],
    "no-trailing-spaces": 0,
    "spaced-comment": 0,
    "no-multiple-empty-lines": 0,
    "space-before-function-paren": 0,
    "camelcase": 0,
    "prefer-const": "warn",
    "space-infix-ops": "warn",
    "no-case-declarations": 0,

  }
}

1 个答案:

答案 0 :(得分:2)

没关系,弄清楚了……我使用的是eslint 5.6,no-useless-catch规则直到5.11才引入,因此出现了错误...