@eslint-react/ast 5.2.1-next.1 → 5.2.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-BYypO7fO.js +18 -0
- package/dist/index.d.ts +63 -493
- package/dist/index.js +157 -780
- package/package.json +2 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) {
|
|
6
|
+
__defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!no_symbols) {
|
|
12
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { __exportAll as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,439 +1,77 @@
|
|
|
1
1
|
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type
|
|
16
|
-
/**
|
|
17
|
-
* Represents method definitions and property definitions in classes
|
|
18
|
-
*/
|
|
19
|
-
type TSESTreeMethodOrProperty = TSESTree.PropertyDefinition | TSESTree.MethodDefinition;
|
|
20
|
-
/**
|
|
21
|
-
* Represents loop statements in TSESTree
|
|
22
|
-
*/
|
|
23
|
-
type TSESTreeLoop = TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
|
|
24
|
-
/**
|
|
25
|
-
* Represents TypeScript array and tuple types
|
|
26
|
-
*/
|
|
27
|
-
type TSESTreeArrayTupleType = TSESTree.TSArrayType | TSESTree.TSTupleType;
|
|
28
|
-
/**
|
|
29
|
-
* Represents property-like nodes in TSESTree
|
|
30
|
-
*/
|
|
31
|
-
type TSESTreeProperty = TSESTree.PropertyDefinition | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignature;
|
|
32
|
-
/**
|
|
33
|
-
* Represents all JSX-related nodes in TSESTree
|
|
34
|
-
* Note: This type is for type-level operations. The isJSX() runtime guard in node-is.ts
|
|
35
|
-
* has a slightly different set of nodes as it includes JSXExpressionContainer which is
|
|
36
|
-
* commonly needed for runtime checks but not included in this type union.
|
|
37
|
-
*/
|
|
38
|
-
type TSESTreeJSX = TSESTree.JSXAttribute | TSESTree.JSXChild | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXEmptyExpression | TSESTree.JSXIdentifierToken | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXTagNameExpression | TSESTree.JSXTextToken;
|
|
39
|
-
type TSESTreeJSXElementLike = TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
40
|
-
/**
|
|
41
|
-
* Represents JSX attribute-like nodes (attributes and spread attributes)
|
|
42
|
-
*/
|
|
43
|
-
type TSESTreeJSXAttributeLike = TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute;
|
|
44
|
-
/**
|
|
45
|
-
* Represents destructuring patterns in variable declarations
|
|
46
|
-
*/
|
|
47
|
-
type TSESTreeDestructuringPattern = TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
|
|
48
|
-
/**
|
|
49
|
-
* Represents TypeScript type declaration nodes
|
|
50
|
-
*/
|
|
51
|
-
type TSESTreeTypeDeclaration = TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
|
|
52
|
-
/**
|
|
53
|
-
* Represents TypeScript type expression nodes (type assertions, non-null expressions, etc.)
|
|
54
|
-
*/
|
|
55
|
-
type TSESTreeTypeExpression = TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.TSInstantiationExpression;
|
|
56
|
-
/**
|
|
57
|
-
* Represents TypeScript type assertion expressions (excluding instantiation expressions)
|
|
58
|
-
*/
|
|
59
|
-
type TSESTreeTypeAssertionExpression = TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
60
|
-
/**
|
|
61
|
-
* Represents a directive expression statement in TSESTree (ex: "use strict";)
|
|
62
|
-
*/
|
|
63
|
-
type TSESTreeDirective = TSESTree.ExpressionStatement & {
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type Node = TSESTree.Node;
|
|
5
|
+
type Program = TSESTree.Program;
|
|
6
|
+
type Expression = TSESTree.Expression;
|
|
7
|
+
type Statement = TSESTree.Statement;
|
|
8
|
+
type Identifier = TSESTree.Identifier;
|
|
9
|
+
type FunctionExpression = TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
|
|
10
|
+
type ClassExpression = TSESTree.ClassDeclaration | TSESTree.ClassExpression;
|
|
11
|
+
type MethodOrPropertyDefinition = TSESTree.PropertyDefinition | TSESTree.MethodDefinition;
|
|
12
|
+
type JSXNode = TSESTree.JSXAttribute | TSESTree.JSXChild | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXEmptyExpression | TSESTree.JSXIdentifierToken | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXTagNameExpression | TSESTree.JSXTextToken;
|
|
13
|
+
type JSXElementLike = TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
14
|
+
type JSXAttributeLike = TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute;
|
|
15
|
+
type Directive = TSESTree.ExpressionStatement & {
|
|
64
16
|
directive: string;
|
|
65
17
|
expression: TSESTree.StringLiteral;
|
|
66
18
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
//#endregion
|
|
74
|
-
//#region src/class-id.d.ts
|
|
75
|
-
/**
|
|
76
|
-
* Get the class identifier of a class node
|
|
77
|
-
* @param node The class node to get the identifier from
|
|
78
|
-
* @returns The class identifier or null if not found
|
|
79
|
-
*/
|
|
80
|
-
declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | null;
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/directive-is.d.ts
|
|
83
|
-
/**
|
|
84
|
-
* Check if a node is a directive expression statement
|
|
85
|
-
* @param node The node to check
|
|
86
|
-
* @returns True if the node is a directive, false otherwise
|
|
87
|
-
*/
|
|
88
|
-
declare function isDirective(node: TSESTree.Node): node is TSESTreeDirective;
|
|
89
|
-
/**
|
|
90
|
-
* Check if a node is a directive-like expression statement
|
|
91
|
-
* @param node The node to check
|
|
92
|
-
* @returns True if the node is a directive, false otherwise
|
|
93
|
-
*/
|
|
94
|
-
declare function isDirectiveLike(node: TSESTree.Node): node is TSESTreeDirectiveLike;
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/directive-kind.d.ts
|
|
97
|
-
/**
|
|
98
|
-
* Known directive kinds in React
|
|
99
|
-
*/
|
|
100
|
-
type DirectiveKind = "use client" | "use server" | "use memo" | "use no memo";
|
|
101
|
-
/**
|
|
102
|
-
* Check if a node is a directive kind
|
|
103
|
-
* @param kind The kind to check
|
|
104
|
-
* @returns True if the kind is a directive kind, false otherwise
|
|
105
|
-
*/
|
|
106
|
-
declare function isDirectiveKind(kind: string): kind is DirectiveKind;
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/directive-name.d.ts
|
|
109
|
-
/**
|
|
110
|
-
* Check if a string is a directive name (heuristic check)
|
|
111
|
-
* Note: This is a broad check that matches any string starting with "use ".
|
|
112
|
-
* For strict validation against known directives, use isDirectiveKind.
|
|
113
|
-
* @param name The string to check
|
|
114
|
-
* @returns True if the string looks like a directive name, false otherwise
|
|
115
|
-
* @see isDirectiveKind
|
|
116
|
-
*/
|
|
117
|
-
declare function isDirectiveName(name: string): boolean;
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/expression-is.d.ts
|
|
120
|
-
/**
|
|
121
|
-
* Check if the given expression is a 'this' expression
|
|
122
|
-
* Unwraps any type expressions before checking
|
|
123
|
-
*
|
|
124
|
-
* @param node The expression node to check
|
|
125
|
-
* @returns True if the expression is a 'this' expression, false otherwise
|
|
126
|
-
*/
|
|
127
|
-
declare function isThisExpressionLoose(node: TSESTree.Expression): boolean;
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/expression-nested.d.ts
|
|
130
|
-
/**
|
|
131
|
-
* Get all nested identifiers in a expression like node
|
|
132
|
-
* @param node The node to get the nested identifiers from
|
|
133
|
-
* @returns All nested identifiers
|
|
134
|
-
*/
|
|
135
|
-
declare function getNestedIdentifiers(node: TSESTree.Node): readonly TSESTree.Identifier[];
|
|
136
|
-
/**
|
|
137
|
-
* Gets the nested return statements in the node that are within the same function
|
|
138
|
-
* @param node The AST node
|
|
139
|
-
* @returns The nested return statements in the node
|
|
140
|
-
*/
|
|
141
|
-
declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTree.ReturnStatement[];
|
|
142
|
-
/**
|
|
143
|
-
* Get all nested expressions of type T in an expression like node
|
|
144
|
-
* @param type The type of the expression to retrieve within the node
|
|
145
|
-
* @returns A partially applied function bound to a predicate of type AST. The returned function can be called passing a
|
|
146
|
-
* node, and it will return an array of all nested expressions of type AST.
|
|
147
|
-
*/
|
|
148
|
-
declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
|
|
149
|
-
type: TNodeType;
|
|
150
|
-
}>[];
|
|
151
|
-
/**
|
|
152
|
-
* Get all nested new expressions in an expression like node
|
|
153
|
-
* @param node The node to get the nested new expressions from
|
|
154
|
-
* @returns All nested new expressions
|
|
155
|
-
*/
|
|
156
|
-
declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpression[];
|
|
157
|
-
/**
|
|
158
|
-
* Get all nested call expressions in a expression like node
|
|
159
|
-
* @param node The node to get the nested call expressions from
|
|
160
|
-
* @returns All nested call expressions
|
|
161
|
-
*/
|
|
162
|
-
declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/file-directive.d.ts
|
|
165
|
-
/**
|
|
166
|
-
* Get all directive expression statements from the top of a program AST node
|
|
167
|
-
* @param node The program AST node
|
|
168
|
-
* @returns The array of directive string literals (ex: "use strict")
|
|
169
|
-
*/
|
|
170
|
-
declare function getFileDirectives(node: TSESTree.Program): TSESTreeDirective[];
|
|
171
|
-
/**
|
|
172
|
-
* Check if a directive with the given name exists in the file directives
|
|
173
|
-
* @param node The program AST node
|
|
174
|
-
* @param name The directive name to check (ex: "use strict", "use memo", "use no memo")
|
|
175
|
-
* @returns True if the directive exists, false otherwise
|
|
176
|
-
*/
|
|
177
|
-
declare function isDirectiveInFile(node: TSESTree.Program, name: string): boolean;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/function-directive.d.ts
|
|
180
|
-
/**
|
|
181
|
-
* Get all directive expression statements from the top of a function AST node
|
|
182
|
-
* @param node The function AST node
|
|
183
|
-
* @returns The array of directive string literals (ex: "use memo", "use no memo")
|
|
184
|
-
*/
|
|
185
|
-
declare function getFunctionDirectives(node: TSESTreeFunction): TSESTreeDirective[];
|
|
186
|
-
/**
|
|
187
|
-
* Check if a directive with the given name exists in the function directives
|
|
188
|
-
* @param node The function AST node
|
|
189
|
-
* @param name The directive name to check (ex: "use memo", "use no memo")
|
|
190
|
-
* @returns True if the directive exists, false otherwise
|
|
191
|
-
*/
|
|
192
|
-
declare function isDirectiveInFunction(node: TSESTreeFunction, name: string): boolean;
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/function-id.d.ts
|
|
195
|
-
/**
|
|
196
|
-
* Gets the static name of a function AST node. For function declarations it is
|
|
197
|
-
* easy. For anonymous function expressions it is much harder. If you search for
|
|
198
|
-
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
|
|
199
|
-
* where JS gives anonymous function expressions names. We roughly detect the
|
|
200
|
-
* same AST nodes with some exceptions to better fit our use case.
|
|
201
|
-
*/
|
|
202
|
-
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldExpression | null;
|
|
203
|
-
/**
|
|
204
|
-
* Type representing the return type of getFunctionId
|
|
205
|
-
*/
|
|
206
|
-
type FunctionID = ReturnType<typeof getFunctionId>;
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/function-init-path.d.ts
|
|
209
|
-
/**
|
|
210
|
-
* Represents various AST paths for React component function declarations
|
|
211
|
-
* Each tuple type represents a specific component definition pattern
|
|
212
|
-
*/
|
|
213
|
-
type FunctionInitPath = readonly [TSESTree.FunctionDeclaration] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration | TSESTree.ClassExpression, TSESTree.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration | TSESTree.ClassExpression, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
|
|
214
|
-
/**
|
|
215
|
-
* Identifies the initialization path of a function node in the ast.
|
|
216
|
-
* Determine what kind of component declaration pattern the function belongs to.
|
|
217
|
-
*
|
|
218
|
-
* @param node The function node to analyze
|
|
219
|
-
* @returns The function initialization path or null if not identifiable
|
|
220
|
-
*/
|
|
221
|
-
declare function getFunctionInitPath(node: TSESTreeFunction): null | FunctionInitPath;
|
|
222
|
-
/**
|
|
223
|
-
* Check if a specific function call exists in the function initialization path.
|
|
224
|
-
* Useful for detecting HOCs like React.memo, React.forwardRef, etc.
|
|
225
|
-
*
|
|
226
|
-
* @param callName The name of the call to check for (ex: "memo", "forwardRef")
|
|
227
|
-
* @param initPath The function initialization path to search in
|
|
228
|
-
* @returns True if the call exists in the path, false otherwise
|
|
229
|
-
*/
|
|
230
|
-
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region src/function-is.d.ts
|
|
233
|
-
/**
|
|
234
|
-
* Check if a function is empty
|
|
235
|
-
* @param node The function node to check
|
|
236
|
-
* @returns True if the function is empty, false otherwise
|
|
237
|
-
*/
|
|
238
|
-
declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
|
|
239
|
-
/**
|
|
240
|
-
* Check if a function is immediately invoked
|
|
241
|
-
* @param node The function node to check
|
|
242
|
-
* @returns True if the function is immediately invoked, false otherwise
|
|
243
|
-
*/
|
|
244
|
-
declare function isFunctionImmediatelyInvoked(node: TSESTreeFunction): boolean;
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region src/identifier-is.d.ts
|
|
247
|
-
/**
|
|
248
|
-
* Check if the given node is an identifier
|
|
249
|
-
* @param node The node to check
|
|
250
|
-
* @param name The name to check
|
|
251
|
-
* @returns True if the node is an identifier, false otherwise
|
|
252
|
-
*/
|
|
253
|
-
declare function isIdentifier(node: TSESTree.Node | null, name?: string): node is TSESTree.Identifier;
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/identifier-name.d.ts
|
|
256
|
-
/**
|
|
257
|
-
* Check if a string is a valid JavaScript identifier name
|
|
258
|
-
* Note: This only checks for ASCII identifiers. Unicode identifiers (e.g., `const 变量 = 1`)
|
|
259
|
-
* are not supported by this simple regex check.
|
|
260
|
-
* @param name The string to check
|
|
261
|
-
* @returns True if the string is a valid ASCII identifier name
|
|
262
|
-
*/
|
|
263
|
-
declare function isIdentifierName(name: string): boolean;
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/identifier-traverse.d.ts
|
|
266
|
-
/**
|
|
267
|
-
* Get the root identifier of a (possibly nested) member expression.
|
|
268
|
-
* For `a.b.c`, returns the `a` Identifier node.
|
|
269
|
-
* @param node The expression to analyze
|
|
270
|
-
* @returns The root Identifier node, or null if it cannot be determined (ex: non-identifier root)
|
|
271
|
-
*/
|
|
272
|
-
declare function getRootIdentifier(node: TSESTree.Expression | TSESTree.PrivateIdentifier): TSESTree.Identifier | null;
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/literal-is.d.ts
|
|
275
|
-
/**
|
|
276
|
-
* Check if a node is a literal value
|
|
277
|
-
* @param node The node to check
|
|
278
|
-
* @returns True if the node is a literal
|
|
279
|
-
*/
|
|
280
|
-
declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
|
|
281
|
-
declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
|
|
282
|
-
declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
|
|
283
|
-
declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
|
|
284
|
-
declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
|
|
285
|
-
declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
|
|
286
|
-
//#endregion
|
|
287
|
-
//#region src/node-equality.d.ts
|
|
288
|
-
/**
|
|
289
|
-
* Check if two nodes are equal
|
|
290
|
-
* @param a node to compare
|
|
291
|
-
* @param b node to compare
|
|
292
|
-
* @returns `true` if node equal
|
|
293
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
294
|
-
*/
|
|
295
|
-
declare const isNodeEqual: {
|
|
296
|
-
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
297
|
-
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
298
|
-
};
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region src/node-is.d.ts
|
|
301
|
-
/**
|
|
302
|
-
* Type guard to check if a node is of a specific AST node type
|
|
303
|
-
* @param nodeType The AST node type to check against
|
|
304
|
-
* @returns A type guard function that narrows the node type
|
|
305
|
-
*/
|
|
306
|
-
declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
19
|
+
type TypeExpression = TSESTree.TSAsExpression | TSESTree.TSTypeAssertion | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSInstantiationExpression;
|
|
20
|
+
declare namespace check_d_exports {
|
|
21
|
+
export { directive, identifier, is, isClass, isFunction, isJSX, isJSXElement, isJSXFragment, isJSXLike, isJSXTagNameExpression, isMethodOrProperty, isOneOf, isProperty, isTypeAssertionExpression, isTypeExpression, literal, thisExpression };
|
|
22
|
+
}
|
|
23
|
+
declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
307
24
|
type: NodeType;
|
|
308
25
|
}>;
|
|
309
|
-
|
|
310
|
-
* Type guard to check if a node is one of multiple AST node types
|
|
311
|
-
* @param nodeTypes Array of AST node types to check against
|
|
312
|
-
* @returns A type guard function that narrows the node type
|
|
313
|
-
*/
|
|
314
|
-
declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
26
|
+
declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
315
27
|
type: NodeTypes[number];
|
|
316
28
|
}>;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
29
|
+
declare function identifier(node: TSESTree.Node | null, named?: string): node is TSESTree.Identifier;
|
|
30
|
+
declare function literal(node: TSESTree.Node): node is TSESTree.Literal;
|
|
31
|
+
declare function literal(node: TSESTree.Node, ofKind: "boolean"): node is TSESTree.BooleanLiteral;
|
|
32
|
+
declare function literal(node: TSESTree.Node, ofKind: "null"): node is TSESTree.NullLiteral;
|
|
33
|
+
declare function literal(node: TSESTree.Node, ofKind: "number"): node is TSESTree.NumberLiteral;
|
|
34
|
+
declare function literal(node: TSESTree.Node, ofKind: "regexp"): node is TSESTree.RegExpLiteral;
|
|
35
|
+
declare function literal(node: TSESTree.Node, ofKind: "string"): node is TSESTree.StringLiteral;
|
|
36
|
+
declare function thisExpression(expression: TSESTree.Expression): boolean;
|
|
322
37
|
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
323
|
-
/**
|
|
324
|
-
* Check if a node is a function type (including TypeScript function types)
|
|
325
|
-
* @param node The node to check
|
|
326
|
-
* @returns True if the node is a function type
|
|
327
|
-
*/
|
|
328
|
-
declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSDeclareFunctionNoDeclare | TSESTree.TSDeclareFunctionWithDeclare | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignatureComputedName | TSESTree.TSMethodSignatureNonComputedName;
|
|
329
|
-
/**
|
|
330
|
-
* Check if a node is a class declaration or expression
|
|
331
|
-
* @param node The node to check
|
|
332
|
-
* @returns True if the node is a class
|
|
333
|
-
*/
|
|
334
38
|
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
|
|
335
|
-
/**
|
|
336
|
-
* Check if a node is a method or property definition
|
|
337
|
-
* @param node The node to check
|
|
338
|
-
* @returns True if the node is a method or property definition
|
|
339
|
-
*/
|
|
340
39
|
declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
|
|
341
|
-
/**
|
|
342
|
-
* Check if a node is a property-like node (including TypeScript property signatures)
|
|
343
|
-
* @param node The node to check
|
|
344
|
-
* @returns True if the node is a property
|
|
345
|
-
*/
|
|
346
40
|
declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
|
|
347
|
-
/**
|
|
348
|
-
* Check if a node is a JSX element
|
|
349
|
-
* @param node The node to check
|
|
350
|
-
* @returns True if the node is a JSX element
|
|
351
|
-
*/
|
|
352
41
|
declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
|
|
353
|
-
/**
|
|
354
|
-
* Check if a node is a JSX fragment
|
|
355
|
-
* @param node The node to check
|
|
356
|
-
* @returns True if the node is a JSX fragment
|
|
357
|
-
*/
|
|
358
42
|
declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
|
|
359
|
-
|
|
360
|
-
* Check if a node is a JSX element or JSX fragment
|
|
361
|
-
*/
|
|
362
|
-
declare const isJSXElementLike: (data: TSESTree.Node | null | undefined) => data is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
363
|
-
/**
|
|
364
|
-
* Check if a node is a JSX tag name expression (identifier, member expression, or namespaced name)
|
|
365
|
-
* @param node The node to check
|
|
366
|
-
* @returns True if the node is a JSX tag name expression
|
|
367
|
-
*/
|
|
43
|
+
declare const isJSXLike: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
368
44
|
declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
|
|
369
|
-
/**
|
|
370
|
-
* Check if a node is a JSX-related node
|
|
371
|
-
* Note: This runtime guard includes JSXExpressionContainer which is commonly needed
|
|
372
|
-
* for AST traversals but not included in the TSESTreeJSX type union.
|
|
373
|
-
* @param node The node to check
|
|
374
|
-
* @returns True if the node is a JSX node
|
|
375
|
-
* @see TSESTreeJSX
|
|
376
|
-
*/
|
|
377
45
|
declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXAttribute | TSESTree.JSXClosingElement | TSESTree.JSXClosingFragment | TSESTree.JSXElement | TSESTree.JSXEmptyExpression | TSESTree.JSXExpressionContainer | TSESTree.JSXFragment | TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName | TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment | TSESTree.JSXSpreadAttribute | TSESTree.JSXSpreadChild | TSESTree.JSXText;
|
|
378
|
-
/**
|
|
379
|
-
* Check if a node is a loop statement
|
|
380
|
-
* @param node The node to check
|
|
381
|
-
* @returns True if the node is a loop
|
|
382
|
-
*/
|
|
383
|
-
declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
|
|
384
|
-
/**
|
|
385
|
-
* Check if a node is a control flow statement (loop, if, or switch)
|
|
386
|
-
* @param node The node to check
|
|
387
|
-
* @returns True if the node is a control flow statement
|
|
388
|
-
*/
|
|
389
|
-
declare const isControlFlow: (data: TSESTree.Node | null | undefined) => data is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.SwitchStatement | TSESTree.WhileStatement;
|
|
390
|
-
/**
|
|
391
|
-
* Check if a node is a conditional expression or control flow statement
|
|
392
|
-
* @param node The node to check
|
|
393
|
-
* @returns True if the node is conditional
|
|
394
|
-
*/
|
|
395
|
-
declare const isConditional: (data: TSESTree.Node | null | undefined) => data is TSESTree.ConditionalExpression | TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.LogicalExpression | TSESTree.SwitchStatement | TSESTree.WhileStatement;
|
|
396
|
-
/**
|
|
397
|
-
* Check if a node is a TypeScript type expression
|
|
398
|
-
* @param node The node to check
|
|
399
|
-
* @returns True if the node is a type expression
|
|
400
|
-
*/
|
|
401
46
|
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
402
|
-
/**
|
|
403
|
-
* Check if a node is a TypeScript type assertion expression
|
|
404
|
-
* @param node The node to check
|
|
405
|
-
* @returns True if the node is a type assertion expression
|
|
406
|
-
*/
|
|
407
47
|
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
//#region src/node-line.d.ts
|
|
413
|
-
declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
414
|
-
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
415
|
-
//#endregion
|
|
416
|
-
//#region src/node-name.d.ts
|
|
417
|
-
declare function getFullyQualifiedName(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
418
|
-
//#endregion
|
|
419
|
-
//#region src/node-selectors.d.ts
|
|
420
|
-
/**
|
|
421
|
-
* Represents an arrow function expression with an implicit return
|
|
422
|
-
*/
|
|
423
|
-
type ImplicitReturnArrowFunctionExpression = TSESTree.ArrowFunctionExpression & {
|
|
424
|
-
body: TSESTree.Expression;
|
|
425
|
-
};
|
|
48
|
+
declare function directive(node: TSESTree.Node): node is Directive;
|
|
49
|
+
declare namespace compare_d_exports {
|
|
50
|
+
export { areEqual };
|
|
51
|
+
}
|
|
426
52
|
/**
|
|
427
|
-
*
|
|
53
|
+
* Check if two nodes are equal
|
|
54
|
+
* @param a node to compare
|
|
55
|
+
* @param b node to compare
|
|
56
|
+
* @returns `true` if node equal
|
|
57
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
428
58
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
59
|
+
declare const areEqual: {
|
|
60
|
+
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
61
|
+
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
432
62
|
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
63
|
+
declare namespace extract_d_exports {
|
|
64
|
+
export { fullyQualifiedName, humanReadableKind, propertyName, rootIdentifier, unwrapped };
|
|
65
|
+
}
|
|
66
|
+
declare function unwrapped(from: TSESTree.Node): Exclude<TSESTree.Node, TypeExpression>;
|
|
67
|
+
declare function rootIdentifier(from: TSESTree.Expression | TSESTree.PrivateIdentifier): TSESTree.Identifier | null;
|
|
68
|
+
declare function propertyName(from: TSESTree.Node): string | null;
|
|
69
|
+
declare function fullyQualifiedName(from: TSESTree.Node, using: (node: TSESTree.Node) => string): string;
|
|
70
|
+
declare function humanReadableKind(of: TSESTree.Node, delimiter?: string): string;
|
|
71
|
+
declare namespace select_d_exports {
|
|
72
|
+
export { DisplayNameAssignment, displayNameAssignment };
|
|
73
|
+
}
|
|
74
|
+
type DisplayNameAssignment = TSESTree.AssignmentExpression & {
|
|
437
75
|
left: TSESTree.MemberExpression & {
|
|
438
76
|
property: TSESTree.Identifier & {
|
|
439
77
|
name: "displayName";
|
|
@@ -442,82 +80,14 @@ type DisplayNameAssignmentExpression = TSESTree.AssignmentExpression & {
|
|
|
442
80
|
operator: "=";
|
|
443
81
|
right: TSESTree.Literal;
|
|
444
82
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
declare
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
declare const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
|
|
457
|
-
//#endregion
|
|
458
|
-
//#region src/node-traverse.d.ts
|
|
459
|
-
/**
|
|
460
|
-
* Find the parent node that satisfies the test function
|
|
461
|
-
* @param node The AST node
|
|
462
|
-
* @param test The test function
|
|
463
|
-
* @returns The parent node that satisfies the test function or `null` if not found
|
|
464
|
-
*/
|
|
465
|
-
declare function findParent<A extends TSESTree.Node>(node: TSESTree.Node | null, test: (n: TSESTree.Node) => n is A): A | null;
|
|
466
|
-
/**
|
|
467
|
-
* Find the parent node that satisfies the test function or `null` if not found
|
|
468
|
-
* @param node The AST node
|
|
469
|
-
* @param test The test function
|
|
470
|
-
* @returns The parent node that satisfies the test function
|
|
471
|
-
*/
|
|
472
|
-
declare function findParent(node: TSESTree.Node | null, test: (node: TSESTree.Node) => boolean): TSESTree.Node | null;
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region src/node-unwrap.d.ts
|
|
475
|
-
/**
|
|
476
|
-
* Unwraps any type expressions to get the underlying JavaScript expression node.
|
|
477
|
-
* Recursively processes nodes until a non-type expression is found.
|
|
478
|
-
* @param node The AST node to unwrap
|
|
479
|
-
* @returns The underlying JavaScript expression node
|
|
480
|
-
*/
|
|
481
|
-
declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
482
|
-
//#endregion
|
|
483
|
-
//#region src/pattern-process-env-node-env.d.ts
|
|
484
|
-
/**
|
|
485
|
-
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
486
|
-
* @param node The AST node
|
|
487
|
-
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
488
|
-
*/
|
|
489
|
-
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null): node is TSESTree.MemberExpression;
|
|
490
|
-
/**
|
|
491
|
-
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
|
|
492
|
-
* @param node The AST node
|
|
493
|
-
* @param operator The operator used in the comparison
|
|
494
|
-
* @param value The string literal value to compare against
|
|
495
|
-
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
496
|
-
*/
|
|
497
|
-
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
498
|
-
//#endregion
|
|
499
|
-
//#region src/pattern-test-mock.d.ts
|
|
500
|
-
declare function isTestMock(node: TSESTree.Node | null): node is TSESTree.MemberExpression;
|
|
501
|
-
declare function isTestMockCallback(node: TSESTree.Node | null): boolean;
|
|
502
|
-
//#endregion
|
|
503
|
-
//#region src/property-name.d.ts
|
|
504
|
-
/**
|
|
505
|
-
* Get the name of a property from a node
|
|
506
|
-
* Handles identifiers, private identifiers, literals, and template literals
|
|
507
|
-
* @param node The node to get the property name from
|
|
508
|
-
* @returns The property name or null if not determinable
|
|
509
|
-
*/
|
|
510
|
-
declare function getPropertyName(node: TSESTree.Node): string | null;
|
|
511
|
-
//#endregion
|
|
512
|
-
//#region src/property-traverse.d.ts
|
|
513
|
-
/**
|
|
514
|
-
* Recursively traverses an object expression's properties to find a property with the specified name
|
|
515
|
-
* Note: This only handles inline object literals in spread elements. Properties from variables
|
|
516
|
-
* (e.g., `{...props}` where props is a variable) are not resolved.
|
|
517
|
-
* @param properties The properties of the object expression to traverse
|
|
518
|
-
* @param name The name of the property to find
|
|
519
|
-
* @returns The matching property node, or null if not found
|
|
520
|
-
*/
|
|
521
|
-
declare function findProperty(properties: TSESTree.ObjectLiteralElement[], name: string): TSESTree.Property | null;
|
|
522
|
-
//#endregion
|
|
523
|
-
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeJSXElementLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParent, findProperty, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getRootIdentifier, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXElementLike, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isTestMock, isTestMockCallback, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression };
|
|
83
|
+
declare const displayNameAssignment: string;
|
|
84
|
+
declare namespace traverse_d_exports {
|
|
85
|
+
export { NodePredicate, Predicate, findParent, findProperty };
|
|
86
|
+
}
|
|
87
|
+
type Predicate<T extends TSESTree.Node> = (node: TSESTree.Node) => node is T;
|
|
88
|
+
type NodePredicate = (node: TSESTree.Node) => boolean;
|
|
89
|
+
declare function findParent<T extends TSESTree.Node>(of: TSESTree.Node | null, where: Predicate<T>): T | null;
|
|
90
|
+
declare function findParent(of: TSESTree.Node | null, where: NodePredicate): TSESTree.Node | null;
|
|
91
|
+
declare function findProperty(in_: TSESTree.ObjectLiteralElement[], named: string): TSESTree.Property | null;
|
|
92
|
+
//#endregion
|
|
93
|
+
export { check_d_exports as Check, ClassExpression, compare_d_exports as Compare, Directive, Expression, extract_d_exports as Extract, FunctionExpression, Identifier, JSXAttributeLike, JSXElementLike, JSXNode, MethodOrPropertyDefinition, Node, Program, select_d_exports as Select, Statement, traverse_d_exports as Traverse, TypeExpression, is, isOneOf };
|