You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* [new] - Implement heading-has-content rule
* [fix] - Handle undefined case in heading-has-content
* [new] - Implement lang rule
Enforces valid language & country code for `lang` attribute on `<html>`
element
* [new] - Implement html-has-lang rule
* [fix] - Name fix on html-has-lang test
* [new] - Implement scope rule
Enforce `scope` prop is only used on `<th>` elements.
* [new] - Implement no-marquee rule.
* [docs] - Add new rules to README
* [fix] - Don't test custom components in rule `scope`
* [fix] - Only test for low-level html DOM element in html-has-lang and lang rules.
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,17 +74,22 @@ Then configure the rules you want to use under the rules section.
74
74
-[aria-proptypes](docs/rules/aria-proptypes.md): Enforce ARIA state and property values are valid.
75
75
-[aria-role](docs/rules/aria-role.md): Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role.
76
76
-[aria-unsupported-elements](docs/rules/aria-unsupported-elements.md): Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
77
+
-[heading-has-content](docs/rules/heading-has-content.md): Enforce heading (`h1`, `h2`, etc) elements contain accessible content.
77
78
-[href-no-hash](docs/rules/href-no-hash.md): Enforce an anchor element's `href` prop value is not just `#`.
79
+
-[html-has-lang](docs/rules/html-has-lang.md): Enforce `<html>` element has `lang` prop.
78
80
-[img-has-alt](docs/rules/img-has-alt.md): Enforce that `<img>` JSX elements use the `alt` prop.
79
81
-[img-redundant-alt](docs/rules/img-redundant-alt.md): Enforce `<img>` alt prop does not contain the word "image", "picture", or "photo".
80
82
-[label-has-for](docs/rules/label-has-for.md): Enforce that `<label>` elements have the `htmlFor` prop.
83
+
-[lang](docs/rules/lang.md): Enforce lang attribute has a valid value.
81
84
-[mouse-events-have-key-events](docs/rules/mouse-events-have-key-events.md): Enforce that `onMouseOver`/`onMouseOut` are accompanied by `onFocus`/`onBlur` for keyboard-only users.
82
85
-[no-access-key](docs/rules/no-access-key.md): Enforce that the `accessKey` prop is not used on any element to avoid complications with keyboard commands used by a screenreader.
86
+
-[no-marquee](docs/rules/no-marquee.md): Enforce `<marquee>` elements are not used.
83
87
-[no-onchange](docs/rules/no-onchange.md): Enforce that `onBlur` is used instead of `onChange`.
84
88
-[onclick-has-focus](docs/rules/onclick-has-focus.md): Enforce that elements with `onClick` handlers must be focusable.
85
89
-[onclick-has-role](docs/rules/onclick-has-role.md): Enforce that non-interactive, visible elements (such as `<div>`) that have click handlers use the role attribute.
86
90
-[role-has-required-aria-props](docs/rules/role-has-required-aria-props.md): Enforce that elements with ARIA roles must have all required attributes for that role.
87
91
-[role-supports-aria-props](docs/rules/role-supports-aria-props.md): Enforce that elements with explicit or implicit roles defined contain only `aria-*` properties supported by that `role`.
92
+
-[scope](docs/rules/scope.md): Enforce `scope` prop is only used on `<th>` elements.
88
93
-[tabindex-no-positive](docs/rules/tabindex-no-positive.md): Enforce `tabIndex` value is not greater than zero.
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.
This rule takes one optional argument of type string or array of strings. These strings determine which JSX elements should be checked including `h1`, `h2`, `h3`, `h4`, `h5`, and `h6` by default. This is a good use case when you have a wrapper component that simply renders a heading element (like in React):
11
+
12
+
```js
13
+
// Header.js
14
+
constHeader=props=> {
15
+
return (
16
+
<h1 {...props}>{ props.children }</h1>
17
+
);
18
+
}
19
+
20
+
...
21
+
22
+
// CreateAccount.js (for example)
23
+
...
24
+
return (
25
+
<Header>Create Account</Header>
26
+
);
27
+
```
28
+
29
+
To tell this plugin to also check your `Header` element, specify this in your `.eslintrc` file:
30
+
31
+
```json
32
+
{
33
+
"rules": {
34
+
"jsx-a11y/heading-has-content": [ 2, "Header" ], // OR
0 commit comments