@@ -70,10 +70,9 @@ module.exports = {
7070 // Used to track the type annotations in scope.
7171 // Necessary because babel's scopes do not track type annotations.
7272 const classExpressions = [ ] ;
73- const defaults = { skipShapeProps : true , customValidators : [ ] } ;
73+ const defaults = { customValidators : [ ] } ;
7474 const configuration = Object . assign ( { } , defaults , context . options [ 0 ] || { } ) ;
7575 const customValidators = configuration . customValidators ;
76- const skipShapeProps = configuration . skipShapeProps ;
7776 const sourceCode = context . getSourceCode ( ) ;
7877 const propWrapperFunctions = new Set ( context . settings . propWrapperFunctions || [ ] ) ;
7978
@@ -149,9 +148,6 @@ module.exports = {
149148 }
150149 return { } ;
151150 case 'ObjectTypeAnnotation' :
152- if ( skipShapeProps ) {
153- return { } ;
154- }
155151 let containsObjectTypeSpread = false ;
156152 const shapeTypeDefinition = {
157153 type : 'shape' ,
@@ -183,13 +179,14 @@ module.exports = {
183179 for ( let i = 0 , j = annotation . types . length ; i < j ; i ++ ) {
184180 const type = buildTypeAnnotationDeclarationTypes ( annotation . types [ i ] , parentName , seen ) ;
185181 // keep only complex type
186- if ( Object . keys ( type ) . length > 0 ) {
182+ if ( type . type ) {
187183 if ( type . children === true ) {
188184 // every child is accepted for one type, abort type analysis
189185 unionTypeDefinition . children = true ;
190186 return unionTypeDefinition ;
191187 }
192188 }
189+ // type.node = annotation.types[i];
193190
194191 unionTypeDefinition . children . push ( type ) ;
195192 }
@@ -200,10 +197,14 @@ module.exports = {
200197 return unionTypeDefinition ;
201198 case 'ArrayTypeAnnotation' :
202199 const fullName = [ parentName , '*' ] . join ( '.' ) ;
200+ const child = buildTypeAnnotationDeclarationTypes ( annotation . elementType , fullName , seen ) ;
201+ child . fullName = fullName ;
202+ child . name = '__ANY_KEY__' ;
203+ child . node = annotation ;
203204 return {
204205 type : 'object' ,
205206 children : {
206- __ANY_KEY__ : buildTypeAnnotationDeclarationTypes ( annotation . elementType , fullName , seen )
207+ __ANY_KEY__ : child
207208 }
208209 } ;
209210 default :
@@ -316,10 +317,6 @@ module.exports = {
316317 const argument = value . arguments [ 0 ] ;
317318 switch ( callName ) {
318319 case 'shape' :
319- if ( skipShapeProps ) {
320- return { } ;
321- }
322-
323320 if ( argument . type !== 'ObjectExpression' ) {
324321 // Invalid proptype or cannot analyse statically
325322 return { } ;
@@ -365,7 +362,7 @@ module.exports = {
365362 for ( let i = 0 , j = argument . elements . length ; i < j ; i ++ ) {
366363 const type = buildReactDeclarationTypes ( argument . elements [ i ] , parentName ) ;
367364 // keep only complex type
368- if ( Object . keys ( type ) . length > 0 ) {
365+ if ( type . type ) {
369366 if ( type . children === true ) {
370367 // every child is accepted for one type, abort type analysis
371368 unionTypeDefinition . children = true ;
@@ -417,6 +414,7 @@ module.exports = {
417414 case 'ObjectExpression' :
418415 iterateProperties ( context , propTypes . properties , ( key , value ) => {
419416 if ( ! value ) {
417+ /* eslint-disable */
420418 ignorePropsValidation = true ;
421419 return ;
422420 }
@@ -453,12 +451,27 @@ module.exports = {
453451 propTypes . parent . right ,
454452 propTypes . parent . left . object . property . name
455453 ) ;
454+
456455 types . name = propTypes . property . name ;
457- types . node = propTypes . property ;
458456 types . fullName = propTypes . property . name ;
457+ types . node = propTypes . property ;
459458 curDeclaredPropTypes [ propTypes . property . name ] = types ;
460459 } else {
461- ignorePropsValidation = true ;
460+ let isUsedInPropTypes = false ;
461+ let n = propTypes ;
462+ while ( n ) {
463+ if ( n . type === 'AssignmentExpression' && propsUtil . isPropTypesDeclaration ( n . left ) ||
464+ ( n . type === 'ClassProperty' || n . type === 'Property' ) && propsUtil . isPropTypesDeclaration ( n ) ) {
465+ // Found a propType used inside of another propType. This is not considered usage, we'll still validate
466+ // this component.
467+ isUsedInPropTypes = true ;
468+ break ;
469+ }
470+ n = n . parent ;
471+ }
472+ if ( ! isUsedInPropTypes ) {
473+ ignorePropsValidation = true ;
474+ }
462475 }
463476 break ;
464477 case 'Identifier' :
0 commit comments