@eslint-react/ast 2.5.1-next.0 → 2.5.1-next.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.ts +62 -60
- package/dist/index.js +67 -61
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare function getArrayMethodCallbackIndexParamPosition(methodName: string): n
|
|
|
9
9
|
declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
10
10
|
declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region src/
|
|
12
|
+
//#region src/types.d.ts
|
|
13
13
|
type TSESTreeFunction = TSESTree$1.ArrowFunctionExpression | TSESTree$1.FunctionDeclaration | TSESTree$1.FunctionExpression;
|
|
14
14
|
type TSESTreeFunctionType = TSESTree$1.TSCallSignatureDeclaration | TSESTree$1.TSConstructSignatureDeclaration | TSESTree$1.TSDeclareFunction | TSESTree$1.TSEmptyBodyFunctionExpression | TSESTree$1.TSFunctionType | TSESTree$1.TSMethodSignature | TSESTreeFunction;
|
|
15
15
|
type TSESTreeClass = TSESTree$1.ClassDeclaration | TSESTree$1.ClassExpression;
|
|
@@ -27,6 +27,19 @@ type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TS
|
|
|
27
27
|
//#region src/class-id.d.ts
|
|
28
28
|
declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
|
|
29
29
|
//#endregion
|
|
30
|
+
//#region src/equal.d.ts
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether node equals to another node
|
|
33
|
+
* @param a node to compare
|
|
34
|
+
* @param b node to compare
|
|
35
|
+
* @returns `true` if node equal
|
|
36
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
37
|
+
*/
|
|
38
|
+
declare const isNodeEqual: {
|
|
39
|
+
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
40
|
+
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
30
43
|
//#region src/expression-base.d.ts
|
|
31
44
|
/**
|
|
32
45
|
* Unwraps any type expressions to get the underlying JavaScript expression node.
|
|
@@ -120,6 +133,28 @@ declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionI
|
|
|
120
133
|
declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
|
|
121
134
|
declare function isFunctionImmediatelyInvoked(node: TSESTreeFunction): boolean;
|
|
122
135
|
//#endregion
|
|
136
|
+
//#region src/is.d.ts
|
|
137
|
+
declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
138
|
+
type: NodeType;
|
|
139
|
+
}>;
|
|
140
|
+
declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
|
|
141
|
+
type: NodeTypes[number];
|
|
142
|
+
}>;
|
|
143
|
+
declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
|
|
144
|
+
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;
|
|
145
|
+
declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
|
|
146
|
+
declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
|
|
147
|
+
declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
|
|
148
|
+
declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
|
|
149
|
+
declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
|
|
150
|
+
declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
|
|
151
|
+
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;
|
|
152
|
+
declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
|
|
153
|
+
declare const isControlFlow: (data: TSESTree.Node | null | undefined) => data is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.SwitchStatement | TSESTree.WhileStatement;
|
|
154
|
+
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;
|
|
155
|
+
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
156
|
+
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
157
|
+
//#endregion
|
|
123
158
|
//#region src/literal.d.ts
|
|
124
159
|
declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
|
|
125
160
|
declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
|
|
@@ -141,55 +176,41 @@ declare function isMultiLine(node: TSESTree.Node): boolean;
|
|
|
141
176
|
* @returns boolean
|
|
142
177
|
*/
|
|
143
178
|
declare function isLineBreak(node: TSESTree.Node): boolean;
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/node-equal.d.ts
|
|
146
179
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
150
|
-
* @returns
|
|
151
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
152
|
-
*/
|
|
153
|
-
declare const isNodeEqual: {
|
|
154
|
-
(a: TSESTree.Node): (b: TSESTree.Node) => boolean;
|
|
155
|
-
(a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
156
|
-
};
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/node-format.d.ts
|
|
159
|
-
/**
|
|
160
|
-
* @internal
|
|
180
|
+
* Convert a node type to a delimiter format string
|
|
181
|
+
* @param node The AST node
|
|
182
|
+
* @param delimiter The delimiter to use
|
|
183
|
+
* @returns The delimiter format string
|
|
161
184
|
*/
|
|
162
185
|
declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
|
|
163
186
|
/**
|
|
164
187
|
* Incomplete but sufficient stringification of AST nodes for common use cases
|
|
165
|
-
*
|
|
166
|
-
* @
|
|
188
|
+
* @param node The AST node
|
|
189
|
+
* @param getText A function to get the text representation of a node
|
|
190
|
+
* @returns A string representation of the node
|
|
167
191
|
*/
|
|
168
192
|
declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
|
|
169
193
|
//#endregion
|
|
170
|
-
//#region src/node-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
declare
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
declare
|
|
188
|
-
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;
|
|
189
|
-
declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
190
|
-
declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
|
|
194
|
+
//#region src/process-env-node-env.d.ts
|
|
195
|
+
/**
|
|
196
|
+
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
197
|
+
* @param node The AST node
|
|
198
|
+
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
199
|
+
*/
|
|
200
|
+
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
201
|
+
/**
|
|
202
|
+
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
|
|
203
|
+
* @param node The AST node
|
|
204
|
+
* @param operator The operator used in the comparison
|
|
205
|
+
* @param value The string literal value to compare against
|
|
206
|
+
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
207
|
+
*/
|
|
208
|
+
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/property-name.d.ts
|
|
211
|
+
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
191
212
|
//#endregion
|
|
192
|
-
//#region src/
|
|
213
|
+
//#region src/selectors.d.ts
|
|
193
214
|
type ImplicitReturnArrowFunctionExpression = TSESTree$1.ArrowFunctionExpression & {
|
|
194
215
|
body: TSESTree$1.Expression;
|
|
195
216
|
};
|
|
@@ -211,25 +232,6 @@ declare const SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpr
|
|
|
211
232
|
declare const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR: string;
|
|
212
233
|
declare const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION: string;
|
|
213
234
|
//#endregion
|
|
214
|
-
//#region src/process-env-node-env.d.ts
|
|
215
|
-
/**
|
|
216
|
-
* Check if the given node is a member expression that accesses `process.env.NODE_ENV`
|
|
217
|
-
* @param node The AST node
|
|
218
|
-
* @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
|
|
219
|
-
*/
|
|
220
|
-
declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
|
|
221
|
-
/**
|
|
222
|
-
* Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal.
|
|
223
|
-
* @param node The AST node
|
|
224
|
-
* @param operator The operator used in the comparison
|
|
225
|
-
* @param value The string literal value to compare against
|
|
226
|
-
* @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
|
|
227
|
-
*/
|
|
228
|
-
declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/property-name.d.ts
|
|
231
|
-
declare function getPropertyName(node: TSESTree.Node): string | unit;
|
|
232
|
-
//#endregion
|
|
233
235
|
//#region src/traverse.d.ts
|
|
234
236
|
/**
|
|
235
237
|
* Find the parent node that satisfies the test function
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ function getClassId(node) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
//#endregion
|
|
52
|
-
//#region src/
|
|
52
|
+
//#region src/is.ts
|
|
53
53
|
const is = ASTUtils.isNodeOfType;
|
|
54
54
|
const isOneOf = ASTUtils.isNodeOfTypes;
|
|
55
55
|
const isFunction = isOneOf([
|
|
@@ -137,6 +137,47 @@ function getUnderlyingExpression(node) {
|
|
|
137
137
|
return node;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/equal.ts
|
|
142
|
+
/**
|
|
143
|
+
* Determines whether node equals to another node
|
|
144
|
+
* @param a node to compare
|
|
145
|
+
* @param b node to compare
|
|
146
|
+
* @returns `true` if node equal
|
|
147
|
+
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
148
|
+
*/
|
|
149
|
+
const isNodeEqual = dual(2, (a, b) => {
|
|
150
|
+
a = isTypeExpression(a) ? getUnderlyingExpression(a) : a;
|
|
151
|
+
b = isTypeExpression(b) ? getUnderlyingExpression(b) : b;
|
|
152
|
+
switch (true) {
|
|
153
|
+
case a === b: return true;
|
|
154
|
+
case a.type !== b.type: return false;
|
|
155
|
+
case a.type === AST_NODE_TYPES.Literal && b.type === AST_NODE_TYPES.Literal: return a.value === b.value;
|
|
156
|
+
case a.type === AST_NODE_TYPES.TemplateElement && b.type === AST_NODE_TYPES.TemplateElement: return a.value.raw === b.value.raw;
|
|
157
|
+
case a.type === AST_NODE_TYPES.TemplateLiteral && b.type === AST_NODE_TYPES.TemplateLiteral: {
|
|
158
|
+
if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) return false;
|
|
159
|
+
let i = a.quasis.length;
|
|
160
|
+
while (i--) if (a.quasis[i]?.value.raw !== b.quasis[i]?.value.raw) return false;
|
|
161
|
+
i = a.expressions.length;
|
|
162
|
+
while (i--) {
|
|
163
|
+
const exprA = a.expressions[i];
|
|
164
|
+
const exprB = b.expressions[i];
|
|
165
|
+
if (!isNodeEqual(exprA, exprB)) return false;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
case a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier: return a.name === b.name;
|
|
170
|
+
case a.type === AST_NODE_TYPES.PrivateIdentifier && b.type === AST_NODE_TYPES.PrivateIdentifier: return a.name === b.name;
|
|
171
|
+
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
|
|
172
|
+
case a.type === AST_NODE_TYPES.JSXAttribute && b.type === AST_NODE_TYPES.JSXAttribute:
|
|
173
|
+
if (a.name.name !== b.name.name) return false;
|
|
174
|
+
if (a.value == null || b.value == null) return a.value === b.value;
|
|
175
|
+
return isNodeEqual(a.value, b.value);
|
|
176
|
+
case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression: return true;
|
|
177
|
+
default: return false;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
140
181
|
//#endregion
|
|
141
182
|
//#region src/expression-is.ts
|
|
142
183
|
/**
|
|
@@ -479,56 +520,20 @@ function isMultiLine(node) {
|
|
|
479
520
|
function isLineBreak(node) {
|
|
480
521
|
return isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
|
|
481
522
|
}
|
|
482
|
-
|
|
483
|
-
//#endregion
|
|
484
|
-
//#region src/node-equal.ts
|
|
485
523
|
/**
|
|
486
|
-
*
|
|
487
|
-
* @param
|
|
488
|
-
* @
|
|
489
|
-
* @returns `true` if node equal
|
|
490
|
-
* @see https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/util/isNodeEqual.ts
|
|
524
|
+
* Get the type of a literal value
|
|
525
|
+
* @param input The literal value
|
|
526
|
+
* @returns The type of the literal value
|
|
491
527
|
*/
|
|
492
|
-
const isNodeEqual = dual(2, (a, b) => {
|
|
493
|
-
a = isTypeExpression(a) ? getUnderlyingExpression(a) : a;
|
|
494
|
-
b = isTypeExpression(b) ? getUnderlyingExpression(b) : b;
|
|
495
|
-
switch (true) {
|
|
496
|
-
case a === b: return true;
|
|
497
|
-
case a.type !== b.type: return false;
|
|
498
|
-
case a.type === AST_NODE_TYPES.Literal && b.type === AST_NODE_TYPES.Literal: return a.value === b.value;
|
|
499
|
-
case a.type === AST_NODE_TYPES.TemplateElement && b.type === AST_NODE_TYPES.TemplateElement: return a.value.raw === b.value.raw;
|
|
500
|
-
case a.type === AST_NODE_TYPES.TemplateLiteral && b.type === AST_NODE_TYPES.TemplateLiteral: {
|
|
501
|
-
if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) return false;
|
|
502
|
-
let i = a.quasis.length;
|
|
503
|
-
while (i--) if (a.quasis[i]?.value.raw !== b.quasis[i]?.value.raw) return false;
|
|
504
|
-
i = a.expressions.length;
|
|
505
|
-
while (i--) {
|
|
506
|
-
const exprA = a.expressions[i];
|
|
507
|
-
const exprB = b.expressions[i];
|
|
508
|
-
if (!isNodeEqual(exprA, exprB)) return false;
|
|
509
|
-
}
|
|
510
|
-
return true;
|
|
511
|
-
}
|
|
512
|
-
case a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier: return a.name === b.name;
|
|
513
|
-
case a.type === AST_NODE_TYPES.PrivateIdentifier && b.type === AST_NODE_TYPES.PrivateIdentifier: return a.name === b.name;
|
|
514
|
-
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
|
|
515
|
-
case a.type === AST_NODE_TYPES.JSXAttribute && b.type === AST_NODE_TYPES.JSXAttribute:
|
|
516
|
-
if (a.name.name !== b.name.name) return false;
|
|
517
|
-
if (a.value == null || b.value == null) return a.value === b.value;
|
|
518
|
-
return isNodeEqual(a.value, b.value);
|
|
519
|
-
case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression: return true;
|
|
520
|
-
default: return false;
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
//#endregion
|
|
525
|
-
//#region src/node-format.ts
|
|
526
528
|
function getLiteralValueType(input) {
|
|
527
529
|
if (input === null) return "null";
|
|
528
530
|
return typeof input;
|
|
529
531
|
}
|
|
530
532
|
/**
|
|
531
|
-
*
|
|
533
|
+
* Convert a node type to a delimiter format string
|
|
534
|
+
* @param node The AST node
|
|
535
|
+
* @param delimiter The delimiter to use
|
|
536
|
+
* @returns The delimiter format string
|
|
532
537
|
*/
|
|
533
538
|
function toDelimiterFormat(node, delimiter = " ") {
|
|
534
539
|
if (node.type === AST_NODE_TYPES.Literal) {
|
|
@@ -540,8 +545,9 @@ function toDelimiterFormat(node, delimiter = " ") {
|
|
|
540
545
|
}
|
|
541
546
|
/**
|
|
542
547
|
* Incomplete but sufficient stringification of AST nodes for common use cases
|
|
543
|
-
*
|
|
544
|
-
* @
|
|
548
|
+
* @param node The AST node
|
|
549
|
+
* @param getText A function to get the text representation of a node
|
|
550
|
+
* @returns A string representation of the node
|
|
545
551
|
*/
|
|
546
552
|
function toStringFormat(node, getText) {
|
|
547
553
|
switch (node.type) {
|
|
@@ -557,21 +563,6 @@ function toStringFormat(node, getText) {
|
|
|
557
563
|
}
|
|
558
564
|
}
|
|
559
565
|
|
|
560
|
-
//#endregion
|
|
561
|
-
//#region src/node-selectors.ts
|
|
562
|
-
const SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
|
|
563
|
-
const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
|
|
564
|
-
"VariableDeclarator",
|
|
565
|
-
"[id.type='ObjectPattern']",
|
|
566
|
-
"[init.type='Identifier']"
|
|
567
|
-
].join("");
|
|
568
|
-
const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
|
|
569
|
-
"AssignmentExpression",
|
|
570
|
-
"[operator='=']",
|
|
571
|
-
"[left.type='MemberExpression']",
|
|
572
|
-
"[left.property.name='displayName']"
|
|
573
|
-
].join("");
|
|
574
|
-
|
|
575
566
|
//#endregion
|
|
576
567
|
//#region src/process-env-node-env.ts
|
|
577
568
|
/**
|
|
@@ -608,6 +599,21 @@ function getPropertyName(node) {
|
|
|
608
599
|
return unit;
|
|
609
600
|
}
|
|
610
601
|
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/selectors.ts
|
|
604
|
+
const SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION = "ArrowFunctionExpression[body.type!='BlockStatement']";
|
|
605
|
+
const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
|
|
606
|
+
"VariableDeclarator",
|
|
607
|
+
"[id.type='ObjectPattern']",
|
|
608
|
+
"[init.type='Identifier']"
|
|
609
|
+
].join("");
|
|
610
|
+
const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
|
|
611
|
+
"AssignmentExpression",
|
|
612
|
+
"[operator='=']",
|
|
613
|
+
"[left.type='MemberExpression']",
|
|
614
|
+
"[left.property.name='displayName']"
|
|
615
|
+
].join("");
|
|
616
|
+
|
|
611
617
|
//#endregion
|
|
612
618
|
//#region src/vitest-mock.ts
|
|
613
619
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "2.5.1-next.
|
|
3
|
+
"version": "2.5.1-next.1",
|
|
4
4
|
"description": "ESLint React's TSESTree AST utility module.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@typescript-eslint/typescript-estree": "^8.51.0",
|
|
35
35
|
"@typescript-eslint/utils": "^8.51.0",
|
|
36
36
|
"string-ts": "^2.3.1",
|
|
37
|
-
"@eslint-react/eff": "2.5.1-next.
|
|
37
|
+
"@eslint-react/eff": "2.5.1-next.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"tsdown": "^0.18.4",
|