From ce939458cb750b7ea79f839b2e4b865b1ab9bd29 Mon Sep 17 00:00:00 2001 From: Ifiok Jr Date: Tue, 26 May 2020 09:37:27 +0200 Subject: [PATCH] fix(eslint-plugin): explicit-module-boundary-types Exit early when the type of the ancestor of the node being checked is not a return statement. --- packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts index 2e26f69b1cab..320d4798e8f0 100644 --- a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts +++ b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts @@ -370,6 +370,10 @@ function ancestorHasReturnType( // by an ancestor check. const isParentCheck = true; + if (ancestor?.type !== AST_NODE_TYPES.ReturnStatement) { + return false; + } + // Has a valid type been found in any of the ancestors. let hasType = false;