You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstshouldBeValid=(<><ahref="/some/valid/uri">Navigate to page</a><ahref={"/some/valid/uri"}>Navigate to page</a><ahref={`/some/valid/uri`}>Navigate to page</a><ahref="#top">Navigate to internal page location</a><ahref={"#top"}>Navigate to internal page location</a><ahref={`#top`}>Navigate to internal page location</a><ahref="https://github.com">github</a><ahref={"https://github.com"}>github</a><ahref={`https://github.com`}>github</a><ahref="#section">section</a><ahref={"#section"}>section</a><ahref={`#section`}>section</a></>)exportconstshouldBeInvalid=(<><ahref="#">invalid</a><ahref={"#"}>invalid</a><ahref={`#`}>invalid</a></>)
Result
Oxlint:
> bunx oxlint --jsx-a11y-plugin src\bar.tsx ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:3:4] 2 │ <> 3 │ <a href="/some/valid/uri">Navigate to page</a> · ─ 4 │ <a href={"/some/valid/uri"}>Navigate to page</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:4:4] 3 │ <a href="/some/valid/uri">Navigate to page</a> 4 │ <a href={"/some/valid/uri"}>Navigate to page</a> · ─ 5 │ <a href={`/some/valid/uri`}>Navigate to page</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:6:4] 5 │ <a href={`/some/valid/uri`}>Navigate to page</a> 6 │ <a href="#top">Navigate to internal page location</a> · ─ 7 │ <a href={"#top"}>Navigate to internal page location</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:7:4] 6 │ <a href="#top">Navigate to internal page location</a> 7 │ <a href={"#top"}>Navigate to internal page location</a> · ─ 8 │ <a href={`#top`}>Navigate to internal page location</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:9:4] 8 │ <a href={`#top`}>Navigate to internal page location</a> 9 │ <a href="https://github.com">github</a> · ─ 10 │ <a href={"https://github.com"}>github</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:10:4] 9 │ <a href="https://github.com">github</a> 10 │ <a href={"https://github.com"}>github</a> · ─ 11 │ <a href={`https://github.com`}>github</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:12:4] 11 │ <a href={`https://github.com`}>github</a> 12 │ <a href="#section">section</a> · ─ 13 │ <a href={"#section"}>section</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:13:4] 12 │ <a href="#section">section</a> 13 │ <a href={"#section"}>section</a> · ─ 14 │ <a href={`#section`}>section</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:20:4] 19 │ <> 20 │ <a href="#">invalid</a> · ─ 21 │ <a href={"#"}>invalid</a> ╰──── help: Provide a correct href for the `a` element. ⚠ eslint-plugin-jsx-a11y(anchor-is-valid): Use an incorrect href for the 'a' element. ╭─[src\bar.tsx:21:4] 20 │ <a href="#">invalid</a> 21 │ <a href={"#"}>invalid</a> · ─ 22 │ <a href={`#`}>invalid</a> ╰──── help: Provide a correct href for the `a` element.Finished in 5ms on 1 file with 121 rules using 12 threads.Found 10 warnings and 0 errors.
Eslint:
Only the last 3
20:3 error The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid 21:3 error The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid 22:3 error The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid ✖ 3 problems (3 errors, 0 warnings)
We can notice that the string wrapped in backquotes will only be considered a valid href, even if it's not valid (e.g. <a href={`#`}>invalid</a>)
The text was updated successfully, but these errors were encountered:
Boshen
changed the title
eslint-plugin-jsx-a11y(anchor-is-valid): Doesn't work at all
eslint-plugin-jsx-a11y(anchor-is-valid): working incorrectly
Sep 13, 2024
Example
Result
Oxlint:
Eslint:
Only the last 3
We can notice that the string wrapped in backquotes will only be considered a valid href, even if it's not valid (e.g.
<a href={`#`}>invalid</a>
)The text was updated successfully, but these errors were encountered: