Skip to content

Commit 84652b6

Browse files
committed
[Fix] no-unused-prop-types: avoid a crash
Fixes jsx-eslint#2131.
1 parent 58ed9e9 commit 84652b6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/util/propWrapper.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ function getPropWrapperFunctions(context) {
88
}
99

1010
function isPropWrapperFunction(context, name) {
11+
if (typeof name !== 'string') {
12+
return false;
13+
}
1114
const propWrapperFunctions = getPropWrapperFunctions(context);
1215
const splitName = name.split('.');
1316
return Array.from(propWrapperFunctions).some(func => {

tests/lib/rules/no-unused-prop-types.js

+11
Original file line numberDiff line numberDiff line change
@@ -2975,6 +2975,17 @@ ruleTester.run('no-unused-prop-types', rule, {
29752975
}
29762976
`,
29772977
parser: 'babel-eslint'
2978+
},
2979+
{
2980+
code: `
2981+
export default class Foo extends React.Component {
2982+
render() {
2983+
return null;
2984+
}
2985+
}
2986+
2987+
Foo.defaultProps = Object.assign({});
2988+
`
29782989
}
29792990
],
29802991

0 commit comments

Comments
 (0)