heading-has-content
Configuration
rslint.config.ts
Rule Details
This rule enforces that heading elements (h1–h6, and any configured
custom heading components) have accessible content — text or descendant
elements that screen readers can announce. An empty heading with no
accessible content is reported.
A heading is considered to have accessible content when at least one of the following holds:
- It contains non-empty text or a non-hidden child element.
- It contains a JSX expression whose value is anything other than the
bare identifier
undefined. - It declares a
dangerouslySetInnerHTMLorchildrenprop.
A heading that is itself hidden from screen readers via aria-hidden
is exempt — it is not announced.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Rule Options
The rule accepts an options object with the following properties:
components— array of additional component names (besides the built-inh1–h6) that should be checked for accessible content.
Examples of incorrect code for this rule with { "components": ["Heading"] }:
Examples of correct code for this rule with { "components": ["Heading"] }: