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
Copy file name to clipboardExpand all lines: docs/rules/jsx-sort-props.md
+22-1Lines changed: 22 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,8 @@ The following patterns are considered okay and do not cause warnings:
28
28
"shorthandFirst":<boolean>,
29
29
"shorthandLast":<boolean>,
30
30
"ignoreCase":<boolean>,
31
-
"noSortAlphabetically":<boolean>
31
+
"noSortAlphabetically":<boolean>,
32
+
"reservedFirst":<boolean>|<array<string>>,
32
33
}]
33
34
...
34
35
```
@@ -75,6 +76,26 @@ When `true`, alphabetical order is not enforced:
75
76
<Hello tel={5555555} name="John"/>
76
77
```
77
78
79
+
### `reservedFirst`
80
+
81
+
This can be a boolean or an array option.
82
+
83
+
When `reservedFirst` is defined, React reserved props (`children`, `dangerouslySetInnerHTML` - **only for DOM components**, `key`, and `ref`) must be listed before all other props, but still respecting the alphabetical order:
If given as an array, the array's values will override the default list of reserved props. **Note**: the values in the array may only be a **subset** of React reserved props.
92
+
93
+
With `reservedFirst: [2, ["key"]]`, the following will not warn:
94
+
95
+
```jsx
96
+
<Hello key={'uuid'} name="John" ref="ref"/>
97
+
```
98
+
78
99
## When not to use
79
100
80
101
This rule is a formatting preference and not following it won't negatively affect the quality of your code. If alphabetizing props isn't a part of your coding standards, then you can leave this rule off.
0 commit comments