src/content/docs/linter/rules/no-ambiguous-anchor-text.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="HTML" icon="seti:html"> :::caution This rule is part of the [nursery](/linter/#nursery) group. This means that it is experimental and the behavior can change at any time. ::: ## Summary - Rule available since: `v2.3.10` - Diagnostic Category: [`lint/nursery/noAmbiguousAnchorText`](/reference/diagnostics#diagnostic-category) - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`jsx-a11y/anchor-ambiguous-text`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/docs/rules/anchor-ambiguous-text.md){
"linter": {
"rules": {
"nursery": {
"noAmbiguousAnchorText": "error"
}
}
}
}
Disallow ambiguous anchor descriptions.
Enforces <a> values are not exact matches for the phrases "click here", "here", "link", "a link", or "learn more".
Screen readers announce tags as links/interactive, but rely on values for context.
Ambiguous anchor descriptions do not provide sufficient context for users.
<a>learn more</a>
<a>documentation</a>
wordsThe words option allows users to modify the strings that can be checked for in the anchor text. Useful for specifying other words in other languages.
Default ["click here", "here", "link", "a link", "learn more"]
{
"linter": {
"rules": {
"nursery": {
"noAmbiguousAnchorText": {
"options": {
"words": [
"click this"
]
}
}
}
}
}
}
<a>click this</a>
{
"linter": {
"rules": {
"nursery": {
"noAmbiguousAnchorText": "error"
}
}
}
}
Disallow ambiguous anchor descriptions.
Enforces <a> values are not exact matches for the phrases "click here", "here", "link", "a link", or "learn more".
Screen readers announce tags as links/interactive, but rely on values for context.
Ambiguous anchor descriptions do not provide sufficient context for users.
const Invalid = () => <a>learn more</a>;
const Valid = () => <a>documentation</a>;
wordsThe words option allows users to modify the strings that can be checked for in the anchor text. Useful for specifying other words in other languages.
Default ["click here", "here", "link", "a link", "learn more"]
{
"linter": {
"rules": {
"nursery": {
"noAmbiguousAnchorText": {
"options": {
"words": [
"click this"
]
}
}
}
}
}
}
const Invalid = () => <a>click this</a>;