Skip to content

Commit 6d7a857

Browse files
bmishljharb
authored andcommitted
[Docs] automate docs with eslint-doc-generator
1 parent 0bdf95b commit 6d7a857

Some content is hidden

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

49 files changed

+322
-241
lines changed

.eslintrc

-14
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"],

README.md

+57-92
Large diffs are not rendered by default.

docs/rules/accessible-emoji.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# [Deprecated] accessible-emoji
1+
# jsx-a11y/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

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
# alt-text
1+
# jsx-a11y/alt-text
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# anchor-ambiguous-text
1+
# jsx-a11y/anchor-ambiguous-text
2+
3+
☑️ This rule is _disabled_ in the `recommended` config.
4+
5+
<!-- end auto-generated rule header -->
26

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# anchor-has-content
1+
# jsx-a11y/anchor-has-content
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# anchor-is-valid
1+
# jsx-a11y/anchor-is-valid
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

@@ -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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# aria-activedescendant-has-tabindex
1+
# jsx-a11y/aria-activedescendant-has-tabindex
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

docs/rules/aria-props.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# aria-props
1+
# jsx-a11y/aria-props
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

docs/rules/aria-proptypes.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# aria-proptypes
1+
# jsx-a11y/aria-proptypes
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

37
ARIA state and property values must be valid.
48

docs/rules/aria-role.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# aria-role
1+
# jsx-a11y/aria-role
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

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

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

docs/rules/aria-unsupported-elements.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# aria-unsupported-elements
1+
# jsx-a11y/aria-unsupported-elements
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

docs/rules/autocomplete-valid.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# autocomplete-valid
1+
# jsx-a11y/autocomplete-valid
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

37
Ensure the autocomplete attribute is correct and suitable for the form field it is used with.
48

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

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

@@ -22,7 +26,7 @@ This rule takes one optional object argument of type object:
2226
<input type="text" autocomplete="name" />
2327

2428
<!-- Good: MyInput is not listed in inputComponents -->
25-
<MyInput autocomplete="incorrect" />
29+
<MyInput autocomplete="incorrect" />
2630
```
2731

2832
### Fail
@@ -34,7 +38,7 @@ This rule takes one optional object argument of type object:
3438
<input type="email" autocomplete="url" />
3539

3640
<!-- Bad: MyInput is listed in inputComponents -->
37-
<MyInput autocomplete="incorrect" />
41+
<MyInput autocomplete="incorrect" />
3842
```
3943

4044
## Accessibility guidelines

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# click-events-have-key-events
1+
# jsx-a11y/click-events-have-key-events
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# control-has-associated-label
1+
# jsx-a11y/control-has-associated-label
2+
3+
💼 This rule is _disabled_ in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

37
Enforce that a control (an interactive element) has a text label.
48

@@ -50,7 +54,7 @@ You can configure the rule to be aware of your custom components. Refer to the R
5054
<CustomInput label="Surname" type="text" value={value} />
5155
```
5256

53-
## Rule details
57+
## Rule options
5458

5559
This rule takes one optional object argument of type object:
5660

docs/rules/heading-has-content.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# heading-has-content
1+
# jsx-a11y/heading-has-content
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

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

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

docs/rules/html-has-lang.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# html-has-lang
1+
# jsx-a11y/html-has-lang
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

37
<html> elements must have the lang prop. This rule is largely superseded by the [`lang` rule](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/lang.md).
48

docs/rules/iframe-has-title.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# iframe-has-title
1+
# jsx-a11y/iframe-has-title
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

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

docs/rules/img-redundant-alt.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# img-redundant-alt
1+
# jsx-a11y/img-redundant-alt
2+
3+
💼 This rule is enabled in the following configs: ☑️ `recommended`, 🔒 `strict`.
4+
5+
<!-- end auto-generated rule header -->
26

37
Enforce img alt attribute does not contain the word image, picture, or photo. Screenreaders already announce `img` elements as an image. There is no need to use words such as *image*, *photo*, and/or *picture*.
48

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

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

0 commit comments

Comments
 (0)