How can I fix jsx-a11y/anchor-is-valid when using the Link component in React?

前端 未结 3 1080
一整个雨季
一整个雨季 2021-02-06 22:26

In a React app

Person Link

results in the following eslint error

The href attribu

3条回答
  •  你的背包
    2021-02-06 22:49

    The Link component generates href attribute so in the end anchor tag is valid from the accessibility point of view. Add an exception to .eslintrc:

    {
      "rules": {
        "jsx-a11y/anchor-is-valid": [ "error", {
          "components": [ "Link" ],
          "specialLink": [ "to" ]
        }]
      }
    }
    

    Additionally, there is the same issue with a answer on GitHub.

提交回复
热议问题