Skip to content

noAmbiguousAnchorText

¥Summary

¥How to configure

biome.json
{
"linter": {
"rules": {
"nursery": {
"noAmbiguousAnchorText": "error"
}
}
}
}

¥Description

禁止使用含义模糊的锚点描述。

¥Disallow ambiguous anchor descriptions.

强制 <a> 值不能与短语 “点击此处”、“此处”、“link”、“链接” 或 “了解更多” 完全匹配。屏幕阅读器将标签读作 links/interactive,但依赖于值来获取上下文。含糊不清的锚点描述无法为用户提供足够的上下文。

¥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

¥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.

¥Valid

<a>documentation</a>

¥Options

words 选项允许用户修改锚文本中可以检查的字符串。适用于指定其他语言的单词。

¥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.

默认 ["click here", "here", "link", "a link", "learn more"]

¥Default ["click here", "here", "link", "a link", "learn more"]

biome.json
{
"linter": {
"rules": {
"nursery": {
"noAmbiguousAnchorText": {
"options": {
"words": [
"click this"
]
}
}
}
}
}
}

¥Invalid

<a>click this</a>

¥Related links