From c3ec002d69e94b4b48ba2da41ab6cf4d2c3ff06d Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 10 Aug 2023 17:24:22 -0400 Subject: [PATCH] Invert shouldVisitNode logic --- .../src/Entrypoint/Program.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/compiler/forget/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/forget/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index f760bd5659..6afcafa694 100644 --- a/compiler/forget/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/forget/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -331,26 +331,17 @@ function shouldVisitNode( pass: CompilerPass ): boolean { if (pass.opts.enableOnlyOnReactScript) { - if (!isComponentDeclaration(fn.node)) { - return false; - } + return isComponentDeclaration(fn.node); } if (pass.opts.enableOnlyOnUseForgetDirective) { const body = fn.get("body"); - if (!body.isBlockStatement()) { - return false; - } - if (!hasAnyUseForgetDirectives(body.node.directives)) { - return false; + if (body.isBlockStatement()) { + return hasAnyUseForgetDirectives(body.node.directives); } } - if (fn.scope.getProgramParent() !== fn.scope.parent) { - return false; - } - - return true; + return fn.scope.getProgramParent() === fn.scope.parent; } function log(error: CompilerError, filename: string | null): void {