Skip to content

Commit

Permalink
[Fix] prop-types: handle anonymous functions
Browse files Browse the repository at this point in the history
Fixes #2728.

Co-authored-by: Odin Hørthe Omdal <odin.omdal@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Dmitriy Lazarev <w@kich.dev>
  • Loading branch information
3 people committed Jul 27, 2020
1 parent e20522c commit f070df0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/util/Components.js
Expand Up @@ -689,6 +689,7 @@ function componentRule(rule, context) {
getStatelessComponent(node) {
if (
node.type === 'FunctionDeclaration'
&& node.id
&& isFirstLetterCapitalized(node.id.name)
&& utils.isReturningJSXOrNull(node)
) {
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/prop-types.js
Expand Up @@ -2569,6 +2569,11 @@ ruleTester.run('prop-types', rule, {
return null;
}`,
parser: parsers.TYPESCRIPT_ESLINT
},
{
code: `
export default function() {}
`
}
],

Expand Down

0 comments on commit f070df0

Please sign in to comment.