简体   繁体   English

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

[英]Always getting 'definition for rule 'no-useless-catch' was not found' in Eslint (v 6.0.0) when doing import React

I have tried to google this but to no avail so far...我试过谷歌这个,但到目前为止无济于事......

In a standard React project, every component typically begins with import React from 'react' .在标准的 React 项目中,每个组件通常都以import React from 'react'开头。 For me, with Eslint v6.0.0 configured to extend: 'standard', "eslint:recommended", "plugin:react/recommended" I always get this warning in vscode:对我来说,将 Eslint v6.0.0 配置为扩展: 'standard', "eslint:recommended", "plugin:react/recommended"我总是在 vscode 中收到这个警告:

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

.. for the very first import in a javascript file. .. 在 javascript 文件中的第一次import

vscode 截图

Any ideas on why this is happening?关于为什么会发生这种情况的任何想法? I don't want to disable the rule because it does seem useful but how do I configure eslint to not complain about this in literally every file in the project?我不想禁用该规则,因为它看起来确实很有用,但是我如何配置 eslint 才不会在项目中的每个文件中都抱怨这个?

Here is the complete eslintrc file:这是完整的 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,

  }
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在运行 ESLint 时出现“未找到规则‘导入/无无关依赖’的定义”? - Why am I getting "Definition for rule 'import/no-extraneous-dependencies' was not found" when running ESLint? eslint-config-react-app throws找不到规则“ getter-return”的定义 - eslint-config-react-app throws Definition for rule 'getter-return' was not found 如何解决:“找不到规则'@typescript-eslint/consistent-type-assertions'的定义” - How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found" MaterialUI 的自定义 ESLint 导入规则 - Custom ESLint Import Rule for MaterialUI 在 Storybook js 中找不到规则“@typescript-eslint/no-implicit-any”的定义 - Definition for rule '@typescript-eslint/no-implicit-any' was not found with Storybook js 反应路由器 v6.0.0-beta.5 - React router v6.0.0-beta.5 未找到规则“re​​act-hooks/exhaustive-deps”的定义 - Definition for rule 'react-hooks/exhaustive-deps' was not found 未找到规则显示名称的 React linting 定义 - React linting definition for rule display-name not found 当您想更改默认导入的名称时,如何修复 import/no-named-as-default ESlint 规则? - How to fix import/no-named-as-default ESlint rule when you want to change the name of a default import? 禁用未找到 eslint 规则的警告消息 - Disable warning message for eslint rule not being found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM