anchorContent
Reports anchor elements without accessible content.
✅ This rule is included in the jsx logical preset.
Automated tools such as screen readers and search engine crawlers rely on anchors (links) having contents to understand those links. If anchor is missing accessible content, then it will not be properly understood.
This rule checks that all anchors either have child content or an ARIA property describing the anchor.
Examples
Section titled “Examples”<a /><a></a><a> <span aria-hidden /></a><a>Link text</a><a aria-label="Link" /><a title="Link title" />When Not To Use It
Section titled “When Not To Use It”If you are using a framework that automatically generates accessible content for anchors, you can safely disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
jsx-a11y/anchor-content - Oxlint:
jsx_a11y/anchor-has-content
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.