noAmbiguousAnchorText
Summary
Section titled “Summary”- Rule available since:
v2.3.10 - Diagnostic Category:
lint/nursery/noAmbiguousAnchorText - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
jsx-a11y/anchor-ambiguous-text
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noAmbiguousAnchorText": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”<a>learn more</a>code-block.html:1:1 lint/nursery/noAmbiguousAnchorText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ No ambiguous anchor descriptions allowed.
> 1 │ <a>learn more</a>
│ ^^^^^^^^^^^^^^^^^
2 │
ℹ Ambiguous anchor descriptions do not provide sufficient context for screen reader users. Provide more context to these users.
<a>documentation</a>Options
Section titled “Options”The 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" ] } } } } }}Invalid
Section titled “Invalid”<a>click this</a>Related links
Section titled “Related links”Summary
Section titled “Summary”- Rule available since:
v2.3.10 - Diagnostic Category:
lint/nursery/noAmbiguousAnchorText - This rule doesn’t have a fix.
- The default severity of this rule is information.
- Sources:
- Same as
jsx-a11y/anchor-ambiguous-text
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noAmbiguousAnchorText": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const Invalid = () => <a>learn more</a>;code-block.jsx:1:23 lint/nursery/noAmbiguousAnchorText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ No ambiguous anchor descriptions allowed.
> 1 │ const Invalid = () => <a>learn more</a>;
│ ^^^^^^^^^^^^^^^^^
2 │
ℹ Ambiguous anchor descriptions do not provide sufficient context for screen reader users. Provide more context to these users.
const Valid = () => <a>documentation</a>;Options
Section titled “Options”The 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" ] } } } } }}Invalid
Section titled “Invalid”const Invalid = () => <a>click this</a>;code-block.jsx:1:23 lint/nursery/noAmbiguousAnchorText ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ No ambiguous anchor descriptions allowed.
> 1 │ const Invalid = () => <a>click this</a>;
│ ^^^^^^^^^^^^^^^^^
2 │
ℹ Ambiguous anchor descriptions do not provide sufficient context for screen reader users. Provide more context to these users.
Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.