@eslint-react/ast 2.0.0-next.16 → 2.0.0-next.162
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/index.d.ts +142 -212
- package/dist/index.js +533 -554
- package/package.json +8 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
-
|
|
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;
|
|
@@ -19,145 +67,31 @@ type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.Assignm
|
|
|
19
67
|
type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
|
|
20
68
|
type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
|
|
21
69
|
type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/class-id.d.ts
|
|
72
|
+
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/expression-base.d.ts
|
|
75
|
+
/**
|
|
76
|
+
* Unwraps any type expressions to get the underlying JavaScript expression node.
|
|
77
|
+
* Recursively processes nodes until a non-type expression is found.
|
|
78
|
+
*
|
|
79
|
+
* @param node - The AST node to unwrap
|
|
80
|
+
* @returns The underlying JavaScript expression node
|
|
81
|
+
*/
|
|
82
|
+
declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/expression-is.d.ts
|
|
85
|
+
/**
|
|
86
|
+
* Checks if the given expression is a 'this' expression.
|
|
87
|
+
* Unwraps any type expressions before checking.
|
|
88
|
+
*
|
|
89
|
+
* @param node - The expression node to check
|
|
90
|
+
* @returns true if the expression is a ThisExpression, false otherwise
|
|
29
91
|
*/
|
|
30
|
-
declare function getJSExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
31
92
|
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
|
-
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/expression-nested.d.ts
|
|
161
95
|
/**
|
|
162
96
|
* Get all nested identifiers in a expression like node
|
|
163
97
|
* @param node The node to get the nested identifiers from
|
|
@@ -177,7 +111,7 @@ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTr
|
|
|
177
111
|
* node, and it will return an array of all nested expressions of type T.
|
|
178
112
|
*/
|
|
179
113
|
declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
|
|
180
|
-
|
|
114
|
+
type: TNodeType;
|
|
181
115
|
}>[];
|
|
182
116
|
/**
|
|
183
117
|
* Get all nested new expressions in an expression like node
|
|
@@ -191,91 +125,87 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
|
|
|
191
125
|
* @returns All nested call expressions
|
|
192
126
|
*/
|
|
193
127
|
declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
|
|
194
|
-
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/function-id.d.ts
|
|
195
130
|
/**
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
131
|
+
* Gets the static name of a function AST node. For function declarations it is
|
|
132
|
+
* easy. For anonymous function expressions it is much harder. If you search for
|
|
133
|
+
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
|
|
134
|
+
* where JS gives anonymous function expressions names. We roughly detect the
|
|
135
|
+
* same AST nodes with some exceptions to better fit our use case.
|
|
199
136
|
*/
|
|
200
|
-
declare function
|
|
137
|
+
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | unit;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/function-init-path.d.ts
|
|
201
140
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* @returns boolean
|
|
141
|
+
* Represents various AST paths for React component function declarations.
|
|
142
|
+
* Each tuple type represents a specific component definition pattern.
|
|
205
143
|
*/
|
|
206
|
-
|
|
207
|
-
|
|
144
|
+
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];
|
|
145
|
+
/**
|
|
146
|
+
* Identifies the initialization path of a function node in the AST.
|
|
147
|
+
* Determines what kind of component declaration pattern the function belongs to.
|
|
148
|
+
*
|
|
149
|
+
* @param node - The function node to analyze
|
|
150
|
+
* @returns The function initialization path or unit if not identifiable
|
|
151
|
+
*/
|
|
152
|
+
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
153
|
+
/**
|
|
154
|
+
* Checks if a specific function call exists in the function initialization path.
|
|
155
|
+
* Useful for detecting HOCs like React.memo, React.forwardRef, etc.
|
|
156
|
+
*
|
|
157
|
+
* @param callName - The name of the call to check for (e.g., "memo", "forwardRef")
|
|
158
|
+
* @param initPath - The function initialization path to search in
|
|
159
|
+
* @returns True if the call exists in the path, false otherwise
|
|
160
|
+
*/
|
|
161
|
+
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/function-is.d.ts
|
|
164
|
+
declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
|
|
165
|
+
declare function isFunctionImmediatelyInvoked(node: TSESTreeFunction): boolean;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/literal.d.ts
|
|
208
168
|
declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
|
|
209
169
|
declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
|
|
210
170
|
declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
|
|
211
171
|
declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
|
|
212
172
|
declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
|
|
213
173
|
declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
|
|
214
|
-
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/misc.d.ts
|
|
215
176
|
/**
|
|
216
|
-
*
|
|
217
|
-
* @param
|
|
218
|
-
* @
|
|
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
|
|
177
|
+
* Check if a node is multiline
|
|
178
|
+
* @param node The AST node to check
|
|
179
|
+
* @returns `true` if the node is multiline
|
|
229
180
|
*/
|
|
230
|
-
declare function
|
|
181
|
+
declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
231
182
|
/**
|
|
232
|
-
*
|
|
183
|
+
* Check if a node is a line break
|
|
184
|
+
* @param node The AST node to check
|
|
185
|
+
* @returns boolean
|
|
233
186
|
*/
|
|
234
|
-
declare function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
187
|
+
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/promise-then.d.ts
|
|
190
|
+
declare function isThenCall(node: TSESTree.CallExpression): boolean;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/property-name.d.ts
|
|
193
|
+
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/traverse-up.d.ts
|
|
262
196
|
/**
|
|
263
|
-
*
|
|
197
|
+
* Find the parent node that satisfies the test function
|
|
264
198
|
* @param node The AST node
|
|
265
|
-
* @
|
|
199
|
+
* @param test The test function
|
|
200
|
+
* @returns The parent node that satisfies the test function or `_` if not found
|
|
266
201
|
*/
|
|
267
|
-
declare function
|
|
202
|
+
declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
|
|
268
203
|
/**
|
|
269
|
-
*
|
|
204
|
+
* Find the parent node that satisfies the test function or `_` if not found
|
|
270
205
|
* @param node The AST node
|
|
271
|
-
* @param
|
|
272
|
-
* @
|
|
273
|
-
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
206
|
+
* @param test The test function
|
|
207
|
+
* @returns The parent node that satisfies the test function
|
|
274
208
|
*/
|
|
275
|
-
declare function
|
|
276
|
-
|
|
277
|
-
|
|
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 };
|
|
209
|
+
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
210
|
+
//#endregion
|
|
211
|
+
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 };
|