Skip to content

Commit

Permalink
Add empty params check for unused prop types rule to fix empty propty…
Browse files Browse the repository at this point in the history
…pe functions from causing crashes
  • Loading branch information
kevinzwhuang committed Dec 13, 2017
1 parent f6e4c89 commit d331af6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ module.exports = {
case 'ArrowFunctionExpression':
case 'FunctionDeclaration':
case 'FunctionExpression':
if (node.params.length === 0) {
break;
}
type = 'destructuring';
properties = node.params[0].properties;
if (inSetStateUpdater()) {
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,17 @@ ruleTester.run('no-unused-prop-types', rule, {
}
`,
parser: 'babel-eslint'
},
{
code: `
class MyComponent extends React.Component<Props> {
render() {
return <div>{ this.props.other }</div>
}
}
MyComponent.propTypes = { other: () => {} };
`,
parser: 'babel-eslint'
}
],

Expand Down

0 comments on commit d331af6

Please sign in to comment.