Skip to content

Commit 94eb949

Browse files
committed
Add documentation for jsx-no-duplicate-props
1 parent 1ca6062 commit 94eb949

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Finally, enable all of the rules that you would like to use.
4444
"rules": {
4545
"react/display-name": 1,
4646
"react/jsx-boolean-value": 1,
47+
"react/jsx-no-duplicate-props": 1,
4748
"react/jsx-no-undef": 1,
4849
"react/jsx-quotes": 1,
4950
"react/jsx-sort-prop-types": 1,
@@ -70,6 +71,7 @@ Finally, enable all of the rules that you would like to use.
7071
* [display-name](docs/rules/display-name.md): Prevent missing displayName in a React component definition
7172
* [jsx-boolean-value](docs/rules/jsx-boolean-value.md): Enforce boolean attributes notation in JSX
7273
* [jsx-curly-spacing](docs/rules/jsx-curly-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes
74+
* [jsx-no-duplicate-props](docs/rules/jsx-no-duplicate-props.md): Prevent duplicate props in JSX
7375
* [jsx-no-undef](docs/rules/jsx-no-undef.md): Disallow undeclared variables in JSX
7476
* [jsx-quotes](docs/rules/jsx-quotes.md): Enforce quote style for JSX attributes
7577
* [jsx-sort-prop-types](docs/rules/jsx-sort-prop-types.md): Enforce propTypes declarations alphabetical sorting

docs/rules/jsx-no-duplicate-props.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Prevent duplicate properties in JSX (jsx-no-duplicate-props)
2+
3+
Creating JSX elements with duplicate props can cause unexpected behavior in your application.
4+
5+
## Rule Details
6+
7+
The following patterns are considered warnings:
8+
9+
```js
10+
<Hello name="John" name="John" />;
11+
```
12+
13+
The following patterns are not considered warnings:
14+
15+
```js
16+
<Hello firstname="John" lastname="Doe" />;
17+
```
18+
19+
## Rule Options
20+
21+
```js
22+
...
23+
"jsx-no-duplicate-props": [<enabled>, { "ignoreCase": <boolean> }]
24+
...
25+
```
26+
27+
### `ignoreCase`
28+
29+
When `true` the rule ignores the case of the props. Default to `false`.
30+
31+
## When Not To Use It
32+
33+
If you are not using JSX then you can disable this rule.

0 commit comments

Comments
 (0)