diff --git a/lib/util/usedPropTypes.js b/lib/util/usedPropTypes.js index 9e5fffbfe5..9e19fe8b14 100755 --- a/lib/util/usedPropTypes.js +++ b/lib/util/usedPropTypes.js @@ -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; } diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index bcb48a09dc..b8d5bd7e3d 100755 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2349,6 +2349,12 @@ ruleTester.run('prop-types', rule, { } `, parser: parsers.BABEL_ESLINT + }, + { + // issue #2326 + code: ` + for (const {result} of results) {} + ` } ],