Skip to content

Commit

Permalink
Fixes Issue jsx-eslint#825
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgueni Naverniouk committed Sep 13, 2016
1 parent 0de2a9e commit f79c63e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ module.exports = {
});
break;
case 'destructuring':
for (var k = 0, l = properties.length; k < l; k++) {
for (var k = 0, l = (properties || []).length; k < l; k++) {
if (hasSpreadOperator(properties[k]) || properties[k].computed) {
continue;
}
Expand Down
32 changes: 32 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,20 @@ ruleTester.run('no-unused-prop-types', rule, {
].join('\n'),
parser: 'babel-eslint',
parserOptions: parserOptions
}, {
// Destructured state props in `componentDidUpdate` [Issue #825]
code: [
'class Hello extends Component {',
' static propTypes = {',
' something: PropTypes.bool',
' }',
' componentDidUpdate ({something}, {state1, state2}) {',
' return something;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint',
parserOptions: parserOptions
}
],

Expand Down Expand Up @@ -2337,6 +2351,24 @@ ruleTester.run('no-unused-prop-types', rule, {
line: 3,
column: 13
}]
}, {
code: [
'class Hello extends Component {',
' static propTypes = {',
' something: PropTypes.bool',
' }',
' componentDidUpdate (prevProps, {state1, state2}) {',
' return something;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint',
parserOptions: parserOptions,
errors: [{
message: '\'something\' PropType is defined but prop is never used',
line: 3,
column: 16
}]
}/* , {
// Enable this when the following issue is fixed
// https://github.com/yannickcr/eslint-plugin-react/issues/296
Expand Down

0 comments on commit f79c63e

Please sign in to comment.