Skip to content

Commit 057f1db

Browse files
committed
[Fix] : fix crash on for...of destructuring
Fixes #2326
1 parent 62255af commit 057f1db

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/util/usedPropTypes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils)
452452
}
453453

454454
// Only handles destructuring
455-
if (node.id.type !== 'ObjectPattern') {
455+
if (node.id.type !== 'ObjectPattern' || !node.init) {
456456
return;
457457
}
458458

tests/lib/rules/prop-types.js

+6
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,12 @@ ruleTester.run('prop-types', rule, {
23492349
}
23502350
`,
23512351
parser: parsers.BABEL_ESLINT
2352+
},
2353+
{
2354+
// issue #2326
2355+
code: `
2356+
for (const {result} of results) {}
2357+
`
23522358
}
23532359
],
23542360

0 commit comments

Comments
 (0)