Skip to content

Commit bfdc5cf

Browse files
committed
docs: automate docs with eslint-doc-generator
1 parent 0a73cf4 commit bfdc5cf

File tree

67 files changed

+308
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+308
-276
lines changed

.eslintrc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@
2828
"eslint-plugin/require-meta-type": "off",
2929
},
3030
},
31-
{
32-
"files": ["markdown.config.js"],
33-
"parserOptions": {
34-
"sourceType": "script",
35-
},
36-
"rules": {
37-
"no-console": 0,
38-
"import/no-extraneous-dependencies": [
39-
"error",
40-
{ "devDependencies": true },
41-
],
42-
"strict": ["error", "global"],
43-
},
44-
},
4531
{
4632
"files": ["__tests__/src/rules/*.js"],
4733
"extends": ["plugin:eslint-plugin/tests-recommended"],

.github/workflows/readme.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ jobs:
1212
name: 'nvm install lts/* && npm install'
1313
with:
1414
node-version: 'lts/*'
15+
- run: npm run build
1516
- run: npm run generate-list-of-rules:check

README.md

Lines changed: 57 additions & 92 deletions
Large diffs are not rendered by default.

docs/rules/accessible-emoji.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# [Deprecated] accessible-emoji
1+
# accessible-emoji
2+
3+
❌ This rule is deprecated.
4+
5+
<!-- end auto-generated rule header -->
26

37
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.
48

docs/rules/alt-text.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# alt-text
22

3+
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
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 screen reader 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>`.
48

59
## How to resolve
10+
611
### `<img>`
12+
713
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.
814

915
For images that are being used as icons for a button or control, the `alt` prop should be set to an empty string (`alt=""`).
@@ -12,20 +18,25 @@ For images that are being used as icons for a button or control, the `alt` prop
1218
<button>
1319
<img src="icon.png" alt="" />
1420
Save
21+
1522
</button>
1623
```
24+
1725
The content of an `alt` attribute is used to calculate the accessible label of an element, whereas the text content is used to produce a label for the element. For this reason, adding a label to an icon can produce a confusing or duplicated label on a control that already has appropriate text content.
1826

1927
### `<object>`
28+
2029
Add alternative text to all embedded `<object>` elements using either inner text, setting the `title` prop, or using the `aria-label` or `aria-labelledby` props.
2130

2231
### `<input type="image">`
32+
2333
All `<input type="image">` elements must have a non-empty `alt` prop set with a meaningful description of the image or have the `aria-label` or `aria-labelledby` props set.
2434

2535
### `<area>`
36+
2637
All clickable `<area>` elements within an image map have an `alt`, `aria-label` or `aria-labelledby` prop that describes the purpose of the link.
2738

28-
## Rule details
39+
## Rule options
2940

3041
This rule takes one optional object argument of type object:
3142

@@ -66,19 +77,22 @@ return (
6677
<header>
6778
<Image alt="Logo" src="logo.jpg" />
6879
</header>
80+
6981
);
7082
```
7183

7284
Note that passing props as spread attribute without explicitly the necessary accessibility props defined will cause this rule to fail. Explicitly pass down the set of props needed for rule to pass. Use `Image` component above as a reference for destructuring and applying the prop. **It is a good thing to explicitly pass props that you expect to be passed for self-documentation.** For example:
7385

7486
#### Bad
87+
7588
```jsx
7689
function Foo(props) {
7790
return <img {...props} />
7891
}
7992
```
8093

8194
#### Good
95+
8296
```jsx
8397
function Foo({ alt, ...props}) {
8498
return <img alt={alt} {...props} />
@@ -89,6 +103,7 @@ function Foo({ alt, ...props}) {
89103
function Foo(props) {
90104
const {
91105
alt,
106+
92107
...otherProps
93108
} = props;
94109

@@ -97,6 +112,7 @@ function Foo(props) {
97112
```
98113

99114
### Succeed
115+
100116
```jsx
101117
<img src="foo" alt="Foo eating a sandwich." />
102118
<img src="foo" alt={"Foo eating a sandwich."} />
@@ -111,6 +127,7 @@ function Foo(props) {
111127

112128
<area aria-label="foo" />
113129
<area aria-labelledby="id1" />
130+
114131
<area alt="This is descriptive!" />
115132

116133
<input type="image" alt="This is descriptive!" />
@@ -120,26 +137,31 @@ function Foo(props) {
120137
```
121138

122139
### Fail
140+
123141
```jsx
124142
<img src="foo" />
125143
<img {...props} />
126144
<img {...props} alt /> // Has no value
127145
<img {...props} alt={undefined} /> // Has no value
128146
<img {...props} alt={`${undefined}`} /> // Has no value
129147
<img src="foo" role="presentation" /> // Avoid ARIA if it can be achieved without
148+
130149
<img src="foo" role="none" /> // Avoid ARIA if it can be achieved without
131150

132151
<object {...props} />
133152

153+
134154
<area {...props} />
135155

136156
<input type="image" {...props} />
137157
```
138158

139159
## Accessibility guidelines
160+
140161
- [WCAG 1.1.1](https://www.w3.org/WAI/WCAG21/Understanding/non-text-content.html)
141162

142163
### Resources
164+
143165
- [axe-core, object-alt](https://dequeuniversity.com/rules/axe/3.2/object-alt)
144166
- [axe-core, image-alt](https://dequeuniversity.com/rules/axe/3.2/image-alt)
145167
- [axe-core, input-image-alt](https://dequeuniversity.com/rules/axe/3.2/input-image-alt)

docs/rules/anchor-ambiguous-text.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# anchor-ambiguous-text
22

3+
✅ This rule is _disabled_ in the `recommended` config.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Enforces `<a>` values are not exact matches for the phrases "click here", "here", "link", "a link", or "learn more". Screenreaders announce tags as links/interactive, but rely on values for context. Ambiguous anchor descriptions do not provide sufficient context for users.
48

5-
## Rule details
9+
## Rule options
610

711
This rule takes one optional object argument with the parameter `words`.
812

@@ -33,13 +37,15 @@ Note that this rule still disallows ambiguous `aria-label` or `alt` values.
3337
Note that this rule is case-insensitive, trims whitespace, and ignores certain punctuation (`[,.?¿!‽¡;:]`). It only looks for **exact matches**.
3438

3539
### Succeed
40+
3641
```jsx
3742
<a>read this tutorial</a> // passes since it is not one of the disallowed words
3843
<a>${here}</a> // this is valid since 'here' is a variable name
3944
<a aria-label="tutorial on using eslint-plugin-jsx-a11y">click here</a> // the aria-label supersedes the inner text
4045
```
4146

4247
### Fail
48+
4349
```jsx
4450
<a>here</a>
4551
<a>HERE</a>

docs/rules/anchor-has-content.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# anchor-has-content
22

3+
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
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.
48

5-
## Rule details
9+
## Rule options
610

711
This rule takes one optional object argument of type object:
812

docs/rules/anchor-is-valid.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# anchor-is-valid
22

3+
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
The HTML `<a>` element, with a valid `href` attribute, is formally defined as representing a **hyperlink**. That is, a link between one HTML document and another, or between one location inside an HTML document and another location inside the same document.
48

59
In fact, the interactive, underlined `<a>` element has become so synonymous with web navigation that this expectation has become entrenched inside browsers, assistive technologies such as screen readers and in how people generally expect the internet to behave. In short, anchors should navigate.
@@ -159,7 +163,7 @@ This button element can now also be used inline in text.
159163

160164
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.
161165

162-
## Rule details
166+
## Rule options
163167

164168
This rule takes one optional object argument of type object:
165169

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# aria-activedescendant-has-tabindex
22

3+
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
`aria-activedescendant` is used to manage focus within a [composite widget](https://www.w3.org/TR/wai-aria/#composite).
48
The element with the attribute `aria-activedescendant` retains the active document
59
focus; it indicates which of its child elements has secondary focus by assigning

docs/rules/aria-props.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# aria-props
22

3+
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
6+
37
Elements cannot use an invalid ARIA attribute. This will fail if it finds an `aria-*` property that is not listed in [WAI-ARIA States and Properties spec](https://www.w3.org/WAI/PF/aria-1.1/states_and_properties).
48

59
## Rule details

0 commit comments

Comments
 (0)