-
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathcomponent-init-path.ts
More file actions
20 lines (18 loc) · 697 Bytes
/
Copy pathcomponent-init-path.ts
File metadata and controls
20 lines (18 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import * as ast from "@eslint-react/ast";
import { ComponentFlag } from "./component-flag";
import type { FunctionComponentSemanticNode } from "./component-semantic-node";
/**
* Get component flag from init path
* @param initPath The init path of the function component
* @returns The component flag
*/
export function getComponentFlagFromInitPath(initPath: FunctionComponentSemanticNode["initPath"]) {
let flag = ComponentFlag.None;
if (initPath != null && ast.hasCallInFunctionInitPath("memo", initPath)) {
flag |= ComponentFlag.Memo;
}
if (initPath != null && ast.hasCallInFunctionInitPath("forwardRef", initPath)) {
flag |= ComponentFlag.ForwardRef;
}
return flag;
}