@@ -115,15 +115,28 @@ module.exports = {
115
115
function testAttributeForDeprecation ( attribute , deprecatedPropList , componentName ) {
116
116
let wasFound = false ;
117
117
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
+ ) ;
119
125
} 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 ( ) ) ;
121
131
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
+ }
127
140
}
128
141
}
129
142
return wasFound ;
@@ -160,12 +173,13 @@ module.exports = {
160
173
/* handle required props */
161
174
let foundAttribute = false ;
162
175
attributes . forEach ( attribute => {
163
- foundAttribute = foundAttribute || testAttributeForDeprecation ( attribute , requiredPropList , componentName ) ;
176
+ foundAttribute =
177
+ foundAttribute || testAttributeForDeprecation ( attribute , requiredPropList , componentName ) ;
164
178
} ) ;
165
-
166
- if ( ! foundAttribute && requiredPropList [ 0 ] ) {
179
+
180
+ if ( ! foundAttribute && requiredPropList [ 0 ] ) {
167
181
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 } ) ;
169
183
}
170
184
} ) ;
171
185
}
0 commit comments