Skip to content

Commit 9ea7449

Browse files
Nokel81ljharb
andcommitted
[New] add no-invalid-html-attribute rule
Co-authored-by: Sebastian Malton <[email protected]> Co-authored-by: Jordan Harband <[email protected]>
1 parent abc6f3e commit 9ea7449

File tree

6 files changed

+1648
-0
lines changed

6 files changed

+1648
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
99
* [`no-unused-class-component-methods`]: Handle unused class component methods ([#2166][] @jakeleventhal @pawelnvk)
1010
* add [`no-arrow-function-lifecycle`] ([#1980][] @ngtan)
1111
* add support for `@typescript-eslint/parser` v5 (@ljharb)
12+
* [`no-invalid-html-attribute`]: add rule ([#2863][] @Nokel81)
1213

1314
### Fixed
1415
* `propTypes`: add `VoidFunctionComponent` to react generic list ([#3092][] @vedadeepta)
@@ -30,6 +31,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
3031
[#3110]: https://github.com/yannickcr/eslint-plugin-react/pull/3110
3132
[#3102]: https://github.com/yannickcr/eslint-plugin-react/issue/3102
3233
[#3092]: https://github.com/yannickcr/eslint-plugin-react/pull/3092
34+
[#2863]: https://github.com/yannickcr/eslint-plugin-react/pull/2863
3335
[#2166]: https://github.com/yannickcr/eslint-plugin-react/pull/2166
3436
[#1980]: https://github.com/yannickcr/eslint-plugin-react/pull/1980
3537

@@ -3533,3 +3535,4 @@ If you're still not using React 15 you can keep the old behavior by setting the
35333535
[`style-prop-object`]: docs/rules/style-prop-object.md
35343536
[`void-dom-elements-no-children`]: docs/rules/void-dom-elements-no-children.md
35353537
[`wrap-multilines`]: docs/rules/jsx-wrap-multilines.md
3538+
[`no-invalid-html-attribute`]: docs/rules/no-invalid-html-attribute.md

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ Enable the rules that you would like to use.
144144
| | | [react/no-did-update-set-state](docs/rules/no-did-update-set-state.md) | Prevent usage of setState in componentDidUpdate |
145145
|| | [react/no-direct-mutation-state](docs/rules/no-direct-mutation-state.md) | Prevent direct mutation of this.state |
146146
|| | [react/no-find-dom-node](docs/rules/no-find-dom-node.md) | Prevent usage of findDOMNode |
147+
| | 🔧 | [react/no-invalid-html-attribute](docs/rules/no-invalid-html-attribute.md) | Forbid attribute with an invalid values` |
147148
|| | [react/no-is-mounted](docs/rules/no-is-mounted.md) | Prevent usage of isMounted |
148149
| | | [react/no-multi-comp](docs/rules/no-multi-comp.md) | Prevent multiple component definition per file |
149150
| | | [react/no-namespace](docs/rules/no-namespace.md) | Enforce that namespaces are not used in React elements |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Prevent usage of invalid attributes (react/no-invalid-html-attribute)
2+
3+
Some HTML elements have a specific set of valid values for some attributes.
4+
For instance the elements: `a`, `area`, `link`, or `form` all have an attribute called `rel`.
5+
There is a fixed list of values that have any meaning for this attribute on these tags (see [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel)).
6+
To help with minimizing confusion while reading code, only the appropriate values should be on each attribute.
7+
8+
## Rule Details
9+
10+
This rule aims to remove invalid attribute values.
11+
12+
## Rule Options
13+
The options is a list of attributes to check. Defaults to `["rel"]`.
14+
15+
## When Not To Use It
16+
17+
When you don't want to enforce attribute value correctness.

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const allRules = {
5454
'jsx-uses-react': require('./lib/rules/jsx-uses-react'),
5555
'jsx-uses-vars': require('./lib/rules/jsx-uses-vars'),
5656
'jsx-wrap-multilines': require('./lib/rules/jsx-wrap-multilines'),
57+
'no-invalid-html-attribute': require('./lib/rules/no-invalid-html-attribute'),
5758
'no-access-state-in-setstate': require('./lib/rules/no-access-state-in-setstate'),
5859
'no-adjacent-inline-elements': require('./lib/rules/no-adjacent-inline-elements'),
5960
'no-array-index-key': require('./lib/rules/no-array-index-key'),

0 commit comments

Comments
 (0)