@eslint-react/ast 2.9.1-beta.0 → 2.9.1-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.ts +26 -7
- package/dist/index.js +17 -13
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,19 @@ type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullEx
|
|
|
55
55
|
* Represents TypeScript type assertion expressions (excluding instantiation expressions)
|
|
56
56
|
*/
|
|
57
57
|
type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
|
|
58
|
+
/**
|
|
59
|
+
* Represents a directive expression statement in TSESTree (e.g., "use strict";)
|
|
60
|
+
*/
|
|
61
|
+
type TSESTreeDirective = TSESTree$1.ExpressionStatement & {
|
|
62
|
+
directive: string;
|
|
63
|
+
expression: TSESTree$1.StringLiteral;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Represents a directive-like expression statement in TSESTree
|
|
67
|
+
*/
|
|
68
|
+
type TSESTreeDirectiveLike = TSESTree$1.ExpressionStatement & {
|
|
69
|
+
expression: TSESTree$1.StringLiteral;
|
|
70
|
+
};
|
|
58
71
|
//#endregion
|
|
59
72
|
//#region src/class-id.d.ts
|
|
60
73
|
/**
|
|
@@ -66,11 +79,17 @@ declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | unit;
|
|
|
66
79
|
//#endregion
|
|
67
80
|
//#region src/directive-is.d.ts
|
|
68
81
|
/**
|
|
69
|
-
* Check if a node is a directive
|
|
82
|
+
* Check if a node is a directive expression statement
|
|
83
|
+
* @param node The node to check
|
|
84
|
+
* @returns True if the node is a directive, false otherwise
|
|
85
|
+
*/
|
|
86
|
+
declare function isDirective(node: TSESTree.Node): node is TSESTreeDirective;
|
|
87
|
+
/**
|
|
88
|
+
* Check if a node is a directive-like expression statement
|
|
70
89
|
* @param node The node to check
|
|
71
90
|
* @returns True if the node is a directive, false otherwise
|
|
72
91
|
*/
|
|
73
|
-
declare function
|
|
92
|
+
declare function isDirectiveLike(node: TSESTree.Node): node is TSESTreeDirectiveLike;
|
|
74
93
|
//#endregion
|
|
75
94
|
//#region src/directive-kind.d.ts
|
|
76
95
|
type DirectiveKind = "use client" | "use server" | "use memo" | "use no memo";
|
|
@@ -158,11 +177,11 @@ declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallEx
|
|
|
158
177
|
//#endregion
|
|
159
178
|
//#region src/file-directive.d.ts
|
|
160
179
|
/**
|
|
161
|
-
* Get all directive
|
|
180
|
+
* Get all directive expression statements from the top of a program AST node
|
|
162
181
|
* @param node The program AST node
|
|
163
182
|
* @returns The array of directive string literals (e.g., "use strict")
|
|
164
183
|
*/
|
|
165
|
-
declare function getFileDirectives(node: TSESTree.Program):
|
|
184
|
+
declare function getFileDirectives(node: TSESTree.Program): TSESTreeDirective[];
|
|
166
185
|
//#endregion
|
|
167
186
|
//#region src/format.d.ts
|
|
168
187
|
/**
|
|
@@ -182,11 +201,11 @@ declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.No
|
|
|
182
201
|
//#endregion
|
|
183
202
|
//#region src/function-directive.d.ts
|
|
184
203
|
/**
|
|
185
|
-
* Get all directive
|
|
204
|
+
* Get all directive expression statements from the top of a function AST node
|
|
186
205
|
* @param node The function AST node
|
|
187
206
|
* @returns The array of directive string literals (e.g., "use memo", "use no memo")
|
|
188
207
|
*/
|
|
189
|
-
declare function getFunctionDirectives(node: TSESTreeFunction):
|
|
208
|
+
declare function getFunctionDirectives(node: TSESTreeFunction): TSESTreeDirective[];
|
|
190
209
|
//#endregion
|
|
191
210
|
//#region src/function-id.d.ts
|
|
192
211
|
/**
|
|
@@ -483,4 +502,4 @@ declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.M
|
|
|
483
502
|
*/
|
|
484
503
|
declare function isViMockCallback(node: TSESTree.Node | null | unit): boolean;
|
|
485
504
|
//#endregion
|
|
486
|
-
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getClassId, getFileDirectives, getFunctionDirectives, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback, toDelimiterFormat, toStringFormat };
|
|
505
|
+
export { DirectiveKind, DisplayNameAssignmentExpression, FunctionID, FunctionInitPath, ImplicitReturnArrowFunctionExpression, ObjectDestructuringVariableDeclarator, SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, TSESTreeArrayTupleType, TSESTreeClass, TSESTreeDestructuringPattern, TSESTreeDirective, TSESTreeDirectiveLike, TSESTreeFunction, TSESTreeFunctionType, TSESTreeJSX, TSESTreeJSXAttributeLike, TSESTreeLoop, TSESTreeMethodOrProperty, TSESTreeProperty, TSESTreeTypeAssertionExpression, TSESTreeTypeDeclaration, TSESTreeTypeExpression, findParentNode, getClassId, getFileDirectives, getFunctionDirectives, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback, toDelimiterFormat, toStringFormat };
|
package/dist/index.js
CHANGED
|
@@ -44,12 +44,20 @@ function isLiteral(node, type) {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/directive-is.ts
|
|
46
46
|
/**
|
|
47
|
-
* Check if a node is a directive
|
|
47
|
+
* Check if a node is a directive expression statement
|
|
48
48
|
* @param node The node to check
|
|
49
49
|
* @returns True if the node is a directive, false otherwise
|
|
50
50
|
*/
|
|
51
51
|
function isDirective(node) {
|
|
52
|
-
return
|
|
52
|
+
return node.type === AST_NODE_TYPES.ExpressionStatement && node.directive != null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if a node is a directive-like expression statement
|
|
56
|
+
* @param node The node to check
|
|
57
|
+
* @returns True if the node is a directive, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
function isDirectiveLike(node) {
|
|
60
|
+
return node.type === AST_NODE_TYPES.ExpressionStatement && isLiteral(node.expression, "string") && isDirectiveName(node.expression.value);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
//#endregion
|
|
@@ -483,17 +491,15 @@ const getNestedCallExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.CallE
|
|
|
483
491
|
//#endregion
|
|
484
492
|
//#region src/file-directive.ts
|
|
485
493
|
/**
|
|
486
|
-
* Get all directive
|
|
494
|
+
* Get all directive expression statements from the top of a program AST node
|
|
487
495
|
* @param node The program AST node
|
|
488
496
|
* @returns The array of directive string literals (e.g., "use strict")
|
|
489
497
|
*/
|
|
490
498
|
function getFileDirectives(node) {
|
|
491
499
|
const directives = [];
|
|
492
500
|
for (const stmt of node.body) {
|
|
493
|
-
if (stmt
|
|
494
|
-
|
|
495
|
-
if (!isDirective(expr)) continue;
|
|
496
|
-
directives.push(expr);
|
|
501
|
+
if (!isDirective(stmt)) continue;
|
|
502
|
+
directives.push(stmt);
|
|
497
503
|
}
|
|
498
504
|
return directives;
|
|
499
505
|
}
|
|
@@ -538,7 +544,7 @@ function toStringFormat(node, getText) {
|
|
|
538
544
|
//#endregion
|
|
539
545
|
//#region src/function-directive.ts
|
|
540
546
|
/**
|
|
541
|
-
* Get all directive
|
|
547
|
+
* Get all directive expression statements from the top of a function AST node
|
|
542
548
|
* @param node The function AST node
|
|
543
549
|
* @returns The array of directive string literals (e.g., "use memo", "use no memo")
|
|
544
550
|
*/
|
|
@@ -546,10 +552,8 @@ function getFunctionDirectives(node) {
|
|
|
546
552
|
const directives = [];
|
|
547
553
|
if (node.body.type !== AST_NODE_TYPES.BlockStatement) return directives;
|
|
548
554
|
for (const stmt of node.body.body) {
|
|
549
|
-
if (stmt
|
|
550
|
-
|
|
551
|
-
if (!isDirective(expr)) continue;
|
|
552
|
-
directives.push(expr);
|
|
555
|
+
if (!isDirective(stmt)) continue;
|
|
556
|
+
directives.push(stmt);
|
|
553
557
|
}
|
|
554
558
|
return directives;
|
|
555
559
|
}
|
|
@@ -796,4 +800,4 @@ function isViMockCallback(node) {
|
|
|
796
800
|
}
|
|
797
801
|
|
|
798
802
|
//#endregion
|
|
799
|
-
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParentNode, getClassId, getFileDirectives, getFunctionDirectives, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback, toDelimiterFormat, toStringFormat };
|
|
803
|
+
export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParentNode, getClassId, getFileDirectives, getFunctionDirectives, getFunctionId, getFunctionInitPath, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveKind, isDirectiveLike, isDirectiveName, isFunction, isFunctionEmpty, isFunctionImmediatelyInvoked, isFunctionType, isIdentifier, isIdentifierName, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProcessEnvNodeEnv, isProcessEnvNodeEnvCompare, isProperty, isThisExpressionLoose, isTypeAssertionExpression, isTypeExpression, isViMock, isViMockCallback, toDelimiterFormat, toStringFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/ast",
|
|
3
|
-
"version": "2.9.1-beta.
|
|
3
|
+
"version": "2.9.1-beta.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.54.0",
|
|
35
35
|
"@typescript-eslint/utils": "^8.54.0",
|
|
36
36
|
"string-ts": "^2.3.1",
|
|
37
|
-
"@eslint-react/eff": "2.9.1-beta.
|
|
37
|
+
"@eslint-react/eff": "2.9.1-beta.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"tsdown": "^0.20.1",
|