From 58947d907587272cd9a8e6106a3fca6b59bbd317 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Wed, 15 Nov 2023 09:36:31 +0000 Subject: [PATCH] [babel] Rename isReactFunction to isReactAPI Disambiguates better between this and the existing `isReactFunctionLike` function. --- .../src/Entrypoint/Program.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index 18b92ee633..f3feb96b4e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -398,7 +398,7 @@ function shouldVisitNode(fn: BabelFn, pass: CompilerPass): boolean { // Component declarations are known components (fn.isFunctionDeclaration() && isComponentDeclaration(fn.node)) || // Otherwise check if this is a component or hook-like function - isReactFunctionLike(fn) + isComponentOrHookLike(fn) ); } case "all": { @@ -466,7 +466,7 @@ function isComponentName(path: NodePath): boolean { return path.isIdentifier() && /^[A-Z]/.test(path.node.name); } -function isReactFunction( +function isReactAPI( path: NodePath, functionName: string ): boolean { @@ -490,7 +490,7 @@ function isForwardRefCallback(path: NodePath): boolean { return !!( path.parentPath.isCallExpression() && path.parentPath.get("callee").isExpression() && - isReactFunction(path.parentPath.get("callee"), "forwardRef") + isReactAPI(path.parentPath.get("callee"), "forwardRef") ); } @@ -503,7 +503,7 @@ function isMemoCallback(path: NodePath): boolean { return ( path.parentPath.isCallExpression() && path.parentPath.get("callee").isExpression() && - isReactFunction(path.parentPath.get("callee"), "memo") + isReactAPI(path.parentPath.get("callee"), "memo") ); } @@ -511,7 +511,7 @@ function isMemoCallback(path: NodePath): boolean { * Adapted from the ESLint rule at * https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js#L90-L103 */ -function isReactFunctionLike( +function isComponentOrHookLike( node: NodePath< t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression >