Skip to content

Commit

Permalink
JSXSpreadAttribute instead of JSXSpreadChild
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Suvorova authored and Diana Suvorova committed Jul 15, 2017
1 parent b7d8763 commit a8f2fdb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 9 additions & 3 deletions lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ module.exports = {
* @returns {Boolean} True if the prop is used, false if not.
*/
function isPropUsed(node, prop) {
for (let i = 0, l = node.usedPropTypes.length; i < l; i++) {
const usedProp = node.usedPropTypes[i];
const usedPropTypes = node.usedPropTypes || [];
for (let i = 0, l = usedPropTypes.length; i < l; i++) {
const usedProp = usedPropTypes[i];
if (
prop.type === 'shape' ||
prop.name === '__ANY_KEY__' ||
Expand Down Expand Up @@ -896,7 +897,7 @@ module.exports = {
}
},

JSXSpreadChild: function(node) {
JSXSpreadAttribute: function(node) {
const component = components.get(utils.getParentComponent());
components.set(component ? component.node : node, {
ignorePropsValidation: true
Expand Down Expand Up @@ -958,6 +959,11 @@ module.exports = {
stack.pop();
},

ReturnStatement: function (node) {
const code = context.getSourceCode();
return {code, node};
},

'Program:exit': function() {
stack = null;
const list = components.list();
Expand Down
6 changes: 1 addition & 5 deletions lib/util/Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,8 @@ Components.prototype.list = function() {
}
const id = this._getId(this._list[j].node);
list[j] = this._list[j];
if (!list[j].usedPropTypes) {
list[j].usedPropTypes = [];
}

if (usedPropTypes[id]) {
list[j].usedPropTypes = (list[j].usedPropTypes).concat(usedPropTypes[id]);
list[j].usedPropTypes = (list[j].usedPropTypes || []).concat(usedPropTypes[id]);
}
}
return list;
Expand Down

0 comments on commit a8f2fdb

Please sign in to comment.