diff --git a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts index a46130cb426c..64f85d48b752 100644 --- a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts +++ b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts @@ -55,12 +55,14 @@ function isFunctionArgument( } /** - * Checks if a node is an expression in a JSX attribute assignment + * Checks if a node is type-constrained in JSX * ``` - * + * {}} /> + * {() => {}} + * * ``` */ -function isJSXAttribute( +function isTypedJSX( node: TSESTree.Node, ): node is TSESTree.JSXExpressionContainer | TSESTree.JSXSpreadAttribute { return ( @@ -78,7 +80,7 @@ function isTypedParent( isVariableDeclaratorWithTypeAnnotation(parent) || isPropertyDefinitionWithTypeAnnotation(parent) || isFunctionArgument(parent, callee) || - isJSXAttribute(parent) + isTypedJSX(parent) ); } diff --git a/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts b/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts index 1359f4f256bd..557b0edae6b6 100644 --- a/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts @@ -182,11 +182,7 @@ class App { }, // https://github.com/typescript-eslint/typescript-eslint/issues/7552 { - code: ` -const Comp: FC = () => { - return