简体   繁体   English

在eslintrc.json中关闭eslint规则

[英]Turning eslint rule off in eslintrc.json

I am trying to disable jsx-a11y/anchor-is-valid in eslintrc.json . 我试图禁用jsx-a11y/anchor-is-valideslintrc.json According to the docs , the relevant rule block looks like this: 根据文档 ,相关的规则块如下所示:

{
    "rules": {
        "jsx-a11y/anchor-is-valid": [ "error", {
            "components": [ "Link" ],
            "specialLink": [ "hrefLeft", "hrefRight" ],
            "aspects": [ "noHref", "invalidHref", "preferButton" ]
          }]
    }
}

This used to work before I upgraded create-react-app to version 2.0, where my eslint rule was simply "jsx-a11y/anchor-is-valid": 0 . 这在我将create-react-app升级到版本2.0之前曾经工作过,其中我的eslint规则只是"jsx-a11y/anchor-is-valid": 0

I have read the eslint docs which says that we can simply change error into off , although I have tried that to no avail. 我已经阅读过eslint docs ,它说我们可以简单地将error更改为off ,尽管我已经尝试过无效。

What is the correct way to disable the rule and what is the documentation that I should be referencing? 禁用规则的正确方法是什么?我应该引用的文档是什么?

Seems like this is a new addition to create react app. 似乎这是创建react应用程序的新增功能。 The point is to convert the href into a button if possible. 重点是尽可能将href转换为button

Adding "jsx-a11y/anchor-is-valid": 0 to .eslintrc.json is correct. 添加"jsx-a11y/anchor-is-valid": 0.eslintrc.json是正确的。 This prevents errors from showing up when running eslint , but does not prevent errors from showing up in the CRA console. 这可以防止在运行eslint时出现错误,但不会阻止错误显示在CRA控制台中。

Alternatives such as // eslint-disable-next-line or href="#/" can be used although perhaps unrecommended. 可以使用诸如// eslint-disable-next-linehref="#/"替代方案,尽管可能是未经推荐的。 Check out the discussion here for more information. 有关更多信息,请查看此处的讨论。

暂无
暂无

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

相关问题 Eslint 插件“反应”在 eslintrc.json >> eslint-config-airbnb 之间发生冲突 - Eslint Plugin "react"was conflicted between .eslintrc.json >> eslint-config-airbnb 无法加载在“.eslintrc.json”中声明的插件“prettier”:找不到模块“eslint-plugin-prettier” - Failed to load plugin 'prettier' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-prettier' eslint - 尽管有 correct.eslintrc.json 设置,但 no-unused-vars 警告仍然存在 - eslint - no-unused-vars warning persists despite correct .eslintrc.json setting Create-react-app - 插件“react”中的错误在“.eslintrc.json”和“BaseConfig”之间发生冲突 - Create-react-app - ERROR in Plugin "react" was conflicted between ".eslintrc.json" and "BaseConfig" heroku 无法加载要扩展的配置“airbnb”。 引用自:/app/.eslintrc.json - heroku Failed to load config "airbnb" to extend from. Referenced from: /app/.eslintrc.json 关闭 ESLint 规则(在 React 应用程序中,使用 WebStorm) - Turn off ESLint rule (in React app, using WebStorm) 错误:无法加载在“.eslintrc.js”中声明的解析器“@babel/eslint-parser”:找不到模块“@babel/core/package.json” - Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.js': Cannot find module '@babel/core/package.json' 标签的 EsLint 规则 - EsLint rule for label 处理“无法加载在‘.eslintrc’中声明的插件‘react’:找不到模块‘eslint-plugin-react’”ESLint 错误 - Dealing with "Failed to load plugin 'react' declared in '.eslintrc': Cannot find module 'eslint-plugin-react'" ESLint error MaterialUI 的自定义 ESLint 导入规则 - Custom ESLint Import Rule for MaterialUI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM