@@ -133,39 +133,33 @@ module.exports = {
133
133
* @param {Object[] } propTypes List of propTypes to check `isRequired`.
134
134
*/
135
135
function reportFnPropsWithoutInit ( props , propTypes ) {
136
- switch ( props . type ) {
137
- case 'Identifier' : {
138
- const hasOptionalProp = values ( propTypes ) . some (
139
- ( propType ) => ! propType . isRequired
140
- ) ;
141
- if ( hasOptionalProp ) {
142
- report ( context , messages . destructureInSignature , 'destructureInSignature' , {
143
- node : props ,
144
- } ) ;
145
- }
146
- break ;
147
- }
148
- case 'ObjectPattern' : {
149
- props . properties . filter ( ( prop ) => {
150
- if ( prop . type === 'RestElement'
151
- || prop . type === 'ExperimentalRestProperty'
152
- ) {
153
- return false ;
154
- }
155
- const propType = propTypes [ prop . key . name ] ;
156
- if ( ! propType || propType . isRequired ) {
157
- return false ;
158
- }
159
- return prop . value . type !== 'AssignmentPattern' ;
160
- } ) . forEach ( ( prop ) => {
161
- report ( context , messages . shouldAssignObjectDefault , 'shouldAssignObjectDefault' , {
162
- node : prop ,
163
- data : { name : prop . key . name } ,
164
- } ) ;
136
+ if ( props . type === 'Identifier' ) {
137
+ const hasOptionalProp = values ( propTypes ) . some (
138
+ ( propType ) => ! propType . isRequired
139
+ ) ;
140
+ if ( hasOptionalProp ) {
141
+ report ( context , messages . destructureInSignature , 'destructureInSignature' , {
142
+ node : props ,
165
143
} ) ;
166
- break ;
167
144
}
168
- default :
145
+ } else if ( props . type === 'ObjectPattern' ) {
146
+ props . properties . filter ( ( prop ) => {
147
+ if ( prop . type === 'RestElement'
148
+ || prop . type === 'ExperimentalRestProperty'
149
+ ) {
150
+ return false ;
151
+ }
152
+ const propType = propTypes [ prop . key . name ] ;
153
+ if ( ! propType || propType . isRequired ) {
154
+ return false ;
155
+ }
156
+ return prop . value . type !== 'AssignmentPattern' ;
157
+ } ) . forEach ( ( prop ) => {
158
+ report ( context , messages . shouldAssignObjectDefault , 'shouldAssignObjectDefault' , {
159
+ node : prop ,
160
+ data : { name : prop . key . name } ,
161
+ } ) ;
162
+ } ) ;
169
163
}
170
164
}
171
165
reportFnPropsWithoutInit ( componentNode . params [ 0 ] , declaredPropTypes ) ;
0 commit comments