概要
react-routerの<Link> Componentはリンク先を決めるAttributeとしてhref
の代わりにto
を使う。
だが、eslint
のjsx-a11y/anchor-is-valid
プラグインを使っていると、href
を使っていない事で怒られてしまう。
解決策
ルールを無効にする事も出来るが、それだと本来の<a>タグを使用する時に機能しなくなってしまうので、<Link> Componentを使う時は特別にto
をリンク先を決めるAttributeとして認める為のルールを.eslintrc
に追加する。
eslintrc.js
module.exports = {
"rules": {
"jsx-a11y/anchor-is-valid": [ "error", {
"components": [ "Link" ],
"specialLink": ["to"]
}]
}
}