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: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,7 +123,7 @@ Enable the rules that you would like to use.
123
123
|||[react/boolean-prop-naming](docs/rules/boolean-prop-naming.md)| Enforces consistent naming for boolean props |
124
124
|||[react/button-has-type](docs/rules/button-has-type.md)| Forbid "button" element without an explicit "type" attribute |
125
125
|||[react/default-props-match-prop-types](docs/rules/default-props-match-prop-types.md)| Enforce all defaultProps are defined and not "required" in propTypes. |
126
-
|||[react/destructuring-assignment](docs/rules/destructuring-assignment.md)| Enforce consistent usage of destructuring assignment of props, state, and context |
126
+
||🔧|[react/destructuring-assignment](docs/rules/destructuring-assignment.md)| Enforce consistent usage of destructuring assignment of props, state, and context |
127
127
| ✔ ||[react/display-name](docs/rules/display-name.md)| Prevent missing displayName in a React component definition |
128
128
|||[react/forbid-component-props](docs/rules/forbid-component-props.md)| Forbid certain props on components |
129
129
|||[react/forbid-dom-props](docs/rules/forbid-dom-props.md)| Forbid certain props on DOM Nodes |
@@ -104,3 +104,33 @@ class Foo extends React.PureComponent {
104
104
bar =this.props.bar
105
105
}
106
106
```
107
+
108
+
### `destructureInSignature` (default: "ignore")
109
+
110
+
This option can be one of `always` or `ignore`. When configured with `always`, the rule will require props destructuring happens in the function signature.
111
+
112
+
Examples of **incorrect** code for `destructureInSignature: 'always'` :
113
+
114
+
```jsx
115
+
functionFoo(props) {
116
+
const {a} = props;
117
+
return<>{a}</>
118
+
}
119
+
```
120
+
121
+
Examples of **correct** code for `destructureInSignature: 'always'` :
122
+
123
+
```jsx
124
+
functionFoo({a}) {
125
+
return<>{a}</>
126
+
}
127
+
```
128
+
129
+
```jsx
130
+
// Ignores when props is used elsewhere
131
+
functionFoo(props) {
132
+
const {a} = props;
133
+
useProps(props); // NOTE: it is a bad practice to pass the props object anywhere else!
0 commit comments