From f070df0a0f619aa6f1883bfd4f9a082d9c7d1ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odin=20H=C3=B8rthe=20Omdal?= Date: Mon, 27 Jul 2020 11:18:51 +0200 Subject: [PATCH] [Fix] `prop-types`: handle anonymous functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2728. Co-authored-by: Odin Hørthe Omdal Co-authored-by: Jordan Harband Co-authored-by: Dmitriy Lazarev --- lib/util/Components.js | 1 + tests/lib/rules/prop-types.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/util/Components.js b/lib/util/Components.js index deb26dda56..9eb0f78282 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -689,6 +689,7 @@ function componentRule(rule, context) { getStatelessComponent(node) { if ( node.type === 'FunctionDeclaration' + && node.id && isFirstLetterCapitalized(node.id.name) && utils.isReturningJSXOrNull(node) ) { diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index 0089d1c812..0020e9f84e 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -2569,6 +2569,11 @@ ruleTester.run('prop-types', rule, { return null; }`, parser: parsers.TYPESCRIPT_ESLINT + }, + { + code: ` + export default function() {} + ` } ],