Skip to content

Commit 5e15fba

Browse files
Rel1cxclaude
andcommitted
docs: add JSDoc comments to core package types and functions
- Add JSDoc to isHookId() function in hook-id.ts - Add JSDoc to SemanticNode interface and properties in semantic-node.ts - Add JSDoc to SemanticFunc interface and properties in semantic-func.ts - Add JSDoc to HookSemanticNode interface in hook-semantic-node.ts Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 118e317 commit 5e15fba

4 files changed

Lines changed: 39 additions & 21 deletions

File tree

packages/core/src/hook/hook-id.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import type { TSESTree } from "@typescript-eslint/types";
22
import { AST_NODE_TYPES as AST } from "@typescript-eslint/types";
33
import { isHookName } from "./hook-name";
44

5+
/**
6+
* Checks if the given node is a hook identifier
7+
* @param id The AST node to check
8+
* @returns `true` if the node is a hook identifier or member expression with hook name, `false` otherwise
9+
*/
510
export function isHookId(id: TSESTree.Node): id is TSESTree.Identifier | TSESTree.MemberExpression {
611
switch (id.type) {
712
case AST.Identifier:

packages/core/src/hook/hook-semantic-node.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ import type { TSESTree } from "@typescript-eslint/types";
55
import type { SemanticNode } from "../semantic";
66

77
/* eslint-disable perfectionist/sort-interfaces */
8+
/**
9+
* Represents a semantic hook node in the AST
10+
* This interface extends SemanticNode and provides additional properties for React hook analysis
11+
*/
812
export interface HookSemanticNode extends SemanticNode {
9-
// The identifier of the hook
13+
/** The identifier of the hook */
1014
id: ast.FunctionID | unit;
11-
// The AST node of the hook
15+
/** The AST node of the hook */
1216
node: ast.TSESTreeFunction;
13-
// The name of the hook
17+
/** The name of the hook */
1418
name: string;
15-
// The other hooks called by the hook
19+
/** The other hooks called by the hook */
1620
hookCalls: TSESTree.CallExpression[];
17-
/**
18-
* The directives used in the function (e.g., "use strict", "use client", etc.)
19-
*/
21+
/** The directives used in the function (e.g., "use strict", "use client", etc.) */
2022
directives: TSESTree.StringLiteral[];
2123
}
2224
/* eslint-enable perfectionist/sort-interfaces */

packages/core/src/semantic/semantic-func.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,26 @@ import type { TSESTree } from "@typescript-eslint/types";
55
import type { SemanticNode } from "./semantic-node";
66

77
/* eslint-disable perfectionist/sort-interfaces */
8+
/**
9+
* Represents a semantic function node in the AST
10+
* This interface extends SemanticNode and provides additional properties for function analysis
11+
*/
812
export interface SemanticFunc extends SemanticNode {
9-
// The identifier of the function
13+
/** The identifier of the function */
1014
id: ast.FunctionID | unit;
11-
// The AST node of the function
15+
/** The AST node of the function */
1216
node: ast.TSESTreeFunction;
13-
// The name of the function
17+
/** The name of the function */
1418
name: string | unit;
15-
// The return type of the function
19+
/** The return type annotation of the function */
1620
type: TSESTree.TSTypeAnnotation | unit;
17-
// The body of the function
21+
/** The body of the function */
1822
body: TSESTree.BlockStatement | TSESTree.Expression;
19-
// The directives of the function (e.g., "use strict", "use client", "use server", etc.)
23+
/** The directives of the function (e.g., "use strict", "use client", "use server", etc.) */
2024
directives: TSESTree.StringLiteral[];
21-
// The parameters of the function
25+
/** The parameters of the function */
2226
parameters: TSESTree.Parameter[];
23-
// The type parameters of the function
27+
/** The type parameters of the function */
2428
typeParameters: TSESTree.TSTypeParameterDeclaration | unit;
2529
}
2630
/* eslint-enable perfectionist/sort-interfaces */
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import type { unit } from "@eslint-react/eff";
22
import type { TSESTree } from "@typescript-eslint/types";
33

4+
/**
5+
* Represents a semantic node in the AST
6+
* This is the base interface for all semantic nodes in the React semantic analysis
7+
*/
48
export interface SemanticNode {
5-
id:
6-
| unit
7-
| TSESTree.Node;
9+
/** The identifier of the node */
10+
id: unit | TSESTree.Node;
11+
/** The unique key of the node */
812
key: string;
13+
/** The kind of the node */
914
kind: string;
10-
name:
11-
| unit
12-
| string;
15+
/** The name of the node */
16+
name: unit | string;
17+
/** The AST node */
1318
node: TSESTree.Node;
19+
/** The flag of the node */
1420
flag: bigint;
21+
/** The hint of the node */
1522
hint: bigint;
1623
}

0 commit comments

Comments
 (0)