@@ -26,6 +26,7 @@ const messages = {
26
26
forbiddenPropType : 'Prop type "{{target}}" is forbidden' ,
27
27
} ;
28
28
29
+ /** @type { import('eslint').Rule.RuleModule } */
29
30
module . exports = {
30
31
meta : {
31
32
docs : {
@@ -196,7 +197,7 @@ module.exports = {
196
197
}
197
198
if ( node . specifiers . length >= 1 ) {
198
199
const propTypesSpecifier = node . specifiers . find ( ( specifier ) => (
199
- specifier . imported && specifier . imported . name === 'PropTypes'
200
+ specifier . type === 'ImportSpecifier' && specifier . imported && specifier . imported . name === 'PropTypes'
200
201
) ) ;
201
202
if ( propTypesSpecifier ) {
202
203
propTypesPackageName = propTypesSpecifier . local . name ;
@@ -231,13 +232,17 @@ module.exports = {
231
232
) {
232
233
return ;
233
234
}
235
+ if ( node . parent . type !== 'AssignmentExpression' ) {
236
+ return ;
237
+ }
234
238
235
239
checkNode ( node . parent . right ) ;
236
240
} ,
237
241
238
242
CallExpression ( node ) {
239
243
if (
240
- node . callee . object
244
+ node . callee . type === 'MemberExpression'
245
+ && node . callee . object
241
246
&& ! isPropTypesPackage ( node . callee . object )
242
247
&& ! propsUtil . isPropTypesDeclaration ( node . callee )
243
248
) {
@@ -246,7 +251,8 @@ module.exports = {
246
251
247
252
if (
248
253
node . arguments . length > 0
249
- && ( node . callee . name === 'shape' || astUtil . getPropertyName ( node . callee ) === 'shape' )
254
+ && ( ( node . callee . type === 'Identifier' && node . callee . name === 'shape' ) || astUtil . getPropertyName ( node . callee ) === 'shape' )
255
+ && node . arguments [ 0 ] . type === 'ObjectExpression'
250
256
) {
251
257
checkProperties ( node . arguments [ 0 ] . properties ) ;
252
258
}
@@ -271,7 +277,7 @@ module.exports = {
271
277
272
278
ObjectExpression ( node ) {
273
279
node . properties . forEach ( ( property ) => {
274
- if ( ! property . key ) {
280
+ if ( property . type !== 'Property' ) {
275
281
return ;
276
282
}
277
283
0 commit comments