Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin-template): [accessibility-elements-content] add allowList option #1201

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,7 +23,17 @@ Ensures that the heading, anchor and button elements have content in it

## Rule Options

The rule does not have any configuration options.
The rule accepts an options object with the following properties:

```ts
interface Options {
/**
* Default: `["aria-label","innerHtml","innerHTML","innerText","outerHTML","title"]`
*/
allowList?: string[];
}

```

<br>

Expand Down Expand Up @@ -113,94 +123,48 @@ The rule does not have any configuration options.
~~~~~~~~~~~~~~~~~
```

</details>

<br>

---

<br>

<details>
<summary>✅ - Toggle examples of <strong>correct</strong> code for this rule</summary>

<br>

#### Default Config
#### Custom Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
"error",
{
"allowList": [
"aria-labelledby"
]
}
]
}
}
```

<br>

#### ✅ Valid Code
#### ❌ Invalid Code

```html
<h1>Heading Content!</h1>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
<button [ariaLabelledBy]="label"></button>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

<br>

#### ✅ Valid Code

```html
<h2><app-content></app-content></h2>
```
</details>

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<h3 [innerHtml]="dangerouslySetHTML"></h3>
```

<br>

---
<details>
<summary>✅ - Toggle examples of <strong>correct</strong> code for this rule</summary>

<br>

Expand All @@ -221,215 +185,19 @@ The rule does not have any configuration options.
#### ✅ Valid Code

```html
<h1>Heading Content!</h1>
<h2><app-content></app-content></h2>
<h3 [innerHtml]="dangerouslySetHTML"></h3>
<h4 [innerText]="text"></h4>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<a>Anchor Content!</a>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<a><app-content></app-content></a>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<a [innerHTML]="dangerouslySetHTML"></a>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<a [innerText]="text"></a>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<a [outerHTML]="text"></a>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<a aria-hidden></a>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<button [attr.aria-hidden]="true"></button>
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
]
}
}
```

<br>

#### ✅ Valid Code

```html
<h5 [attr.aria-label]="text"></h5>
<h6 title="text"></h6>
```

<br>
Expand All @@ -438,13 +206,19 @@ The rule does not have any configuration options.

<br>

#### Default Config
#### Custom Config

```json
{
"rules": {
"@angular-eslint/template/accessibility-elements-content": [
"error"
"error",
{
"allowList": [
"appTooltipLabel",
"ariaLabel"
]
}
]
}
}
Expand All @@ -455,7 +229,10 @@ The rule does not have any configuration options.
#### ✅ Valid Code

```html
<h6 title="text"></h6>
<button appTooltipLabel="directive adds aria-label"></button>
<button [appTooltipLabel]="label"></button>
<h1 ariaLabel="Important Content"></h1>
<a [ariaLabel]="label"></a>
```

</details>
Expand Down