File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -233,8 +233,9 @@ module.exports = {
233233 * @returns {Boolean } True if the prop is used, false if not.
234234 */
235235 function isPropUsed ( node , prop ) {
236- for ( let i = 0 , l = node . usedPropTypes . length ; i < l ; i ++ ) {
237- const usedProp = node . usedPropTypes [ i ] ;
236+ const usedPropTypes = node . usedPropTypes || [ ] ;
237+ for ( let i = 0 , l = usedPropTypes . length ; i < l ; i ++ ) {
238+ const usedProp = usedPropTypes [ i ] ;
238239 if (
239240 prop . type === 'shape' ||
240241 prop . name === '__ANY_KEY__' ||
@@ -896,7 +897,7 @@ module.exports = {
896897 }
897898 } ,
898899
899- JSXSpreadChild : function ( node ) {
900+ JSXSpreadAttribute : function ( node ) {
900901 const component = components . get ( utils . getParentComponent ( ) ) ;
901902 components . set ( component ? component . node : node , {
902903 ignorePropsValidation : true
@@ -958,6 +959,11 @@ module.exports = {
958959 stack . pop ( ) ;
959960 } ,
960961
962+ ReturnStatement : function ( node ) {
963+ const code = context . getSourceCode ( ) ;
964+ return { code, node} ;
965+ } ,
966+
961967 'Program:exit' : function ( ) {
962968 stack = null ;
963969 const list = components . list ( ) ;
Original file line number Diff line number Diff line change @@ -114,12 +114,8 @@ Components.prototype.list = function() {
114114 }
115115 const id = this . _getId ( this . _list [ j ] . node ) ;
116116 list [ j ] = this . _list [ j ] ;
117- if ( ! list [ j ] . usedPropTypes ) {
118- list [ j ] . usedPropTypes = [ ] ;
119- }
120-
121117 if ( usedPropTypes [ id ] ) {
122- list [ j ] . usedPropTypes = ( list [ j ] . usedPropTypes ) . concat ( usedPropTypes [ id ] ) ;
118+ list [ j ] . usedPropTypes = ( list [ j ] . usedPropTypes || [ ] ) . concat ( usedPropTypes [ id ] ) ;
123119 }
124120 }
125121 return list ;
You can’t perform that action at this time.
0 commit comments