Skip to content

Commit 5d9d6f2

Browse files
committed
fix: add ExperimentalRestProperty support
Extends ObjectPattern to handle case where properties has a ExperimentalRestProperty, and uses the name property from argument instead of key.
1 parent b457375 commit 5d9d6f2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/rules/no-unused-prop-types.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ const propsUsedInRedux = function (context) {
6666
const usedInReactRedux = context.getAncestors()
6767
.some(ancestor => belongsToReduxReact(ancestor, null, node));
6868
if (usedInReactRedux) {
69-
node.properties.forEach(prop => context.report(node, `exclude:${prop.key.name}`));
69+
node.properties.forEach((prop) => {
70+
if (prop.type === 'Property' && prop.key && prop.key.name) {
71+
return context.report(node, `exclude:${prop.key.name}`);
72+
} else if (prop.type === 'ExperimentalRestProperty' && prop.argument && prop.argument.name) {
73+
return context.report(node, `exclude:${prop.argument.name}`);
74+
}
75+
return undefined;
76+
});
7077
}
7178
},
7279
};

0 commit comments

Comments
 (0)