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