noAmbiguousAnchorText
¥Summary
-
规则生效日期:
v2.3.10¥Rule available since:
v2.3.10 -
诊断类别:
lint/nursery/noAmbiguousAnchorText¥Diagnostic Category:
lint/nursery/noAmbiguousAnchorText -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
与
jsx-a11y/anchor-ambiguous-text相同¥Same as
jsx-a11y/anchor-ambiguous-text
-
¥How to configure
{ "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"]
{ "linter": { "rules": { "nursery": { "noAmbiguousAnchorText": { "options": { "words": [ "click this" ] } } } } }}¥Invalid
<a>click this</a>¥Related links
¥Summary
-
规则生效日期:
v2.3.10¥Rule available since:
v2.3.10 -
诊断类别:
lint/nursery/noAmbiguousAnchorText¥Diagnostic Category:
lint/nursery/noAmbiguousAnchorText -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 information。
¥The default severity of this rule is information.
-
来源:
¥Sources:
-
与
jsx-a11y/anchor-ambiguous-text相同¥Same as
jsx-a11y/anchor-ambiguous-text
-
¥How to configure
{ "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
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.
¥Valid
const 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"]
{ "linter": { "rules": { "nursery": { "noAmbiguousAnchorText": { "options": { "words": [ "click this" ] } } } } }}¥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
Biome v2.1 中文网 - 粤ICP备13048890号