File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,17 @@ module.exports = function(context) {
8181 ) ;
8282 }
8383
84+ /**
85+ * Checks if the prop is declared
86+ * @param {String } name Name of the prop to check.
87+ * @param {Object } component The component to process
88+ * @returns {Boolean } True if the prop is declared, false if not.
89+ */
90+ function hasSpreadOperator ( node ) {
91+ var tokens = context . getTokens ( node ) ;
92+ return tokens . length && tokens [ 0 ] . value === '...' ;
93+ }
94+
8495 /**
8596 * Mark a prop type as used
8697 * @param {ASTNode } node The AST node being marked.
@@ -107,9 +118,13 @@ module.exports = function(context) {
107118 } ) ;
108119 break ;
109120 case 'destructuring' :
110- for ( var i = 0 , j = node . parent . parent . declarations [ 0 ] . id . properties . length ; i < j ; i ++ ) {
121+ var properties = node . parent . parent . declarations [ 0 ] . id . properties ;
122+ for ( var i = 0 , j = properties . length ; i < j ; i ++ ) {
123+ if ( hasSpreadOperator ( properties [ i ] ) ) {
124+ continue ;
125+ }
111126 usedPropTypes . push ( {
112- name : node . parent . parent . declarations [ 0 ] . id . properties [ i ] . key . name ,
127+ name : properties [ i ] . key . name ,
113128 node : node
114129 } ) ;
115130 }
You can’t perform that action at this time.
0 commit comments