From 84652b6527161f651a671754fb5f619296c3654e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 11 Jan 2019 00:21:32 -0800 Subject: [PATCH] [Fix] `no-unused-prop-types`: avoid a crash Fixes #2131. --- lib/util/propWrapper.js | 3 +++ tests/lib/rules/no-unused-prop-types.js | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/util/propWrapper.js b/lib/util/propWrapper.js index b41dd0933c..24092c43aa 100644 --- a/lib/util/propWrapper.js +++ b/lib/util/propWrapper.js @@ -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 => { diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index 17f95dc112..2ee18e4ca3 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -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({}); + ` } ],