![](/img/trans.png)
[英]Eslint Plugin "react"was conflicted between .eslintrc.json >> eslint-config-airbnb
[英]Turning eslint rule off in eslintrc.json
我試圖禁用jsx-a11y/anchor-is-valid
的eslintrc.json
。 根據文檔 ,相關的規則塊如下所示:
{
"rules": {
"jsx-a11y/anchor-is-valid": [ "error", {
"components": [ "Link" ],
"specialLink": [ "hrefLeft", "hrefRight" ],
"aspects": [ "noHref", "invalidHref", "preferButton" ]
}]
}
}
這在我將create-react-app
升級到版本2.0之前曾經工作過,其中我的eslint規則只是"jsx-a11y/anchor-is-valid": 0
。
我已經閱讀過eslint docs ,它說我們可以簡單地將error
更改為off
,盡管我已經嘗試過無效。
禁用規則的正確方法是什么?我應該引用的文檔是什么?
似乎這是創建react應用程序的新增功能。 重點是盡可能將href
轉換為button
。
添加"jsx-a11y/anchor-is-valid": 0
到.eslintrc.json
是正確的。 這可以防止在運行eslint
時出現錯誤,但不會阻止錯誤顯示在CRA控制台中。
可以使用諸如// eslint-disable-next-line
或href="#/"
替代方案,盡管可能是未經推薦的。 有關更多信息,請查看此處的討論。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.