File tree 1 file changed +17
-2
lines changed
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) {
81
81
) ;
82
82
}
83
83
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
+
84
95
/**
85
96
* Mark a prop type as used
86
97
* @param {ASTNode } node The AST node being marked.
@@ -107,9 +118,13 @@ module.exports = function(context) {
107
118
} ) ;
108
119
break ;
109
120
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
+ }
111
126
usedPropTypes . push ( {
112
- name : node . parent . parent . declarations [ 0 ] . id . properties [ i ] . key . name ,
127
+ name : properties [ i ] . key . name ,
113
128
node : node
114
129
} ) ;
115
130
}
You can’t perform that action at this time.
0 commit comments