File tree Expand file tree Collapse file tree 3 files changed +7
-23
lines changed Expand file tree Collapse file tree 3 files changed +7
-23
lines changed Original file line number Diff line number Diff line change @@ -136,9 +136,6 @@ module.exports = {
136
136
checkValue ( node , propValue ) ;
137
137
} ,
138
138
CallExpression ( node ) {
139
- if ( node . type !== 'CallExpression' ) {
140
- return ;
141
- }
142
139
if ( ! isCreateElement ( node , context ) || node . arguments . length < 1 ) {
143
140
return ;
144
141
}
Original file line number Diff line number Diff line change @@ -236,6 +236,7 @@ module.exports = {
236
236
237
237
VariableDeclarator ( node ) {
238
238
const reactModuleName = getReactModuleName ( node ) ;
239
+ const objectPatternNodeId = node . id . type === 'ObjectPattern' ? node . id : undefined ;
239
240
const isRequire = node . init . type === 'CallExpression'
240
241
&& node . init . callee && node . init . callee . type === 'Identifier'
241
242
&& node . init . callee . name === 'require' ;
@@ -244,18 +245,15 @@ module.exports = {
244
245
&& node . init . arguments . length
245
246
&& node . init . arguments [ 0 ] . type === 'Literal'
246
247
&& typeof MODULES [ node . init . arguments [ 0 ] . value ] !== 'undefined' ;
247
- const isDestructuring = node . id && node . id . type === 'ObjectPattern' ;
248
248
249
249
if (
250
- ! ( isDestructuring && reactModuleName )
251
- && ! ( isDestructuring && isRequire && isReactRequire )
250
+ ! ( objectPatternNodeId && reactModuleName )
251
+ && ! ( objectPatternNodeId && isRequire && isReactRequire )
252
252
) {
253
253
return ;
254
254
}
255
- if ( node . id . type !== 'ObjectPattern' ) {
256
- return ;
257
- }
258
- node . id . properties . filter ( ( p ) => p . type !== 'RestElement' && p . key ) . forEach ( ( property ) => {
255
+
256
+ objectPatternNodeId . properties . forEach ( ( property ) => {
259
257
if ( property . type !== 'Property' || property . key . type !== 'Identifier' ) {
260
258
return ;
261
259
}
Original file line number Diff line number Diff line change @@ -105,10 +105,6 @@ module.exports = {
105
105
} ,
106
106
107
107
CallExpression ( node ) {
108
- if ( node . callee . type !== 'MemberExpression' && node . callee . type !== 'Identifier' ) {
109
- return ;
110
- }
111
-
112
108
if ( ! isCreateElement ( node , context ) ) {
113
109
return ;
114
110
}
@@ -120,11 +116,7 @@ module.exports = {
120
116
return ;
121
117
}
122
118
123
- if ( args [ 0 ] . type !== 'Literal' ) {
124
- return ;
125
- }
126
-
127
- const elementName = args [ 0 ] . value ;
119
+ const elementName = args [ 0 ] . type === 'Literal' ? args [ 0 ] . value : undefined ;
128
120
129
121
if ( ! isVoidDOMElement ( elementName ) ) {
130
122
// e.g. React.createElement('div');
@@ -149,10 +141,7 @@ module.exports = {
149
141
const props = args [ 1 ] . properties ;
150
142
151
143
const hasChildrenPropOrDanger = props . some ( ( prop ) => {
152
- if ( prop . type !== 'Property' ) {
153
- return false ;
154
- }
155
- if ( ! prop . key || prop . key . type !== 'Identifier' ) {
144
+ if ( prop . type !== 'Property' || prop . key . type !== 'Identifier' ) {
156
145
return false ;
157
146
}
158
147
You can’t perform that action at this time.
0 commit comments