Ensures that the heading, anchor and button elements have content in it
- Type: suggestion
The rule accepts an options object with the following properties:
interface Options {
/**
* Default: `["aria-label","innerHtml","innerHTML","innerText","outerHTML","title"]`
*/
allowList?: string[];
}
The following examples are generated automatically from the actual unit tests within the plugin, so you can be assured that their behavior is accurate based on the current commit.
❌ - Toggle examples of incorrect code for this rule
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
<h1 class="size-1"></h1>
~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
<a href="#" [routerLink]="['route1']"></a>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
<button></button>
~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error",
{
"allowList": [
"aria-labelledby"
]
}
]
}
}
<button [ariaLabelledBy]="label"></button>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
✅ - Toggle examples of correct code for this rule
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
<h1>Heading Content!</h1>
<h2><app-content></app-content></h2>
<h3 [innerHtml]="dangerouslySetHTML"></h3>
<h4 [innerText]="text"></h4>
<a>Anchor Content!</a>
<a><app-content></app-content></a>
<a [innerHTML]="dangerouslySetHTML"></a>
<a [innerText]="text"></a>
<a [outerHTML]="text"></a>
<a aria-hidden></a>
<button [attr.aria-hidden]="true"></button>
<h5 [attr.aria-label]="text"></h5>
<h6 title="text"></h6>
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error",
{
"allowList": [
"appTooltipLabel",
"ariaLabel"
]
}
]
}
}
<button appTooltipLabel="directive adds aria-label"></button>
<button [appTooltipLabel]="label"></button>
<h1 ariaLabel="Important Content"></h1>
<a [ariaLabel]="label"></a>