@eslint-react/ast 1.52.9 → 1.52.10-beta.1
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.mts +50 -97
- package/dist/index.d.ts +50 -97
- package/dist/index.js +520 -460
- package/dist/index.mjs +498 -459
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { unit } from
|
|
3
|
-
import { TSESTree as TSESTree$1 } from
|
|
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/ast-array-method.d.ts
|
|
5
6
|
declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
6
7
|
declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/ast-array-method-callback.d.ts
|
|
8
10
|
declare function getArrayMethodCallbackIndexParamPosition(methodName: string): number;
|
|
9
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/ast-node.d.ts
|
|
10
13
|
type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
|
|
11
14
|
type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
|
|
12
15
|
type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
|
|
@@ -19,14 +22,16 @@ type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.Assignm
|
|
|
19
22
|
type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
|
|
20
23
|
type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
|
|
21
24
|
type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
|
|
22
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/ast-class-id.d.ts
|
|
23
27
|
/**
|
|
24
28
|
* Gets class identifier from ClassDeclaration or ClassExpression
|
|
25
29
|
* @param node The AST node to check
|
|
26
30
|
* @returns class identifier or null
|
|
27
31
|
*/
|
|
28
32
|
declare function getClassId(node: TSESTreeClass): unit | TSESTree.Identifier;
|
|
29
|
-
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/ast-expression.d.ts
|
|
30
35
|
/**
|
|
31
36
|
* Recursively get the inner expression until it's not a TypeExpression
|
|
32
37
|
* @param node - The node to get the expression from
|
|
@@ -34,18 +39,12 @@ declare function getClassId(node: TSESTreeClass): unit | TSESTree.Identifier;
|
|
|
34
39
|
*/
|
|
35
40
|
declare function getJSExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
36
41
|
declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* Gets the static name of a function AST node. For function declarations it is
|
|
40
|
-
* easy. For anonymous function expressions it is much harder. If you search for
|
|
41
|
-
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
|
|
42
|
-
* where JS gives anonymous function expressions names. We roughly detect the
|
|
43
|
-
* same AST nodes with some exceptions to better fit our use case.
|
|
44
|
-
*/
|
|
45
|
-
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/ast-function-id.d.ts
|
|
46
44
|
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): unit | TSESTree.Identifier;
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/ast-function-init-path.d.ts
|
|
47
|
+
type FunctionInitPath =
|
|
49
48
|
/**
|
|
50
49
|
* function Comp() { return <div />; }
|
|
51
50
|
*/
|
|
@@ -53,101 +52,49 @@ readonly [TSESTree.FunctionDeclaration]
|
|
|
53
52
|
/**
|
|
54
53
|
* const Comp = () => <div />;
|
|
55
54
|
* const Comp = function () { return <div />; };
|
|
56
|
-
*/
|
|
57
|
-
| readonly [
|
|
58
|
-
TSESTree.VariableDeclaration,
|
|
59
|
-
TSESTree.VariableDeclarator,
|
|
60
|
-
TSESTreeFunction
|
|
61
|
-
]
|
|
55
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTreeFunction]
|
|
62
56
|
/**
|
|
63
57
|
* const Comp = React.memo(() => <div />);
|
|
64
58
|
* const Comp = React.forwardRef(() => <div />);
|
|
65
|
-
*/
|
|
66
|
-
| readonly [
|
|
67
|
-
TSESTree.VariableDeclaration,
|
|
68
|
-
TSESTree.VariableDeclarator,
|
|
69
|
-
TSESTree.CallExpression,
|
|
70
|
-
TSESTreeFunction
|
|
71
|
-
]
|
|
59
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTreeFunction]
|
|
72
60
|
/**
|
|
73
61
|
* const Comp = React.memo(React.forwardRef(() => <div />));
|
|
74
|
-
*/
|
|
75
|
-
| readonly [
|
|
76
|
-
TSESTree.VariableDeclaration,
|
|
77
|
-
TSESTree.VariableDeclarator,
|
|
78
|
-
TSESTree.CallExpression,
|
|
79
|
-
TSESTree.CallExpression,
|
|
80
|
-
TSESTreeFunction
|
|
81
|
-
]
|
|
62
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction]
|
|
82
63
|
/**
|
|
83
64
|
* const Comps = {
|
|
84
65
|
* TopNav() { return <div />; },
|
|
85
66
|
* SidPanel: () => <div />,
|
|
86
67
|
* }
|
|
87
|
-
*/
|
|
88
|
-
| readonly [
|
|
89
|
-
TSESTree.VariableDeclaration,
|
|
90
|
-
TSESTree.VariableDeclarator,
|
|
91
|
-
TSESTree.ObjectExpression,
|
|
92
|
-
TSESTree.Property,
|
|
93
|
-
TSESTreeFunction
|
|
94
|
-
]
|
|
68
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTreeFunction]
|
|
95
69
|
/**
|
|
96
70
|
* const Comps = {
|
|
97
71
|
* TopNav: React.memo(() => <div />),
|
|
98
72
|
* SidPanel: React.forwardRef(() => <div />),
|
|
99
73
|
* }
|
|
100
|
-
*/
|
|
101
|
-
| readonly [
|
|
102
|
-
TSESTree.VariableDeclaration,
|
|
103
|
-
TSESTree.VariableDeclarator,
|
|
104
|
-
TSESTree.ObjectExpression,
|
|
105
|
-
TSESTree.Property,
|
|
106
|
-
TSESTree.CallExpression,
|
|
107
|
-
TSESTreeFunction
|
|
108
|
-
]
|
|
74
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTreeFunction]
|
|
109
75
|
/**
|
|
110
76
|
* const Comps = {
|
|
111
77
|
* TopNav: React.memo(React.forwardRef(() => <div />)),
|
|
112
78
|
* SidPanel: React.forwardRef(React.memo(() => <div />)),
|
|
113
79
|
* }
|
|
114
|
-
*/
|
|
115
|
-
| readonly [
|
|
116
|
-
TSESTree.VariableDeclaration,
|
|
117
|
-
TSESTree.VariableDeclarator,
|
|
118
|
-
TSESTree.ObjectExpression,
|
|
119
|
-
TSESTree.Property,
|
|
120
|
-
TSESTree.CallExpression,
|
|
121
|
-
TSESTree.CallExpression,
|
|
122
|
-
TSESTreeFunction
|
|
123
|
-
]
|
|
80
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction]
|
|
124
81
|
/**
|
|
125
82
|
* class Comp {
|
|
126
83
|
* TopNav() { return <div />; }
|
|
127
84
|
* }
|
|
128
|
-
*/
|
|
129
|
-
| readonly [
|
|
130
|
-
TSESTree.ClassDeclaration,
|
|
131
|
-
TSESTree.ClassBody,
|
|
132
|
-
TSESTree.MethodDefinition,
|
|
133
|
-
TSESTreeFunction
|
|
134
|
-
]
|
|
85
|
+
*/ | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction]
|
|
135
86
|
/**
|
|
136
87
|
* class Comp {
|
|
137
88
|
* TopNav = () => <div />;
|
|
138
89
|
* }
|
|
139
|
-
*/
|
|
140
|
-
| readonly [
|
|
141
|
-
TSESTree.ClassDeclaration,
|
|
142
|
-
TSESTree.ClassBody,
|
|
143
|
-
TSESTree.PropertyDefinition,
|
|
144
|
-
TSESTreeFunction
|
|
145
|
-
];
|
|
90
|
+
*/ | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
|
|
146
91
|
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
147
92
|
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
148
|
-
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/ast-function-is.d.ts
|
|
149
95
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
150
|
-
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/ast-hierarchy.d.ts
|
|
151
98
|
/**
|
|
152
99
|
* Find the parent node that satisfies the test function
|
|
153
100
|
* @param node The AST node
|
|
@@ -162,7 +109,6 @@ declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | u
|
|
|
162
109
|
* @returns The parent node that satisfies the test function
|
|
163
110
|
*/
|
|
164
111
|
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
165
|
-
|
|
166
112
|
/**
|
|
167
113
|
* Get all nested identifiers in a expression like node
|
|
168
114
|
* @param node The node to get the nested identifiers from
|
|
@@ -182,7 +128,7 @@ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTr
|
|
|
182
128
|
* node, and it will return an array of all nested expressions of type T.
|
|
183
129
|
*/
|
|
184
130
|
declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
|
|
185
|
-
|
|
131
|
+
type: TNodeType;
|
|
186
132
|
}>[];
|
|
187
133
|
/**
|
|
188
134
|
* Get all nested new expressions in an expression like node
|
|
@@ -196,12 +142,13 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
|
|
|
196
142
|
* @returns All nested call expressions
|
|
197
143
|
*/
|
|
198
144
|
declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
|
|
199
|
-
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/ast-is.d.ts
|
|
200
147
|
declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
201
|
-
|
|
148
|
+
type: NodeType;
|
|
202
149
|
}>;
|
|
203
150
|
declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
204
|
-
|
|
151
|
+
type: NodeTypes[number];
|
|
205
152
|
}>;
|
|
206
153
|
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
207
154
|
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;
|
|
@@ -215,7 +162,8 @@ declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTre
|
|
|
215
162
|
declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
|
|
216
163
|
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
217
164
|
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
218
|
-
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/ast-line.d.ts
|
|
219
167
|
/**
|
|
220
168
|
* Check if a node is multiline
|
|
221
169
|
* @param node The AST node to check
|
|
@@ -228,14 +176,16 @@ declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
|
228
176
|
* @returns boolean
|
|
229
177
|
*/
|
|
230
178
|
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
231
|
-
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/ast-literal-is.d.ts
|
|
232
181
|
declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
|
|
233
182
|
declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
|
|
234
183
|
declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
|
|
235
184
|
declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
|
|
236
185
|
declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
|
|
237
186
|
declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
|
|
238
|
-
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/ast-node-equal.d.ts
|
|
239
189
|
/**
|
|
240
190
|
* Determines whether node equals to another node
|
|
241
191
|
* @param a node to compare
|
|
@@ -244,10 +194,11 @@ declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTre
|
|
|
244
194
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
245
195
|
*/
|
|
246
196
|
declare const isNodeEqual: {
|
|
247
|
-
|
|
248
|
-
|
|
197
|
+
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
198
|
+
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
249
199
|
};
|
|
250
|
-
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/ast-process-env-node-env.d.ts
|
|
251
202
|
/**
|
|
252
203
|
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
253
204
|
* @param node The AST node
|
|
@@ -262,9 +213,11 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is
|
|
|
262
213
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
263
214
|
*/
|
|
264
215
|
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
265
|
-
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/ast-property-name.d.ts
|
|
266
218
|
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
267
|
-
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/ast-to-string.d.ts
|
|
268
221
|
declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
269
222
|
/**
|
|
270
223
|
* Returns human readable node name for given AST node
|
|
@@ -273,5 +226,5 @@ declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "
|
|
|
273
226
|
* @returns Human readable node name
|
|
274
227
|
*/
|
|
275
228
|
declare function toString(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
276
|
-
|
|
277
|
-
export {
|
|
229
|
+
//#endregion
|
|
230
|
+
export { FunctionInitPath, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isClass, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpression, isTypeAssertionExpression, isTypeExpression, toDelimiterCaseType, toString };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { unit } from
|
|
3
|
-
import { TSESTree as TSESTree$1 } from
|
|
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/ast-array-method.d.ts
|
|
5
6
|
declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
6
7
|
declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/ast-array-method-callback.d.ts
|
|
8
10
|
declare function getArrayMethodCallbackIndexParamPosition(methodName: string): number;
|
|
9
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/ast-node.d.ts
|
|
10
13
|
type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
|
|
11
14
|
type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
|
|
12
15
|
type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
|
|
@@ -19,14 +22,16 @@ type TSESTreeDestructuringPattern = TSESTree$1.ArrayPattern | TSESTree$1.Assignm
|
|
|
19
22
|
type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TSTypeAliasDeclaration;
|
|
20
23
|
type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
|
|
21
24
|
type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
|
|
22
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/ast-class-id.d.ts
|
|
23
27
|
/**
|
|
24
28
|
* Gets class identifier from ClassDeclaration or ClassExpression
|
|
25
29
|
* @param node The AST node to check
|
|
26
30
|
* @returns class identifier or null
|
|
27
31
|
*/
|
|
28
32
|
declare function getClassId(node: TSESTreeClass): unit | TSESTree.Identifier;
|
|
29
|
-
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/ast-expression.d.ts
|
|
30
35
|
/**
|
|
31
36
|
* Recursively get the inner expression until it's not a TypeExpression
|
|
32
37
|
* @param node - The node to get the expression from
|
|
@@ -34,18 +39,12 @@ declare function getClassId(node: TSESTreeClass): unit | TSESTree.Identifier;
|
|
|
34
39
|
*/
|
|
35
40
|
declare function getJSExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
|
|
36
41
|
declare function isThisExpression(node: TSESTree.Expression): boolean;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* Gets the static name of a function AST node. For function declarations it is
|
|
40
|
-
* easy. For anonymous function expressions it is much harder. If you search for
|
|
41
|
-
* `IsAnonymousFunctionDefinition()` in the ECMAScript spec you'll find places
|
|
42
|
-
* where JS gives anonymous function expressions names. We roughly detect the
|
|
43
|
-
* same AST nodes with some exceptions to better fit our use case.
|
|
44
|
-
*/
|
|
45
|
-
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/ast-function-id.d.ts
|
|
46
44
|
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): unit | TSESTree.Identifier;
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/ast-function-init-path.d.ts
|
|
47
|
+
type FunctionInitPath =
|
|
49
48
|
/**
|
|
50
49
|
* function Comp() { return <div />; }
|
|
51
50
|
*/
|
|
@@ -53,101 +52,49 @@ readonly [TSESTree.FunctionDeclaration]
|
|
|
53
52
|
/**
|
|
54
53
|
* const Comp = () => <div />;
|
|
55
54
|
* const Comp = function () { return <div />; };
|
|
56
|
-
*/
|
|
57
|
-
| readonly [
|
|
58
|
-
TSESTree.VariableDeclaration,
|
|
59
|
-
TSESTree.VariableDeclarator,
|
|
60
|
-
TSESTreeFunction
|
|
61
|
-
]
|
|
55
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTreeFunction]
|
|
62
56
|
/**
|
|
63
57
|
* const Comp = React.memo(() => <div />);
|
|
64
58
|
* const Comp = React.forwardRef(() => <div />);
|
|
65
|
-
*/
|
|
66
|
-
| readonly [
|
|
67
|
-
TSESTree.VariableDeclaration,
|
|
68
|
-
TSESTree.VariableDeclarator,
|
|
69
|
-
TSESTree.CallExpression,
|
|
70
|
-
TSESTreeFunction
|
|
71
|
-
]
|
|
59
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTreeFunction]
|
|
72
60
|
/**
|
|
73
61
|
* const Comp = React.memo(React.forwardRef(() => <div />));
|
|
74
|
-
*/
|
|
75
|
-
| readonly [
|
|
76
|
-
TSESTree.VariableDeclaration,
|
|
77
|
-
TSESTree.VariableDeclarator,
|
|
78
|
-
TSESTree.CallExpression,
|
|
79
|
-
TSESTree.CallExpression,
|
|
80
|
-
TSESTreeFunction
|
|
81
|
-
]
|
|
62
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction]
|
|
82
63
|
/**
|
|
83
64
|
* const Comps = {
|
|
84
65
|
* TopNav() { return <div />; },
|
|
85
66
|
* SidPanel: () => <div />,
|
|
86
67
|
* }
|
|
87
|
-
*/
|
|
88
|
-
| readonly [
|
|
89
|
-
TSESTree.VariableDeclaration,
|
|
90
|
-
TSESTree.VariableDeclarator,
|
|
91
|
-
TSESTree.ObjectExpression,
|
|
92
|
-
TSESTree.Property,
|
|
93
|
-
TSESTreeFunction
|
|
94
|
-
]
|
|
68
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTreeFunction]
|
|
95
69
|
/**
|
|
96
70
|
* const Comps = {
|
|
97
71
|
* TopNav: React.memo(() => <div />),
|
|
98
72
|
* SidPanel: React.forwardRef(() => <div />),
|
|
99
73
|
* }
|
|
100
|
-
*/
|
|
101
|
-
| readonly [
|
|
102
|
-
TSESTree.VariableDeclaration,
|
|
103
|
-
TSESTree.VariableDeclarator,
|
|
104
|
-
TSESTree.ObjectExpression,
|
|
105
|
-
TSESTree.Property,
|
|
106
|
-
TSESTree.CallExpression,
|
|
107
|
-
TSESTreeFunction
|
|
108
|
-
]
|
|
74
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTreeFunction]
|
|
109
75
|
/**
|
|
110
76
|
* const Comps = {
|
|
111
77
|
* TopNav: React.memo(React.forwardRef(() => <div />)),
|
|
112
78
|
* SidPanel: React.forwardRef(React.memo(() => <div />)),
|
|
113
79
|
* }
|
|
114
|
-
*/
|
|
115
|
-
| readonly [
|
|
116
|
-
TSESTree.VariableDeclaration,
|
|
117
|
-
TSESTree.VariableDeclarator,
|
|
118
|
-
TSESTree.ObjectExpression,
|
|
119
|
-
TSESTree.Property,
|
|
120
|
-
TSESTree.CallExpression,
|
|
121
|
-
TSESTree.CallExpression,
|
|
122
|
-
TSESTreeFunction
|
|
123
|
-
]
|
|
80
|
+
*/ | readonly [TSESTree.VariableDeclaration, TSESTree.VariableDeclarator, TSESTree.ObjectExpression, TSESTree.Property, TSESTree.CallExpression, TSESTree.CallExpression, TSESTreeFunction]
|
|
124
81
|
/**
|
|
125
82
|
* class Comp {
|
|
126
83
|
* TopNav() { return <div />; }
|
|
127
84
|
* }
|
|
128
|
-
*/
|
|
129
|
-
| readonly [
|
|
130
|
-
TSESTree.ClassDeclaration,
|
|
131
|
-
TSESTree.ClassBody,
|
|
132
|
-
TSESTree.MethodDefinition,
|
|
133
|
-
TSESTreeFunction
|
|
134
|
-
]
|
|
85
|
+
*/ | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.MethodDefinition, TSESTreeFunction]
|
|
135
86
|
/**
|
|
136
87
|
* class Comp {
|
|
137
88
|
* TopNav = () => <div />;
|
|
138
89
|
* }
|
|
139
|
-
*/
|
|
140
|
-
| readonly [
|
|
141
|
-
TSESTree.ClassDeclaration,
|
|
142
|
-
TSESTree.ClassBody,
|
|
143
|
-
TSESTree.PropertyDefinition,
|
|
144
|
-
TSESTreeFunction
|
|
145
|
-
];
|
|
90
|
+
*/ | readonly [TSESTree.ClassDeclaration, TSESTree.ClassBody, TSESTree.PropertyDefinition, TSESTreeFunction];
|
|
146
91
|
declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
|
|
147
92
|
declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
148
|
-
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/ast-function-is.d.ts
|
|
149
95
|
declare function isEmptyFunction(node: TSESTreeFunction): boolean;
|
|
150
|
-
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/ast-hierarchy.d.ts
|
|
151
98
|
/**
|
|
152
99
|
* Find the parent node that satisfies the test function
|
|
153
100
|
* @param node The AST node
|
|
@@ -162,7 +109,6 @@ declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | u
|
|
|
162
109
|
* @returns The parent node that satisfies the test function
|
|
163
110
|
*/
|
|
164
111
|
declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
|
|
165
|
-
|
|
166
112
|
/**
|
|
167
113
|
* Get all nested identifiers in a expression like node
|
|
168
114
|
* @param node The node to get the nested identifiers from
|
|
@@ -182,7 +128,7 @@ declare function getNestedReturnStatements(node: TSESTree.Node): readonly TSESTr
|
|
|
182
128
|
* node, and it will return an array of all nested expressions of type T.
|
|
183
129
|
*/
|
|
184
130
|
declare function getNestedExpressionsOfType<TNodeType extends AST_NODE_TYPES>(type: TNodeType): (node: TSESTree.Node) => Extract<TSESTree.Node, {
|
|
185
|
-
|
|
131
|
+
type: TNodeType;
|
|
186
132
|
}>[];
|
|
187
133
|
/**
|
|
188
134
|
* Get all nested new expressions in an expression like node
|
|
@@ -196,12 +142,13 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
|
|
|
196
142
|
* @returns All nested call expressions
|
|
197
143
|
*/
|
|
198
144
|
declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
|
|
199
|
-
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/ast-is.d.ts
|
|
200
147
|
declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
201
|
-
|
|
148
|
+
type: NodeType;
|
|
202
149
|
}>;
|
|
203
150
|
declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
204
|
-
|
|
151
|
+
type: NodeTypes[number];
|
|
205
152
|
}>;
|
|
206
153
|
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
207
154
|
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;
|
|
@@ -215,7 +162,8 @@ declare const isJSX: (node: TSESTree.Node | null | undefined) => node is TSESTre
|
|
|
215
162
|
declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
|
|
216
163
|
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
217
164
|
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
218
|
-
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/ast-line.d.ts
|
|
219
167
|
/**
|
|
220
168
|
* Check if a node is multiline
|
|
221
169
|
* @param node The AST node to check
|
|
@@ -228,14 +176,16 @@ declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
|
228
176
|
* @returns boolean
|
|
229
177
|
*/
|
|
230
178
|
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
231
|
-
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/ast-literal-is.d.ts
|
|
232
181
|
declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
|
|
233
182
|
declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
|
|
234
183
|
declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
|
|
235
184
|
declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
|
|
236
185
|
declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
|
|
237
186
|
declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
|
|
238
|
-
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/ast-node-equal.d.ts
|
|
239
189
|
/**
|
|
240
190
|
* Determines whether node equals to another node
|
|
241
191
|
* @param a node to compare
|
|
@@ -244,10 +194,11 @@ declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTre
|
|
|
244
194
|
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
245
195
|
*/
|
|
246
196
|
declare const isNodeEqual: {
|
|
247
|
-
|
|
248
|
-
|
|
197
|
+
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
198
|
+
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
249
199
|
};
|
|
250
|
-
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/ast-process-env-node-env.d.ts
|
|
251
202
|
/**
|
|
252
203
|
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
253
204
|
* @param node The AST node
|
|
@@ -262,9 +213,11 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is
|
|
|
262
213
|
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
263
214
|
*/
|
|
264
215
|
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
265
|
-
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/ast-property-name.d.ts
|
|
266
218
|
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
267
|
-
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/ast-to-string.d.ts
|
|
268
221
|
declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
269
222
|
/**
|
|
270
223
|
* Returns human readable node name for given AST node
|
|
@@ -273,5 +226,5 @@ declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "
|
|
|
273
226
|
* @returns Human readable node name
|
|
274
227
|
*/
|
|
275
228
|
declare function toString(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
276
|
-
|
|
277
|
-
export {
|
|
229
|
+
//#endregion
|
|
230
|
+
export { FunctionInitPath, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getArrayMethodCallbackIndexParamPosition, getClassId, getFunctionId, getFunctionInitPath, getJSExpression, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, hasCallInFunctionInitPath, is, isArrayFromCall, isArrayMapCall, isClass, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpression, isTypeAssertionExpression, isTypeExpression, toDelimiterCaseType, toString };
|