@@ -115,15 +115,28 @@ module.exports = {
115115 function testAttributeForDeprecation ( attribute , deprecatedPropList , componentName ) {
116116 let wasFound = false ;
117117 if ( attribute . type === 'JSXAttribute' ) {
118- wasFound = checkPropDeprecation ( attribute , attribute . name , attribute . name . name , deprecatedPropList , componentName ) ;
118+ wasFound = checkPropDeprecation (
119+ attribute ,
120+ attribute . name ,
121+ attribute . name . name ,
122+ deprecatedPropList ,
123+ componentName
124+ ) ;
119125 } else if ( attribute . type === 'JSXSpreadAttribute' ) {
120- const spreadSource = findValueNodeOfIdentifier ( attribute . argument . name , context . getScope ( ) ) ;
126+ const identifierName =
127+ _ . get ( attribute , 'argument.name' ) ||
128+ _ . get ( attribute , 'argument.callee.name' ) ||
129+ _ . get ( attribute , 'argument.property.name' ) ;
130+ const spreadSource = findValueNodeOfIdentifier ( identifierName , context . getScope ( ) ) ;
121131 if ( spreadSource ) {
122- _ . forEach ( spreadSource . properties , property => {
123- const key = _ . get ( property , 'key' ) ;
124- const propName = _ . get ( property , 'key.name' ) ;
125- wasFound = checkPropDeprecation ( key , key , propName , deprecatedPropList , componentName ) ;
126- } ) ;
132+ const properties = _ . get ( spreadSource , 'properties' ) || _ . get ( spreadSource , 'body.properties' ) ;
133+ if ( properties ) {
134+ _ . forEach ( properties , property => {
135+ const key = _ . get ( property , 'key' ) ;
136+ const propName = _ . get ( property , 'key.name' ) ;
137+ wasFound = checkPropDeprecation ( key , key , propName , deprecatedPropList , componentName ) ;
138+ } ) ;
139+ }
127140 }
128141 }
129142 return wasFound ;
@@ -160,12 +173,13 @@ module.exports = {
160173 /* handle required props */
161174 let foundAttribute = false ;
162175 attributes . forEach ( attribute => {
163- foundAttribute = foundAttribute || testAttributeForDeprecation ( attribute , requiredPropList , componentName ) ;
176+ foundAttribute =
177+ foundAttribute || testAttributeForDeprecation ( attribute , requiredPropList , componentName ) ;
164178 } ) ;
165-
166- if ( ! foundAttribute && requiredPropList [ 0 ] ) {
179+
180+ if ( ! foundAttribute && requiredPropList [ 0 ] ) {
167181 const prop = requiredPropList [ 0 ] ;
168- reportRequiredProps ( { node, name : componentName , prop : prop . prop , message : prop . message } )
182+ reportRequiredProps ( { node, name : componentName , prop : prop . prop , message : prop . message } ) ;
169183 }
170184 } ) ;
171185 }
0 commit comments