@eslint-react/ast 2.0.0-next.16 → 2.0.0-next.160

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 +140 -212
  2. package/dist/index.js +531 -554
  3. package/package.json +8 -9
package/dist/index.d.ts CHANGED
@@ -1,12 +1,58 @@
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
+ * @internal
32
+ */
33
+ declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
34
+ //#endregion
35
+ //#region src/node-is.d.ts
36
+ declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
37
+ type: NodeType;
38
+ }>;
39
+ declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
40
+ type: NodeTypes[number];
41
+ }>;
42
+ declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
43
+ 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;
44
+ declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
45
+ declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
46
+ declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
47
+ declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
48
+ declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
49
+ declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
50
+ 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;
51
+ declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
52
+ declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
53
+ declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
54
+ //#endregion
55
+ //#region src/node-types.d.ts
10
56
  type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
11
57
  type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
12
58
  type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
@@ -19,145 +65,31 @@ type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.Assignm
19
65
  type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
20
66
  type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
21
67
  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
68
+ //#endregion
69
+ //#region src/class-id.d.ts
70
+ declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
71
+ //#endregion
72
+ //#region src/expression-base.d.ts
73
+ /**
74
+ * Unwraps any type expressions to get the underlying JavaScript expression node.
75
+ * Recursively processes nodes until a non-type expression is found.
76
+ *
77
+ * @param node - The AST node to unwrap
78
+ * @returns The underlying JavaScript expression node
79
+ */
80
+ declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
81
+ //#endregion
82
+ //#region src/expression-is.d.ts
83
+ /**
84
+ * Checks if the given expression is a 'this' expression.
85
+ * Unwraps any type expressions before checking.
86
+ *
87
+ * @param node - The expression node to check
88
+ * @returns true if the expression is a ThisExpression, false otherwise
29
89
  */
30
- declare function getJSExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
31
90
  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
-
91
+ //#endregion
92
+ //#region src/expression-nested.d.ts
161
93
  /**
162
94
  * Get all nested identifiers in a expression like node
163
95
  * @param node The node to get the nested identifiers from
@@ -177,7 +109,7 @@ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTr
177
109
  * node, and it will return an array of all nested expressions of type T.
178
110
  */
179
111
  declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
180
- type: TNodeType;
112
+ type: TNodeType;
181
113
  }>[];
182
114
  /**
183
115
  * Get all nested new expressions in an expression like node
@@ -191,91 +123,87 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
191
123
  * @returns All nested call expressions
192
124
  */
193
125
  declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
194
-
126
+ //#endregion
127
+ //#region src/function-id.d.ts
195
128
  /**
196
- * Check if a node is multiline
197
- * @param node The AST node to check
198
- * @returns `true` if the node is multiline
129
+ * Gets the static name of a function AST node. For function declarations it is
130
+ * easy. For anonymous function expressions it is much harder. If you search for
131
+ * `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
132
+ * where JS gives anonymous function expressions names. We roughly detect the
133
+ * same AST nodes with some exceptions to better fit our use case.
199
134
  */
200
- declare function isMultiLine(node: TSESTree.Node): boolean;
135
+ declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | unit;
136
+ //#endregion
137
+ //#region src/function-init-path.d.ts
201
138
  /**
202
- * Check if a node is a line break
203
- * @param node The AST node to check
204
- * @returns boolean
139
+ * Represents various AST paths for React component function declarations.
140
+ * Each tuple type represents a specific component definition pattern.
205
141
  */
206
- declare function isLineBreak(node: TSESTree.Node): boolean;
207
-
142
+ 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];
143
+ /**
144
+ * Identifies the initialization path of a function node in the AST.
145
+ * Determines what kind of component declaration pattern the function belongs to.
146
+ *
147
+ * @param node - The function node to analyze
148
+ * @returns The function initialization path or unit if not identifiable
149
+ */
150
+ declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
151
+ /**
152
+ * Checks if a specific function call exists in the function initialization path.
153
+ * Useful for detecting HOCs like React.memo, React.forwardRef, etc.
154
+ *
155
+ * @param callName - The name of the call to check for (e.g., "memo", "forwardRef")
156
+ * @param initPath - The function initialization path to search in
157
+ * @returns True if the call exists in the path, false otherwise
158
+ */
159
+ declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
160
+ //#endregion
161
+ //#region src/function-is.d.ts
162
+ declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
163
+ declare function isFunctionImmediatelyInvoked(node: TSESTreeFunction): boolean;
164
+ //#endregion
165
+ //#region src/literal.d.ts
208
166
  declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
209
167
  declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
210
168
  declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
211
169
  declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
212
170
  declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
213
171
  declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
214
-
172
+ //#endregion
173
+ //#region src/misc.d.ts
215
174
  /**
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
175
+ * Check if a node is multiline
176
+ * @param node The AST node to check
177
+ * @returns `true` if the node is multiline
229
178
  */
230
- declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
179
+ declare function isMultiLine(node: TSESTree.Node): boolean;
231
180
  /**
232
- * @internal
181
+ * Check if a node is a line break
182
+ * @param node The AST node to check
183
+ * @returns boolean
233
184
  */
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
-
185
+ declare function isLineBreak(node: TSESTree.Node): boolean;
186
+ //#endregion
187
+ //#region src/promise-then.d.ts
188
+ declare function isThenCall(node: TSESTree.CallExpression): boolean;
189
+ //#endregion
190
+ //#region src/property-name.d.ts
191
+ declare function getPropertyName(node: TSESTree.Node): string | unit;
192
+ //#endregion
193
+ //#region src/traverse-up.d.ts
262
194
  /**
263
- * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
195
+ * Find the parent node that satisfies the test function
264
196
  * @param node The AST node
265
- * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
197
+ * @param test The test function
198
+ * @returns The parent node that satisfies the test function or `_` if not found
266
199
  */
267
- declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TSESTree.MemberExpression;
200
+ declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
268
201
  /**
269
- * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
202
+ * Find the parent node that satisfies the test function or `_` if not found
270
203
  * @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
204
+ * @param test The test function
205
+ * @returns The parent node that satisfies the test function
274
206
  */
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 };
207
+ declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
208
+ //#endregion
209
+ export { FunctionInitPath, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, 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 };