Skip to content

Commit d6dc426

Browse files
committed
Sync with ember-template-lint
1 parent 0546789 commit d6dc426

2 files changed

Lines changed: 49 additions & 68 deletions

File tree

docs/rules/template-require-context-role.md

Lines changed: 43 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,9 @@
22

33
<!-- end auto-generated rule header -->
44

5-
Requires certain ARIA roles to be used in appropriate context.
6-
7-
Some ARIA roles must be contained within specific parent roles to be meaningful and accessible. For example, a `role="listitem"` must be inside an element with `role="list"`.
8-
9-
## Rule Details
10-
11-
This rule checks that context-dependent ARIA roles are used within the appropriate parent roles.
12-
13-
Roles requiring context:
5+
## `<* role><* role /></*>`
146

15-
- `listitem` → must be in `list`
16-
- `option` → must be in `listbox`
17-
- `tab` → must be in `tablist`
18-
- `menuitem`, `menuitemcheckbox`, `menuitemradio` → must be in `menu` or `menubar`
19-
- `treeitem` → must be in `tree`
20-
- `row` → must be in `table`, `grid`, `treegrid`, or `rowgroup`
21-
- And more...
7+
The required context role defines the owning container where this role is allowed. If a role has a required context, authors MUST ensure that an element with the role is contained inside (or owned by) an element with the required context role. For example, an element with `role="listitem"` is only meaningful when contained inside (or owned by) an element with `role="list"`. You may place intermediate elements with `role="presentation"` or `role="none"` to remove their semantic meaning.
228

239
## Roles to check
2410

@@ -37,65 +23,60 @@ Format: role | required context role
3723
- tab | tablist
3824
- treeitem | group or tree
3925

40-
## `<* role><* role /></*>`
41-
42-
The required context role defines the owning container where this role is allowed. If a role has a required context, authors MUST ensure that an element with the role is contained inside (or owned by) an element with the required context role. For example, an element with `role="listitem"` is only meaningful when contained inside (or owned by) an element with `role="list"`. You may place intermediate elements with `role="presentation"` or `role="none"` to remove their semantic meaning.
43-
4426
## Examples
4527

46-
Examples of **incorrect** code for this rule:
28+
This rule **allows** the following:
4729

48-
```gjs
49-
<template>
50-
<div>
51-
<span role="listitem">Item</span>
52-
</div>
53-
</template>
30+
```hbs
31+
<div role='list'>
32+
<div role='listitem'>Item One</div>
33+
<div role='listitem'>Item Two</div>
34+
</div>
5435
```
5536

56-
```gjs
57-
<template>
58-
<div>
59-
<span role="tab">Tab 1</span>
37+
```hbs
38+
<div role='menu'>
39+
<div role='presentation'>
40+
<a role='menuitem'>Item One</a>
6041
</div>
61-
</template>
62-
```
63-
64-
```gjs
65-
<template>
66-
<div>
67-
<span role="menuitem">Item</span>
42+
<div role='presentation'>
43+
<a role='menuitem'>Item Two</a>
6844
</div>
69-
</template>
45+
</div>
7046
```
7147

72-
Examples of **correct** code for this rule:
48+
This rule **forbids** the following:
7349

74-
```gjs
75-
<template>
76-
<ul role="list">
77-
<li role="listitem">Item</li>
78-
</ul>
79-
</template>
50+
```hbs
51+
<div>
52+
<div role='listitem'>Item One</div>
53+
<div role='listitem'>Item Two</div>
54+
</div>
8055
```
8156

82-
```gjs
83-
<template>
84-
<div role="tablist">
85-
<div role="tab">Tab 1</div>
57+
```hbs
58+
<div role='menu'>
59+
<div role='button'>
60+
<a role='menuitem'>Item One</a>
8661
</div>
87-
</template>
88-
```
89-
90-
```gjs
91-
<template>
92-
<div role="menu">
93-
<div role="menuitem">Item</div>
62+
<div>
63+
<a role='menuitem'>Item Two</a>
9464
</div>
95-
</template>
65+
</div>
9666
```
9767

98-
## References
99-
100-
- [eslint-plugin-ember template-require-context-role](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-require-context-role.md)
101-
- [WAI-ARIA - Required Context Roles](https://www.w3.org/TR/wai-aria-1.2/#scope)
68+
### References
69+
70+
1. <https://www.w3.org/TR/wai-aria-1.1/#scope>
71+
1. <https://www.w3.org/TR/wai-aria-1.1/#columnheader>
72+
1. <https://www.w3.org/TR/wai-aria-1.1/#gridcell>
73+
1. <https://www.w3.org/TR/wai-aria-1.1/#listitem>
74+
1. <https://www.w3.org/TR/wai-aria-1.1/#menuitem>
75+
1. <https://www.w3.org/TR/wai-aria-1.1/#menuitemcheckbox>
76+
1. <https://www.w3.org/TR/wai-aria-1.1/#menuitemradio>
77+
1. <https://www.w3.org/TR/wai-aria-1.1/#option>
78+
1. <https://www.w3.org/TR/wai-aria-1.1/#row>
79+
1. <https://www.w3.org/TR/wai-aria-1.1/#rowgroup>
80+
1. <https://www.w3.org/TR/wai-aria-1.1/#rowheader>
81+
1. <https://www.w3.org/TR/wai-aria-1.1/#tab>
82+
1. <https://www.w3.org/TR/wai-aria-1.1/#treeitem>

tests/lib/rules/template-require-context-role.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ ruleTester.run('template-require-context-role', rule, {
195195
output: null,
196196
errors: [
197197
{
198-
message:
199-
'Role "option" must be contained in an element with one of these roles: listbox',
198+
message: 'Role "option" must be contained in an element with one of these roles: listbox',
200199
},
201200
],
202201
},
@@ -225,7 +224,8 @@ ruleTester.run('template-require-context-role', rule, {
225224
output: null,
226225
errors: [
227226
{
228-
message: 'Role "rowheader" must be contained in an element with one of these roles: grid, row',
227+
message:
228+
'Role "rowheader" must be contained in an element with one of these roles: grid, row',
229229
},
230230
],
231231
},
@@ -402,8 +402,7 @@ hbsRuleTester.run('template-require-context-role', rule, {
402402
output: null,
403403
errors: [
404404
{
405-
message:
406-
'Role "option" must be contained in an element with one of these roles: listbox',
405+
message: 'Role "option" must be contained in an element with one of these roles: listbox',
407406
},
408407
],
409408
},
@@ -432,7 +431,8 @@ hbsRuleTester.run('template-require-context-role', rule, {
432431
output: null,
433432
errors: [
434433
{
435-
message: 'Role "rowheader" must be contained in an element with one of these roles: grid, row',
434+
message:
435+
'Role "rowheader" must be contained in an element with one of these roles: grid, row',
436436
},
437437
],
438438
},

0 commit comments

Comments
 (0)