Skip to content

Commit

Permalink
[Fix] no-unused-prop-types: avoid a crash
Browse files Browse the repository at this point in the history
Fixes #2131.
  • Loading branch information
ljharb committed Jan 11, 2019
1 parent 58ed9e9 commit 84652b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/util/propWrapper.js
Expand Up @@ -8,6 +8,9 @@ function getPropWrapperFunctions(context) {
}

function isPropWrapperFunction(context, name) {
if (typeof name !== 'string') {
return false;
}
const propWrapperFunctions = getPropWrapperFunctions(context);
const splitName = name.split('.');
return Array.from(propWrapperFunctions).some(func => {
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -2975,6 +2975,17 @@ ruleTester.run('no-unused-prop-types', rule, {
}
`,
parser: 'babel-eslint'
},
{
code: `
export default class Foo extends React.Component {
render() {
return null;
}
}
Foo.defaultProps = Object.assign({});
`
}
],

Expand Down

0 comments on commit 84652b6

Please sign in to comment.