簡體   English   中英

在eslintrc.json中關閉eslint規則

[英]Turning eslint rule off in eslintrc.json

我試圖禁用jsx-a11y/anchor-is-valideslintrc.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-linehref="#/"替代方案,盡管可能是未經推薦的。 有關更多信息,請查看此處的討論。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM