Skip to content

Commit

Permalink
feat(eslint-plugin-template): [interactive-supports-focus] unique inv…
Browse files Browse the repository at this point in the history
…alid test descriptions
  • Loading branch information
sandikbarr committed Sep 16, 2022
1 parent ad68f28 commit d621cf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,33 +189,6 @@ The rule does not have any configuration options.

#### ❌ Invalid Code

```html
<div (click)="onClick()"></div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

<br>

---

<br>

#### Default Config

```json
{
"rules": {
"@angular-eslint/template/interactive-supports-focus": [
"error"
]
}
}
```

<br>

#### ❌ Invalid Code

```html
<span (click)="onClick()">Submit</span>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ export const invalid = [
messageId,
}),
convertAnnotatedSourceToFailureCase({
description: 'should fail not hidden from screen reader',
description:
'should fail not hidden from screen reader with bound aria-hidden attribute',
annotatedSource: `
<div [attr.aria-hidden]="false" (click)="onClick()"></div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -176,15 +177,15 @@ export const invalid = [
}),
// aria-disabled="false"
convertAnnotatedSourceToFailureCase({
description: 'should fail not hidden from screen reader',
description: 'should fail aria-disabled is false',
annotatedSource: `
<div role="button" aria-disabled="false" (click)="onClick()"></div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`,
messageId,
}),
convertAnnotatedSourceToFailureCase({
description: 'should fail not hidden from screen reader',
description: 'should fail aria-disabled is false with bound attribute',
annotatedSource: `
<div [attr.aria-disabled]="false" (click)="onClick()"></div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -204,14 +205,6 @@ export const invalid = [
}),

// no role, non interactive element
convertAnnotatedSourceToFailureCase({
description: 'should fail non-interactive element does not support focus',
annotatedSource: `
<div (click)="onClick()"></div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`,
messageId,
}),
convertAnnotatedSourceToFailureCase({
description: 'should fail non-interactive element does not support focus',
annotatedSource: `
Expand All @@ -221,7 +214,8 @@ export const invalid = [
messageId,
}),
convertAnnotatedSourceToFailureCase({
description: 'should fail non-interactive element does not support focus',
description:
'should fail non-interactive element with aria-label does not support focus',
annotatedSource: `
<div (click)="onClick()" [attr.aria-label]="clickableThing"></div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -245,15 +239,17 @@ export const invalid = [

// area and a are not interactive without href
convertAnnotatedSourceToFailureCase({
description: 'should fail non-interactive element does not support focus',
description:
'should fail non-interactive element does not support focus, area should have href',
annotatedSource: `
<area (click)="onClick()" class="foo">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`,
messageId,
}),
convertAnnotatedSourceToFailureCase({
description: 'should fail non-interactive element does not support focus',
description:
'should fail non-interactive element does not support focus, anchor should have href',
annotatedSource: `
<a (click)="onClick()">Click me</a>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit d621cf5

Please sign in to comment.