@@ -26,6 +26,7 @@ const messages = {
2626 forbiddenPropType : 'Prop type "{{target}}" is forbidden' ,
2727} ;
2828
29+ /** @type { import('eslint').Rule.RuleModule } */
2930module . exports = {
3031 meta : {
3132 docs : {
@@ -196,7 +197,7 @@ module.exports = {
196197 }
197198 if ( node . specifiers . length >= 1 ) {
198199 const propTypesSpecifier = node . specifiers . find ( ( specifier ) => (
199- specifier . imported && specifier . imported . name === 'PropTypes'
200+ specifier . type === 'ImportSpecifier' && specifier . imported && specifier . imported . name === 'PropTypes'
200201 ) ) ;
201202 if ( propTypesSpecifier ) {
202203 propTypesPackageName = propTypesSpecifier . local . name ;
@@ -231,13 +232,17 @@ module.exports = {
231232 ) {
232233 return ;
233234 }
235+ if ( node . parent . type !== 'AssignmentExpression' ) {
236+ return ;
237+ }
234238
235239 checkNode ( node . parent . right ) ;
236240 } ,
237241
238242 CallExpression ( node ) {
239243 if (
240- node . callee . object
244+ node . callee . type === 'MemberExpression'
245+ && node . callee . object
241246 && ! isPropTypesPackage ( node . callee . object )
242247 && ! propsUtil . isPropTypesDeclaration ( node . callee )
243248 ) {
@@ -246,7 +251,8 @@ module.exports = {
246251
247252 if (
248253 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'
250256 ) {
251257 checkProperties ( node . arguments [ 0 ] . properties ) ;
252258 }
@@ -271,7 +277,7 @@ module.exports = {
271277
272278 ObjectExpression ( node ) {
273279 node . properties . forEach ( ( property ) => {
274- if ( ! property . key ) {
280+ if ( property . type !== 'Property' ) {
275281 return ;
276282 }
277283
0 commit comments