diff --git a/lib/util/Components.js b/lib/util/Components.js index 495d6f71f3..888f3ee59f 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -345,7 +345,9 @@ function componentRule(rule, context) { // check proper require. if ( - requireExpression.callee.name === 'require' + requireExpression + && requireExpression.callee + && requireExpression.callee.name === 'require' && requireExpression.arguments[0] && requireExpression.arguments[0].value === pragma.toLocaleLowerCase() ) { diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 69b84cf7a7..f064d9a377 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2574,6 +2574,28 @@ ruleTester.run('prop-types', rule, { code: ` export default function() {} ` + }, + { + code: ` + import * as React from 'react'; + + interface Props { + text: string; + } + + export const Test: React.FC = (props: Props) => { + const createElement = (text: string) => { + return ( +
+ {text} +
+ ); + }; + + return <>{createElement(props.text)}; + }; + `, + parser: parsers.TYPESCRIPT_ESLINT } ],