@samitouri / QOS-React-1 / commits / 58947d9075

[babel] Rename isReactFunction to isReactAPI

Disambiguates better between this and the existing `isReactFunctionLike` function.

Sathya Gunasekaran committed Nov 15, 2023 at 09:36 UTC 58947d907587272cd9a8e6106a3fca6b59bbd317
1 file changed +5 -5
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+5 -5
@@ -398,7 +398,7 @@ function shouldVisitNode(fn: BabelFn, pass: CompilerPass): boolean {
398 // Component declarations are known components
399 (fn.isFunctionDeclaration() && isComponentDeclaration(fn.node)) ||
400 // Otherwise check if this is a component or hook-like function
401 - isReactFunctionLike(fn)
401 + isComponentOrHookLike(fn)
402 );
403 }
404 case "all": {
@@ -466,7 +466,7 @@ function isComponentName(path: NodePath<t.Expression>): boolean {
466 return path.isIdentifier() && /^[A-Z]/.test(path.node.name);
467 }
468
469 -function isReactFunction(
469 +function isReactAPI(
470 path: NodePath<t.Expression | t.PrivateName | t.V8IntrinsicIdentifier>,
471 functionName: string
472 ): boolean {
@@ -490,7 +490,7 @@ function isForwardRefCallback(path: NodePath<t.Expression>): boolean {
490 return !!(
491 path.parentPath.isCallExpression() &&
492 path.parentPath.get("callee").isExpression() &&
493 - isReactFunction(path.parentPath.get("callee"), "forwardRef")
493 + isReactAPI(path.parentPath.get("callee"), "forwardRef")
494 );
495 }
496
@@ -503,7 +503,7 @@ function isMemoCallback(path: NodePath<t.Expression>): boolean {
503 return (
504 path.parentPath.isCallExpression() &&
505 path.parentPath.get("callee").isExpression() &&
506 - isReactFunction(path.parentPath.get("callee"), "memo")
506 + isReactAPI(path.parentPath.get("callee"), "memo")
507 );
508 }
509
@@ -511,7 +511,7 @@ function isMemoCallback(path: NodePath<t.Expression>): boolean {
511 * Adapted from the ESLint rule at
512 * https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js#L90-L103
513 */
514 -function isReactFunctionLike(
514 +function isComponentOrHookLike(
515 node: NodePath<
516 t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression
517 >