[英]Turning eslint rule off in eslintrc.json
I am trying to disable jsx-a11y/anchor-is-valid
in eslintrc.json
. 我试图禁用
jsx-a11y/anchor-is-valid
的eslintrc.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-line
或href="#/"
替代方案,尽管可能是未经推荐的。 Check out the discussion here for more information. 有关更多信息,请查看此处的讨论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.