Skip to content

Commit

Permalink
refcator(lint/noRedundantRoles): improve diagnostic message (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerTimonius authored Sep 21, 2023
1 parent 7de063c commit 05ff3f9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Rule for NoRedundantRoles {
rule_category!(),
state.redundant_attribute_value.range(),
markup! {
"Using the role attribute '"{role_attribute}"' on the '"{element}"' element is redundant."
"Using the role attribute '"{role_attribute}"' on the '"{element}"' element is redundant, because it is implied by the semantic '"{element}"' element."
},
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ expression: invalid.jsx
```
invalid.jsx:2:16 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'article' on the 'article' element is redundant.
! Using the role attribute 'article' on the 'article' element is redundant, because it is implied by the semantic 'article' element.
1 │ <>
> 2 │ <article role="article"></article>
Expand All @@ -63,7 +63,7 @@ invalid.jsx:2:16 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:3:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'button' on the 'button' element is redundant.
! Using the role attribute 'button' on the 'button' element is redundant, because it is implied by the semantic 'button' element.
1 │ <>
2 │ <article role="article"></article>
Expand All @@ -82,7 +82,7 @@ invalid.jsx:3:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:4:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'heading' on the 'h1' element is redundant.
! Using the role attribute 'heading' on the 'h1' element is redundant, because it is implied by the semantic 'h1' element.
2 │ <article role="article"></article>
3 │ <button role="button"></button>
Expand All @@ -101,7 +101,7 @@ invalid.jsx:4:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:7:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'heading' on the 'h1' element is redundant.
! Using the role attribute 'heading' on the 'h1' element is redundant, because it is implied by the semantic 'h1' element.
5 │ title
6 │ </h1>
Expand All @@ -120,7 +120,7 @@ invalid.jsx:7:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:8:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'heading' on the 'h2' element is redundant.
! Using the role attribute 'heading' on the 'h2' element is redundant, because it is implied by the semantic 'h2' element.
6 │ </h1>
7 │ <h1 role="heading">title</h1>
Expand All @@ -139,7 +139,7 @@ invalid.jsx:8:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:9:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'dialog' on the 'dialog' element is redundant.
! Using the role attribute 'dialog' on the 'dialog' element is redundant, because it is implied by the semantic 'dialog' element.
7 │ <h1 role="heading">title</h1>
8 │ <h2 role={`heading`}></h2>
Expand All @@ -158,7 +158,7 @@ invalid.jsx:9:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:10:30 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'checkbox' on the 'input' element is redundant.
! Using the role attribute 'checkbox' on the 'input' element is redundant, because it is implied by the semantic 'input' element.
8 │ <h2 role={`heading`}></h2>
9 │ <dialog role="dialog"></dialog>
Expand All @@ -177,7 +177,7 @@ invalid.jsx:10:30 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:11:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'figure' on the 'figure' element is redundant.
! Using the role attribute 'figure' on the 'figure' element is redundant, because it is implied by the semantic 'figure' element.
9 │ <dialog role="dialog"></dialog>
10 │ <input type="checkbox" role="checkbox" />
Expand All @@ -196,7 +196,7 @@ invalid.jsx:11:15 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:12:13 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'form' on the 'form' element is redundant.
! Using the role attribute 'form' on the 'form' element is redundant, because it is implied by the semantic 'form' element.
10 │ <input type="checkbox" role="checkbox" />
11 │ <figure role="figure"></figure>
Expand All @@ -215,7 +215,7 @@ invalid.jsx:12:13 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:14:17 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'group' on the 'fieldset' element is redundant.
! Using the role attribute 'group' on the 'fieldset' element is redundant, because it is implied by the semantic 'fieldset' element.
12 │ <form role="form"></form>
13 │ {/* Needs to check the ancestors: <td role="gridcell"></td> */}
Expand All @@ -234,7 +234,7 @@ invalid.jsx:14:17 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:15:32 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'img' on the 'img' element is redundant.
! Using the role attribute 'img' on the 'img' element is redundant, because it is implied by the semantic 'img' element.
13 │ {/* Needs to check the ancestors: <td role="gridcell"></td> */}
14 │ <fieldset role="group"></fieldset>
Expand All @@ -253,7 +253,7 @@ invalid.jsx:15:32 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:16:19 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'presentation' on the 'img' element is redundant.
! Using the role attribute 'presentation' on the 'img' element is redundant, because it is implied by the semantic 'img' element.
14 │ <fieldset role="group"></fieldset>
15 │ <img src="foo" alt="bar" role="img" />
Expand All @@ -272,7 +272,7 @@ invalid.jsx:16:19 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:17:19 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'link' on the 'a' element is redundant.
! Using the role attribute 'link' on the 'a' element is redundant, because it is implied by the semantic 'a' element.
15 │ <img src="foo" alt="bar" role="img" />
16 │ <img alt="" role="presentation"></img>
Expand All @@ -291,7 +291,7 @@ invalid.jsx:17:19 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:18:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'list' on the 'ol' element is redundant.
! Using the role attribute 'list' on the 'ol' element is redundant, because it is implied by the semantic 'ol' element.
16 │ <img alt="" role="presentation"></img>
17 │ <a href="#" role="link"></a>
Expand All @@ -310,7 +310,7 @@ invalid.jsx:18:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:19:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'list' on the 'ul' element is redundant.
! Using the role attribute 'list' on the 'ul' element is redundant, because it is implied by the semantic 'ul' element.
17 │ <a href="#" role="link"></a>
18 │ <ol role="list"></ol>
Expand All @@ -329,7 +329,7 @@ invalid.jsx:19:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:20:27 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'combobox' on the 'select' element is redundant.
! Using the role attribute 'combobox' on the 'select' element is redundant, because it is implied by the semantic 'select' element.
18 │ <ol role="list"></ol>
19 │ <ul role="list"></ul>
Expand All @@ -348,7 +348,7 @@ invalid.jsx:20:27 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:21:45 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'listbox' on the 'select' element is redundant.
! Using the role attribute 'listbox' on the 'select' element is redundant, because it is implied by the semantic 'select' element.
19 │ <ul role="list"></ul>
20 │ <select name="name" role="combobox"></select>
Expand All @@ -367,7 +367,7 @@ invalid.jsx:21:45 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:22:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'listitem' on the 'li' element is redundant.
! Using the role attribute 'listitem' on the 'li' element is redundant, because it is implied by the semantic 'li' element.
20 │ <select name="name" role="combobox"></select>
21 │ <select name="name" multiple size="4" role="listbox"></select>
Expand All @@ -386,7 +386,7 @@ invalid.jsx:22:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:23:12 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'navigation' on the 'nav' element is redundant.
! Using the role attribute 'navigation' on the 'nav' element is redundant, because it is implied by the semantic 'nav' element.
21 │ <select name="name" multiple size="4" role="listbox"></select>
22 │ <li role="listitem"></li>
Expand All @@ -405,7 +405,7 @@ invalid.jsx:23:12 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:25:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'row' on the 'tr' element is redundant.
! Using the role attribute 'row' on the 'tr' element is redundant, because it is implied by the semantic 'tr' element.
23 │ <nav role="navigation"></nav>
24 │ {/* Needs to check the ancestors: <option role="option"></option> */}
Expand All @@ -424,7 +424,7 @@ invalid.jsx:25:11 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:26:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'rowgroup' on the 'tbody' element is redundant.
! Using the role attribute 'rowgroup' on the 'tbody' element is redundant, because it is implied by the semantic 'tbody' element.
24 │ {/* Needs to check the ancestors: <option role="option"></option> */}
25 │ <tr role="row"></tr>
Expand All @@ -443,7 +443,7 @@ invalid.jsx:26:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:27:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'rowgroup' on the 'tfoot' element is redundant.
! Using the role attribute 'rowgroup' on the 'tfoot' element is redundant, because it is implied by the semantic 'tfoot' element.
25 │ <tr role="row"></tr>
26 │ <tbody role="rowgroup"></tbody>
Expand All @@ -462,7 +462,7 @@ invalid.jsx:27:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:28:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'rowgroup' on the 'thead' element is redundant.
! Using the role attribute 'rowgroup' on the 'thead' element is redundant, because it is implied by the semantic 'thead' element.
26 │ <tbody role="rowgroup"></tbody>
27 │ <tfoot role="rowgroup"></tfoot>
Expand All @@ -481,7 +481,7 @@ invalid.jsx:28:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:30:28 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'searchbox' on the 'input' element is redundant.
! Using the role attribute 'searchbox' on the 'input' element is redundant, because it is implied by the semantic 'input' element.
28 │ <thead role="rowgroup"></thead>
29 │ {/* Needs to check the ancestors: <th scope="row" role="rowheader"></th> */}
Expand All @@ -500,7 +500,7 @@ invalid.jsx:30:28 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:31:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'table' on the 'table' element is redundant.
! Using the role attribute 'table' on the 'table' element is redundant, because it is implied by the semantic 'table' element.
29 │ {/* Needs to check the ancestors: <th scope="row" role="rowheader"></th> */}
30 │ <input type="search" role="searchbox" />
Expand All @@ -519,7 +519,7 @@ invalid.jsx:31:14 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:32:17 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'textbox' on the 'textarea' element is redundant.
! Using the role attribute 'textbox' on the 'textarea' element is redundant, because it is implied by the semantic 'textarea' element.
30 │ <input type="search" role="searchbox" />
31 │ <table role="table"></table>
Expand All @@ -538,7 +538,7 @@ invalid.jsx:32:17 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━
```
invalid.jsx:33:26 lint/a11y/noRedundantRoles FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! Using the role attribute 'textbox' on the 'input' element is redundant.
! Using the role attribute 'textbox' on the 'input' element is redundant, because it is implied by the semantic 'input' element.
31 │ <table role="table"></table>
32 │ <textarea role="textbox"></textarea>
Expand Down
Loading

0 comments on commit 05ff3f9

Please sign in to comment.