@eslint-react/ast 2.0.0-next.18 → 2.0.0-next.180

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +143 -212
  2. package/dist/index.js +532 -554
  3. package/package.json +8 -9
package/dist/index.d.ts CHANGED
@@ -1,12 +1,60 @@
1
- import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types';
2
- import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
3
- import { _ } from '@eslint-react/eff';
1
+ import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
2
+ import { unit } from "@eslint-react/eff";
3
+ import { TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
4
4
 
5
+ //#region src/array-index.d.ts
6
+ declare function getArrayMethodCallbackIndexParamPosition(methodName: string): number;
7
+ //#endregion
8
+ //#region src/array-method.d.ts
5
9
  declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
6
10
  declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
7
-
8
- declare function getArrayMethodCallbackIndexParamPosition(methodName: string): number;
9
-
11
+ //#endregion
12
+ //#region src/node-equal.d.ts
13
+ /**
14
+ * Determines whether node equals to another node
15
+ * @param a node to compare
16
+ * @param b node to compare
17
+ * @returns `true` if node equal
18
+ * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
19
+ */
20
+ declare const isNodeEqual: {
21
+ (a: TSESTree.Node): (b: TSESTree.Node) => boolean;
22
+ (a: TSESTree.Node, b: TSESTree.Node): boolean;
23
+ };
24
+ //#endregion
25
+ //#region src/node-format.d.ts
26
+ /**
27
+ * @internal
28
+ */
29
+ declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
30
+ /**
31
+ * Incomplete but sufficient stringification of AST nodes for common use cases
32
+ *
33
+ * @internal
34
+ */
35
+ declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
36
+ //#endregion
37
+ //#region src/node-is.d.ts
38
+ declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
39
+ type: NodeType;
40
+ }>;
41
+ declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
42
+ type: NodeTypes[number];
43
+ }>;
44
+ declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
45
+ 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;
46
+ declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
47
+ declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
48
+ declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
49
+ declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
50
+ declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
51
+ declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
52
+ 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;
53
+ declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
54
+ declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
55
+ declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
56
+ //#endregion
57
+ //#region src/node-types.d.ts
10
58
  type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
11
59
  type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
12
60
  type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
@@ -15,149 +63,36 @@ type TSESTreeLoop = TSESTree$1.DoWhileStatement | TSESTree$1.ForInStatement | TS
15
63
  type TSESTreeArrayTupleType = TSESTree$1.TSArrayType | TSESTree$1.TSTupleType;
16
64
  type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignature | TSESTree$1.TSParameterProperty | TSESTree$1.TSPropertySignature;
17
65
  type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXText | TSESTree$1.JSXTextToken;
66
+ type TSESTreeJSXAttributeLike = TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute;
18
67
  type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.AssignmentPattern | TSESTree$1.ObjectPattern | TSESTree$1.RestElement;
19
68
  type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
20
69
  type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
21
70
  type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
22
-
23
- declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | _;
24
-
25
- /**
26
- * Recursively get the inner expression until it's not a TypeExpression
27
- * @param node - The node to get the expression from
28
- * @returns The inner expression
71
+ //#endregion
72
+ //#region src/class-id.d.ts
73
+ declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
74
+ //#endregion
75
+ //#region src/expression-base.d.ts
76
+ /**
77
+ * Unwraps any type expressions to get the underlying JavaScript expression node.
78
+ * Recursively processes nodes until a non-type expression is found.
79
+ *
80
+ * @param node - The AST node to unwrap
81
+ * @returns The underlying JavaScript expression node
82
+ */
83
+ declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
84
+ //#endregion
85
+ //#region src/expression-is.d.ts
86
+ /**
87
+ * Checks if the given expression is a 'this' expression.
88
+ * Unwraps any type expressions before checking.
89
+ *
90
+ * @param node - The expression node to check
91
+ * @returns true if the expression is a ThisExpression, false otherwise
29
92
  */
30
- declare function getJSExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
31
93
  declare function isThisExpression(node: TSESTree.Expression): boolean;
32
-
33
- /**
34
- * Gets the static name of a function AST node. For function declarations it is
35
- * easy. For anonymous function expressions it is much harder. If you search for
36
- * `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
37
- * where JS gives anonymous function expressions names. We roughly detect the
38
- * same AST nodes with some exceptions to better fit our use case.
39
- */
40
- declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | _;
41
-
42
- type FunctionInitPath =
43
- /**
44
- * function Comp() { return <div />; }
45
- */
46
- readonly [TSESTree.FunctionDeclaration]
47
- /**
48
- * const Comp = () => <div />;
49
- * const Comp = function () { return <div />; };
50
- */
51
- | readonly [
52
- TSESTree.VariableDeclaration,
53
- TSESTree.VariableDeclarator,
54
- TSESTreeFunction
55
- ]
56
- /**
57
- * const Comp = React.memo(() => <div />);
58
- * const Comp = React.forwardRef(() => <div />);
59
- */
60
- | readonly [
61
- TSESTree.VariableDeclaration,
62
- TSESTree.VariableDeclarator,
63
- TSESTree.CallExpression,
64
- TSESTreeFunction
65
- ]
66
- /**
67
- * const Comp = React.memo(React.forwardRef(() => <div />));
68
- */
69
- | readonly [
70
- TSESTree.VariableDeclaration,
71
- TSESTree.VariableDeclarator,
72
- TSESTree.CallExpression,
73
- TSESTree.CallExpression,
74
- TSESTreeFunction
75
- ]
76
- /**
77
- * const Comps = {
78
- * TopNav() { return <div />; },
79
- * SidPanel: () => <div />,
80
- * }
81
- */
82
- | readonly [
83
- TSESTree.VariableDeclaration,
84
- TSESTree.VariableDeclarator,
85
- TSESTree.ObjectExpression,
86
- TSESTree.Property,
87
- TSESTreeFunction
88
- ]
89
- /**
90
- * const Comps = {
91
- * TopNav: React.memo(() => <div />),
92
- * SidPanel: React.forwardRef(() => <div />),
93
- * }
94
- */
95
- | readonly [
96
- TSESTree.VariableDeclaration,
97
- TSESTree.VariableDeclarator,
98
- TSESTree.ObjectExpression,
99
- TSESTree.Property,
100
- TSESTree.CallExpression,
101
- TSESTreeFunction
102
- ]
103
- /**
104
- * const Comps = {
105
- * TopNav: React.memo(React.forwardRef(() => <div />)),
106
- * SidPanel: React.forwardRef(React.memo(() => <div />)),
107
- * }
108
- */
109
- | readonly [
110
- TSESTree.VariableDeclaration,
111
- TSESTree.VariableDeclarator,
112
- TSESTree.ObjectExpression,
113
- TSESTree.Property,
114
- TSESTree.CallExpression,
115
- TSESTree.CallExpression,
116
- TSESTreeFunction
117
- ]
118
- /**
119
- * class Comp {
120
- * TopNav() { return <div />; }
121
- * }
122
- */
123
- | readonly [
124
- TSESTree.ClassDeclaration,
125
- TSESTree.ClassBody,
126
- TSESTree.MethodDefinition,
127
- TSESTreeFunction
128
- ]
129
- /**
130
- * class Comp {
131
- * TopNav = () => <div />;
132
- * }
133
- */
134
- | readonly [
135
- TSESTree.ClassDeclaration,
136
- TSESTree.ClassBody,
137
- TSESTree.PropertyDefinition,
138
- TSESTreeFunction
139
- ];
140
- declare function getFunctionInitPath(node: TSESTreeFunction): FunctionInitPath | _;
141
- declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
142
-
143
- declare function isEmptyFunction(node: TSESTreeFunction): boolean;
144
- declare function isImmediatelyInvokedFunction(node: TSESTreeFunction): boolean;
145
-
146
- /**
147
- * Find the parent node that satisfies the test function
148
- * @param node The AST node
149
- * @param test The test function
150
- * @returns The parent node that satisfies the test function or `_` if not found
151
- */
152
- declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | _, test: (n: TSESTree.Node) => n is A): A | _;
153
- /**
154
- * Find the parent node that satisfies the test function or `_` if not found
155
- * @param node The AST node
156
- * @param test The test function
157
- * @returns The parent node that satisfies the test function
158
- */
159
- declare function findParentNode(node: TSESTree.Node | _, test: (node: TSESTree.Node) => boolean): TSESTree.Node | _;
160
-
94
+ //#endregion
95
+ //#region src/expression-nested.d.ts
161
96
  /**
162
97
  * Get all nested identifiers in a expression like node
163
98
  * @param node The node to get the nested identifiers from
@@ -177,7 +112,7 @@ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTr
177
112
  * node, and it will return an array of all nested expressions of type T.
178
113
  */
179
114
  declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
180
- type: TNodeType;
115
+ type: TNodeType;
181
116
  }>[];
182
117
  /**
183
118
  * Get all nested new expressions in an expression like node
@@ -191,91 +126,87 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
191
126
  * @returns All nested call expressions
192
127
  */
193
128
  declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
194
-
129
+ //#endregion
130
+ //#region src/function-id.d.ts
195
131
  /**
196
- * Check if a node is multiline
197
- * @param node The AST node to check
198
- * @returns `true` if the node is multiline
132
+ * Gets the static name of a function AST node. For function declarations it is
133
+ * easy. For anonymous function expressions it is much harder. If you search for
134
+ * `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
135
+ * where JS gives anonymous function expressions names. We roughly detect the
136
+ * same AST nodes with some exceptions to better fit our use case.
199
137
  */
200
- declare function isMultiLine(node: TSESTree.Node): boolean;
138
+ declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | unit;
139
+ //#endregion
140
+ //#region src/function-init-path.d.ts
201
141
  /**
202
- * Check if a node is a line break
203
- * @param node The AST node to check
204
- * @returns boolean
142
+ * Represents various AST paths for React component function declarations.
143
+ * Each tuple type represents a specific component definition pattern.
205
144
  */
206
- declare function isLineBreak(node: TSESTree.Node): boolean;
207
-
145
+ 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.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction] | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
146
+ /**
147
+ * Identifies the initialization path of a function node in the AST.
148
+ * Determines what kind of component declaration pattern the function belongs to.
149
+ *
150
+ * @param node - The function node to analyze
151
+ * @returns The function initialization path or unit if not identifiable
152
+ */
153
+ declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
154
+ /**
155
+ * Checks if a specific function call exists in the function initialization path.
156
+ * Useful for detecting HOCs like React.memo, React.forwardRef, etc.
157
+ *
158
+ * @param callName - The name of the call to check for (e.g., "memo", "forwardRef")
159
+ * @param initPath - The function initialization path to search in
160
+ * @returns True if the call exists in the path, false otherwise
161
+ */
162
+ declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
163
+ //#endregion
164
+ //#region src/function-is.d.ts
165
+ declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
166
+ declare function isFunctionImmediatelyInvoked(node: TSESTreeFunction): boolean;
167
+ //#endregion
168
+ //#region src/literal.d.ts
208
169
  declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
209
170
  declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
210
171
  declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
211
172
  declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
212
173
  declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
213
174
  declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
214
-
175
+ //#endregion
176
+ //#region src/misc.d.ts
215
177
  /**
216
- * Determines whether node equals to another node
217
- * @param a node to compare
218
- * @param b node to compare
219
- * @returns `true` if node equal
220
- * @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
221
- */
222
- declare const isNodeEqual: {
223
- (a: TSESTree.Node): (b: TSESTree.Node) => boolean;
224
- (a: TSESTree.Node, b: TSESTree.Node): boolean;
225
- };
226
-
227
- /**
228
- * @internal
178
+ * Check if a node is multiline
179
+ * @param node The AST node to check
180
+ * @returns `true` if the node is multiline
229
181
  */
230
- declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
182
+ declare function isMultiLine(node: TSESTree.Node): boolean;
231
183
  /**
232
- * @internal
184
+ * Check if a node is a line break
185
+ * @param node The AST node to check
186
+ * @returns boolean
233
187
  */
234
- declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
235
-
236
- declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
237
- type: NodeType;
238
- }>;
239
- declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
240
- type: NodeTypes[number];
241
- }>;
242
- declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
243
- 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;
244
- declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
245
- declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
246
- declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
247
- declare const isControlFlow: (data: TSESTree.Node | null | undefined) => data is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.SwitchStatement | TSESTree.WhileStatement;
248
- 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;
249
- declare const isArrayTupleType: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSArrayType | TSESTree.TSTupleType;
250
- declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
251
- declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
252
- declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
253
- declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
254
- 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;
255
- declare const isDestructuringPattern: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
256
- declare const isTypeDeclaration: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
257
- declare const isLeftHandSideExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.CallExpression | TSESTree.ClassExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression;
258
- declare const isLeftHandSideExpressionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.CallExpression | TSESTree.ClassExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSTypeAssertion;
259
- declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
260
- declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
261
-
188
+ declare function isLineBreak(node: TSESTree.Node): boolean;
189
+ //#endregion
190
+ //#region src/promise-then.d.ts
191
+ declare function isThenCall(node: TSESTree.CallExpression): boolean;
192
+ //#endregion
193
+ //#region src/property-name.d.ts
194
+ declare function getPropertyName(node: TSESTree.Node): string | unit;
195
+ //#endregion
196
+ //#region src/traverse-up.d.ts
262
197
  /**
263
- * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
198
+ * Find the parent node that satisfies the test function
264
199
  * @param node The AST node
265
- * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
200
+ * @param test The test function
201
+ * @returns The parent node that satisfies the test function or `_` if not found
266
202
  */
267
- declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TSESTree.MemberExpression;
203
+ declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
268
204
  /**
269
- * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
205
+ * Find the parent node that satisfies the test function or `_` if not found
270
206
  * @param node The AST node
271
- * @param operator The operator used in the comparison
272
- * @param value The string literal value to compare against
273
- * @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
207
+ * @param test The test function
208
+ * @returns The parent node that satisfies the test function
274
209
  */
275
- declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | _, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
276
-
277
- declare function getPropertyName(node: TSESTree.Node): string | _;
278
-
279
- declare function isThenCall(node: TSESTree.CallExpression): boolean;
280
-
281
- export { type FunctionInitPath, type TSESTreeArrayTupleType, type TSESTreeClass, type TSESTreeDestructuringPattern, type TSESTreeFunction, type TSESTreeFunctionType, type TSESTreeJSX, type TSESTreeLoop, type TSESTreeMethodOrProperty, type TSESTreeProperty, type TSESTreeTypeAssertionExpression, type TSESTreeTypeDeclaration, type TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isImmediatelyInvokedFunction, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThenCall, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toDelimiterFormat, toStringFormat };
210
+ declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
211
+ //#endregion
212
+ export { FunctionInitPath, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isClass, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThenCall, isThisExpression, isTypeAssertionExpression, isTypeExpression, toDelimiterFormat, toStringFormat };