@@ -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 : {
@@ -192,7 +193,7 @@ module.exports = {
192
193
}
193
194
if ( node . specifiers . length >= 1 ) {
194
195
const propTypesSpecifier = node . specifiers . find ( ( specifier ) => (
195
- specifier . imported && specifier . imported . name === 'PropTypes'
196
+ specifier . type === 'ImportSpecifier' && specifier . imported && specifier . imported . name === 'PropTypes'
196
197
) ) ;
197
198
if ( propTypesSpecifier ) {
198
199
propTypesPackageName = propTypesSpecifier . local . name ;
@@ -227,13 +228,17 @@ module.exports = {
227
228
) {
228
229
return ;
229
230
}
231
+ if ( node . parent . type !== 'AssignmentExpression' ) {
232
+ return ;
233
+ }
230
234
231
235
checkNode ( node . parent . right ) ;
232
236
} ,
233
237
234
238
CallExpression ( node ) {
235
239
if (
236
- node . callee . object
240
+ node . callee . type === 'MemberExpression'
241
+ && node . callee . object
237
242
&& ! isPropTypesPackage ( node . callee . object )
238
243
&& ! propsUtil . isPropTypesDeclaration ( node . callee )
239
244
) {
@@ -242,7 +247,8 @@ module.exports = {
242
247
243
248
if (
244
249
node . arguments . length > 0
245
- && ( node . callee . name === 'shape' || astUtil . getPropertyName ( node . callee ) === 'shape' )
250
+ && ( ( node . callee . type === 'Identifier' && node . callee . name === 'shape' ) || astUtil . getPropertyName ( node . callee ) === 'shape' )
251
+ && node . arguments [ 0 ] . type === 'ObjectExpression'
246
252
) {
247
253
checkProperties ( node . arguments [ 0 ] . properties ) ;
248
254
}
@@ -267,7 +273,7 @@ module.exports = {
267
273
268
274
ObjectExpression ( node ) {
269
275
node . properties . forEach ( ( property ) => {
270
- if ( ! property . key ) {
276
+ if ( property . type !== 'Property' ) {
271
277
return ;
272
278
}
273
279
0 commit comments