Skip to content

Commit

Permalink
[Fix] : fix crash on for...of destructuring
Browse files Browse the repository at this point in the history
Fixes #2326
  • Loading branch information
yannickcr committed Jun 24, 2019
1 parent 62255af commit 057f1db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/util/usedPropTypes.js
Expand Up @@ -452,7 +452,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils)
}

// Only handles destructuring
if (node.id.type !== 'ObjectPattern') {
if (node.id.type !== 'ObjectPattern' || !node.init) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -2349,6 +2349,12 @@ ruleTester.run('prop-types', rule, {
}
`,
parser: parsers.BABEL_ESLINT
},
{
// issue #2326
code: `
for (const {result} of results) {}
`
}
],

Expand Down

0 comments on commit 057f1db

Please sign in to comment.