Skip to content

Commit 592c2cc

Browse files
authored
Merge pull request #719 from backwardok/add-wcag
Add WCAG guidelines to rule documentation
2 parents 31721bd + 250e5ad commit 592c2cc

36 files changed

+248
-129
lines changed

docs/rules/accessible-emoji.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# [Deprecated] accessible-emoji
22

3-
Emoji have become a common way of communicating content to the end user. To a person using a screenreader, however, he/she may not be aware that this content is there at all. By wrapping the emoji in a `<span>`, giving it the `role="img"`, and providing a useful description in `aria-label`, the screenreader will treat the emoji as an image in the accessibility tree with an accessible name for the end user.
4-
5-
#### Resources
6-
1. [Léonie Watson](http://tink.uk/accessible-emoji/)
3+
Emoji have become a common way of communicating content to the end user. To a person using a screenreader, however, they may not be aware that this content is there at all. By wrapping the emoji in a `<span>`, giving it the `role="img"`, and providing a useful description in `aria-label`, the screenreader will treat the emoji as an image in the accessibility tree with an accessible name for the end user.
74

85
## Rule details
96

@@ -21,3 +18,9 @@ This rule takes no arguments.
2118
<span>🐼</span>
2219
<i role="img" aria-label="Panda">🐼</i>
2320
```
21+
22+
## Accessibility guidelines
23+
- [WCAG 1.1.1](https://www.w3.org/WAI/WCAG21/Understanding/non-text-content.html)
24+
25+
### Resources
26+
- [Léonie Watson, Accessible Emoji](http://tink.uk/accessible-emoji/)

docs/rules/alt-text.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
Enforce that all elements that require alternative text have meaningful information to relay back to the end user. This is a critical component of accessibility for screenreader users in order for them to understand the content's purpose on the page. By default, this rule checks for alternative text on the following elements: `<img>`, `<area>`, `<input type="image">`, and `<object>`.
44

5-
#### Resources
6-
1. [axe-core, object-alt](https://dequeuniversity.com/rules/axe/3.2/object-alt)
7-
2. [axe-core, image-alt](https://dequeuniversity.com/rules/axe/3.2/image-alt)
8-
3. [axe-core, input-image-alt](https://dequeuniversity.com/rules/axe/3.2/input-image-alt)
9-
4. [axe-core, area-alt](https://dequeuniversity.com/rules/axe/3.2/area-alt)
10-
115
## How to resolve
126
### `<img>`
137
An `<img>` must have the `alt` prop set with meaningful text or as an empty string to indicate that it is an image for decoration.
@@ -141,3 +135,12 @@ function Foo(props) {
141135

142136
<input type="image" {...props} />
143137
```
138+
139+
## Accessibility guidelines
140+
- [WCAG 1.1.1](https://www.w3.org/WAI/WCAG21/Understanding/non-text-content.html)
141+
142+
### Resources
143+
- [axe-core, object-alt](https://dequeuniversity.com/rules/axe/3.2/object-alt)
144+
- [axe-core, image-alt](https://dequeuniversity.com/rules/axe/3.2/image-alt)
145+
- [axe-core, input-image-alt](https://dequeuniversity.com/rules/axe/3.2/input-image-alt)
146+
- [axe-core, area-alt](https://dequeuniversity.com/rules/axe/3.2/area-alt)

docs/rules/anchor-has-content.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
Enforce that anchors have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the `aria-hidden` prop. Refer to the references to learn about why this is important.
44

5-
#### References
6-
1. [axe-core, link-name](https://dequeuniversity.com/rules/axe/3.2/link-name)
7-
85
## Rule details
96

107
This rule takes one optional object argument of type object:
@@ -51,3 +48,9 @@ return (
5148
<a />
5249
<a><TextWrapper aria-hidden /></a>
5350
```
51+
## Accessibility guidelines
52+
- [WCAG 2.4.4](https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context)
53+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
54+
55+
### Resources
56+
- [axe-core, link-name](https://dequeuniversity.com/rules/axe/3.2/link-name)

docs/rules/anchor-is-valid.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,6 @@ This button element can now also be used inline in text.
128128

129129
Once again we stress that this is an inferior implementation and some users will encounter difficulty to use your website, however, it will allow a larger group of people to interact with your website than the alternative of ignoring the rule's warning.
130130

131-
132-
### References
133-
1. [WebAIM - Introduction to Links and Hypertext](http://webaim.org/techniques/hypertext/)
134-
1. [Links vs. Buttons in Modern Web Applications](https://marcysutton.com/links-vs-buttons-in-modern-web-applications/)
135-
1. [Using ARIA - Notes on ARIA use in HTML](https://www.w3.org/TR/using-aria/#NOTES)
136-
137131
## Rule details
138132

139133
This rule takes one optional object argument of type object:
@@ -221,4 +215,12 @@ Invalid `href` attribute:
221215
<a href="javascript:void(0)" />
222216
<a href={"javascript:void(0)"} />
223217
<a href={`javascript:void(0)`} />
224-
```
218+
```
219+
220+
## Accessibility guidelines
221+
- [WCAG 2.1.1](https://www.w3.org/WAI/WCAG21/Understanding/keyboard)
222+
223+
### Resources
224+
- [WebAIM - Introduction to Links and Hypertext](http://webaim.org/techniques/hypertext/)
225+
- [Links vs. Buttons in Modern Web Applications](https://marcysutton.com/links-vs-buttons-in-modern-web-applications/)
226+
- [Using ARIA - Notes on ARIA use in HTML](https://www.w3.org/TR/using-aria/#NOTES)

docs/rules/aria-activedescendant-has-tabindex.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ Because an element with `aria-activedescendant` must be tabbable, it must either
1414
have an inherent `tabIndex` of zero or declare a `tabIndex` of zero with the `tabIndex`
1515
attribute.
1616

17-
#### References
18-
1. [MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-activedescendant_attribute)
19-
2017
## Rule details
2118

2219
This rule takes no arguments.
@@ -44,3 +41,9 @@ This rule takes no arguments.
4441
<div aria-activedescendant={someID} tabIndex="-1" />
4542
<input aria-activedescendant={someID} tabIndex={-1} />
4643
```
44+
45+
## Accessibility guidelines
46+
General best practice (reference resources)
47+
48+
### Resources
49+
- [MDN, Using the aria-activedescendant attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-activedescendant_attribute)

docs/rules/aria-props.md

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ This rule takes no arguments.
2020
<div id="address_label">Enter your address</div>
2121
<input aria-labeledby="address_label">
2222
```
23+
24+
## Accessibility guidelines
25+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)

docs/rules/aria-proptypes.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
ARIA state and property values must be valid.
44

5-
#### References
6-
1. [Spec](https://www.w3.org/TR/wai-aria/#states_and_properties)
7-
2. [AX_ARIA_04](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_04)
8-
95
## Rule details
106

117
This rule takes no arguments.
@@ -22,3 +18,9 @@ This rule takes no arguments.
2218
<span aria-hidden="yes">foo</span>
2319
```
2420

21+
## Accessibility guidelines
22+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
23+
24+
### Resources
25+
- [ARIA Spec, States and Properties](https://www.w3.org/TR/wai-aria/#states_and_properties)
26+
- [Chrome Audit Rules, AX_ARIA_04](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_04)

docs/rules/aria-role.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
Elements with ARIA roles must use a valid, non-abstract ARIA role. A reference to role definitions can be found at [WAI-ARIA](https://www.w3.org/TR/wai-aria/#role_definitions) site.
44

5-
[AX_ARIA_01](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_01)
6-
[DPUB-ARIA roles](https://www.w3.org/TR/dpub-aria-1.0/)
7-
85
## Rule details
96

107
This rule takes one optional object argument of type object:
@@ -37,3 +34,10 @@ For the `ignoreNonDOM` option, this determines if developer created components a
3734
<div role=""></div> <!-- Bad: An empty ARIA role is not allowed -->
3835
<Foo role={role}></Foo> <!-- Bad: ignoreNonDOM is set to false or not set -->
3936
```
37+
38+
## Accessibility guidelines
39+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
40+
41+
### Resources
42+
- [Chrome Audit Rules, AX_ARIA_01](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_01)
43+
- [DPUB-ARIA roles](https://www.w3.org/TR/dpub-aria-1.0/)

docs/rules/aria-unsupported-elements.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
Certain reserved DOM elements do not support ARIA roles, states and properties. This is often because they are not visible, for example `meta`, `html`, `script`, `style`. This rule enforces that these DOM elements do not contain the `role` and/or `aria-*` props.
44

5-
#### References
6-
1. [AX_ARIA_12](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_12)
7-
85
## Rule details
96

107
This rule takes no arguments.
@@ -21,3 +18,9 @@ This rule takes no arguments.
2118
<meta charset="UTF-8" aria-hidden="false" />
2219
```
2320

21+
## Accessibility guidelines
22+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
23+
24+
### Resources
25+
- [Chrome Audit Rules, AX_ARIA_12](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_aria_12)
26+
- [DPUB-ARIA roles](https://www.w3.org/TR/dpub-aria-1.0/)

docs/rules/autocomplete-valid.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
Ensure the autocomplete attribute is correct and suitable for the form field it is used with.
44

5-
#### References
6-
1. [axe-core, autocomplete-valid](https://dequeuniversity.com/rules/axe/3.2/autocomplete-valid)
7-
2. [HTML 5.2, Autocomplete requirements](https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute)
8-
95
## Rule details
106

117
This rule takes one optional object argument of type object:
@@ -39,4 +35,11 @@ This rule takes one optional object argument of type object:
3935

4036
<!-- Bad: MyInput is listed in inputComponents -->
4137
<MyInput autocomplete="incorrect" />
42-
```
38+
```
39+
40+
## Accessibility guidelines
41+
- [WCAG 1.3.5](https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose)
42+
43+
### Resources
44+
- [axe-core, autocomplete-valid](https://dequeuniversity.com/rules/axe/3.2/autocomplete-valid)
45+
- [HTML 5.2, Autocomplete requirements](https://www.w3.org/TR/html52/sec-forms.html#autofilling-form-controls-the-autocomplete-attribute)

docs/rules/click-events-have-key-events.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# click-events-have-key-events
22

3-
Enforce `onClick` is accompanied by at least one of the following: `onKeyUp`, `onKeyDown`, `onKeyPress`. Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users.
3+
Enforce `onClick` is accompanied by at least one of the following: `onKeyUp`, `onKeyDown`, `onKeyPress`. Coding for the keyboard is important for users with physical disabilities who cannot use a mouse, AT compatibility, and screenreader users. This does not apply for interactive or hidden elements.
44

55
## Rule details
66

@@ -11,9 +11,14 @@ This rule takes no arguments.
1111
<div onClick={() => {}} onKeyDown={this.handleKeyDown} />
1212
<div onClick={() => {}} onKeyUp={this.handleKeyUp} />
1313
<div onClick={() => {}} onKeyPress={this.handleKeyPress} />
14+
<button onClick={() => {}} />
15+
<div onClick{() => {}} aria-hidden="true" />
1416
```
1517

1618
### Fail
1719
```jsx
1820
<div onClick={() => {}} />
1921
```
22+
23+
## Accessibility guidelines
24+
- [WCAG 2.1.1](https://www.w3.org/WAI/WCAG21/Understanding/keyboard)

docs/rules/control-has-associated-label.md

+5
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,8 @@ This rule takes one optional object argument of type object:
102102
```jsx
103103
<button type="button" class="icon-save" />
104104
```
105+
106+
## Accessibility guidelines
107+
- [WCAG 1.3.1](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships)
108+
- [WCAG 3.3.2](https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions)
109+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)

docs/rules/heading-has-content.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
Enforce that heading elements (`h1`, `h2`, etc.) have content and that the content is accessible to screen readers. Accessible means that it is not hidden using the `aria-hidden` prop. Refer to the references to learn about why this is important.
44

5-
#### References
6-
1. [axe-core, empty-heading](https://dequeuniversity.com/rules/axe/3.2/empty-heading)
7-
85
## Rule details
96

107
This rule takes one optional object argument of type object:
@@ -58,3 +55,9 @@ function Foo(props) {
5855
<h1 />
5956
<h1><TextWrapper aria-hidden />
6057
```
58+
59+
## Accessibility guidelines
60+
- [WCAG 2.4.6](https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-descriptive.html)
61+
62+
### Resources
63+
- [axe-core, empty-heading](https://dequeuniversity.com/rules/axe/3.2/empty-heading)

docs/rules/html-has-lang.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
<html> elements must have the lang prop.
44

5-
#### References
6-
1. [axe-core, html-has-lang](https://dequeuniversity.com/rules/axe/3.2/html-has-lang)
7-
1. [axe-core, html-lang-valid](https://dequeuniversity.com/rules/axe/3.2/html-lang-valid)
8-
95
## Rule details
106

117
This rule takes no arguments.
@@ -22,3 +18,10 @@ This rule takes no arguments.
2218
```jsx
2319
<html>
2420
```
21+
22+
## Accessibility guidelines
23+
- [WCAG 3.1.1](https://www.w3.org/WAI/WCAG21/Understanding/language-of-page)
24+
25+
### Resources
26+
- [axe-core, html-has-lang](https://dequeuniversity.com/rules/axe/3.2/html-has-lang)
27+
- [axe-core, html-lang-valid](https://dequeuniversity.com/rules/axe/3.2/html-lang-valid)

docs/rules/iframe-has-title.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
`<iframe>` elements must have a unique title property to indicate its content to the user.
44

5-
#### References
6-
1. [axe-core, frame-title](https://dequeuniversity.com/rules/axe/3.2/frame-title)
7-
85
## Rule details
96

107
This rule takes no arguments.
@@ -27,3 +24,10 @@ This rule takes no arguments.
2724
<iframe title={true} />
2825
<iframe title={42} />
2926
```
27+
28+
## Accessibility guidelines
29+
- [WCAG 2.4.1](https://www.w3.org/WAI/WCAG21/Understanding/bypass-blocks)
30+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)
31+
32+
### Resources
33+
- [axe-core, frame-title](https://dequeuniversity.com/rules/axe/3.2/frame-title)

docs/rules/img-redundant-alt.md

+6
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ The rule will first check if `aria-hidden` is true to determine whether to enfor
3636
<img src="bar" alt="Image of me at a bar!" />
3737
<img src="baz" alt="Picture of baz fixing a bug." />
3838
```
39+
40+
## Accessibility guidelines
41+
General best practice (reference resources)
42+
43+
### Resources
44+
- [WebAIM, Alternative Text](https://webaim.org/techniques/alttext/)

docs/rules/interactive-supports-focus.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ If your element is catching bubbled click or key events from descendant elements
5050

5151
Marking an element with the role `presentation` indicates to assistive technology that this element should be ignored; it exists to support the web application and is not meant for humans to interact with directly.
5252

53-
### References
54-
1. [AX_FOCUS_02](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_focus_02)
55-
1. [Mozilla Developer Network - ARIA Techniques](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role#Keyboard_and_focus)
56-
1. [Fundamental Keyboard Navigation Conventions](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_generalnav)
57-
1. [WAI-ARIA Authoring Practices Guide - Design Patterns and Widgets](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_ex)
58-
5953
## Rule details
6054

6155
This rule takes an options object with the key `tabbable`. The value is an array of interactive ARIA roles that should be considered tabbable, not just focusable. Any interactive role not included in this list will be flagged as needing to be focusable (tabindex of -1).
@@ -143,3 +137,12 @@ The list of possible values includes:
143137
<!-- Bad: anchor element without href is not focusable -->
144138
<a onclick="showNextPage();" role="button">Next page</a>
145139
```
140+
141+
## Accessibility guidelines
142+
- [WCAG 2.1.1](https://www.w3.org/WAI/WCAG21/Understanding/keyboard)
143+
144+
### Resources
145+
- [Chrome Audit Rules, AX_FOCUS_02](https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_focus_02)
146+
- [Mozilla Developer Network - ARIA Techniques](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role#Keyboard_and_focus)
147+
- [Fundamental Keyboard Navigation Conventions](https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_generalnav)
148+
- [WAI-ARIA Authoring Practices Guide - Design Patterns and Widgets](https://www.w3.org/TR/wai-aria-practices-1.1/#aria_ex)

docs/rules/label-has-associated-control.md

+5
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,8 @@ function Foo(props) {
137137
Surname
138138
</label>
139139
```
140+
141+
## Accessibility guidelines
142+
- [WCAG 1.3.1](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships)
143+
- [WCAG 3.3.2](https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions)
144+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)

docs/rules/label-has-for.md

+5
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@ function Foo(props) {
112112
<input type="text" id="firstName" />
113113
<label>First Name</label>
114114
```
115+
116+
## Accessibility guidelines
117+
- [WCAG 1.3.1](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships)
118+
- [WCAG 3.3.2](https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions)
119+
- [WCAG 4.1.2](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value)

docs/rules/lang.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
The `lang` prop on the `<html>` element must be a valid IETF's BCP 47 language tag.
44

5-
#### References
6-
7-
1. [axe-core, valid-lang](https://dequeuniversity.com/rules/axe/3.2/valid-lang)
8-
2. [Language tags in HTML and XML](https://www.w3.org/International/articles/language-tags/)
9-
3. [IANA Language Subtag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry)
10-
115
## Rule details
126

137
This rule takes no arguments.
@@ -25,3 +19,11 @@ This rule takes no arguments.
2519
<html>
2620
<html lang="foo">
2721
```
22+
23+
## Accessibility guidelines
24+
- [WCAG 3.1.1](https://www.w3.org/WAI/WCAG21/Understanding/language-of-page)
25+
26+
### Resources
27+
- [axe-core, valid-lang](https://dequeuniversity.com/rules/axe/3.2/valid-lang)
28+
- [Language tags in HTML and XML](https://www.w3.org/International/articles/language-tags/)
29+
- [IANA Language Subtag Registry](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry)

0 commit comments

Comments
 (0)