Skip to content

Commit

Permalink
[Fix] no-unused-prop-types: apply skipShapeProps to exact types
Browse files Browse the repository at this point in the history
Fixes #2850.
  • Loading branch information
golopot authored and ljharb committed Dec 22, 2020
1 parent 7aaa1cf commit 9e4bbd0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/no-unused-prop-types.js
Expand Up @@ -70,6 +70,7 @@ module.exports = {
const usedProp = usedPropTypes[i];
if (
prop.type === 'shape'
|| prop.type === 'exact'
|| prop.name === '__ANY_KEY__'
|| usedProp.name === prop.name
) {
Expand Down Expand Up @@ -98,7 +99,7 @@ module.exports = {
return;
}

if (prop.type === 'shape' && configuration.skipShapeProps) {
if ((prop.type === 'shape' || prop.type === 'exact') && configuration.skipShapeProps) {
return;
}

Expand Down
19 changes: 19 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -3213,6 +3213,25 @@ ruleTester.run('no-unused-prop-types', rule, {
Foo.defaultProps = Object.assign({});
`
},
{
code: `
const Hello = ({a}) => (
<div>
{a.map(({b}) => (
<div>{b}</div>
))}
</div>
);
Hello.propTypes = {
a: PropTypes.arrayOf(
PropTypes.exact({
b: PropTypes.string,
})
),
};
`,
parser: parsers.BABEL_ESLINT
},
parsers.TS([
{
code: `
Expand Down

0 comments on commit 9e4bbd0

Please sign in to comment.