@eslint-react/ast 3.0.0-next.4 → 3.0.0-next.41

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 CHANGED
@@ -34,7 +34,7 @@ type TSESTreeProperty = TSESTree$1.PropertyDefinition | TSESTree$1.TSIndexSignat
34
34
  /**
35
35
  * Represents all JSX-related nodes in TSESTree
36
36
  */
37
- type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXElement | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXExpression | TSESTree$1.JSXExpressionContainer | TSESTree$1.JSXFragment | TSESTree$1.JSXIdentifier | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXSpreadChild | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXText | TSESTree$1.JSXTextToken;
37
+ type TSESTreeJSX = TSESTree$1.JSXAttribute | TSESTree$1.JSXChild | TSESTree$1.JSXClosingElement | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXEmptyExpression | TSESTree$1.JSXIdentifierToken | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXSpreadAttribute | TSESTree$1.JSXTagNameExpression | TSESTree$1.JSXTextToken;
38
38
  /**
39
39
  * Represents JSX attribute-like nodes (attributes and spread attributes)
40
40
  */
@@ -77,34 +77,6 @@ type TSESTreeDirectiveLike = TSESTree$1.ExpressionStatement & {
77
77
  */
78
78
  declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | unit;
79
79
  //#endregion
80
- //#region src/directive-helper.d.ts
81
- /**
82
- * Get all directive expression statements from the top of a program AST node
83
- * @param node The program AST node
84
- * @returns The array of directive string literals (e.g., "use strict")
85
- */
86
- declare function getFileDirectives(node: TSESTree.Program): TSESTreeDirective[];
87
- /**
88
- * Get all directive expression statements from the top of a function AST node
89
- * @param node The function AST node
90
- * @returns The array of directive string literals (e.g., "use memo", "use no memo")
91
- */
92
- declare function getFunctionDirectives(node: TSESTreeFunction): TSESTreeDirective[];
93
- /**
94
- * Check if a directive with the given name exists in the file or function directives
95
- * @param node The program or function AST node
96
- * @param name The directive name to check (e.g., "use strict", "use memo", "use no memo")
97
- * @returns True if the directive exists, false otherwise
98
- */
99
- declare function isDirectiveInFile(node: TSESTree.Program, name: string): boolean;
100
- /**
101
- * Check if a directive with the given name exists in the function directives
102
- * @param node The function AST node
103
- * @param name The directive name to check (e.g., "use memo", "use no memo")
104
- * @returns True if the directive exists, false otherwise
105
- */
106
- declare function isDirectiveInFunction(node: TSESTreeFunction, name: string): boolean;
107
- //#endregion
108
80
  //#region src/directive-is.d.ts
109
81
  /**
110
82
  * Check if a node is a directive expression statement
@@ -136,15 +108,6 @@ declare function isDirectiveKind(kind: string): kind is DirectiveKind;
136
108
  */
137
109
  declare function isDirectiveName(name: string): boolean;
138
110
  //#endregion
139
- //#region src/expression-base.d.ts
140
- /**
141
- * Unwraps any type expressions to get the underlying JavaScript expression node.
142
- * Recursively processes nodes until a non-type expression is found.
143
- * @param node The AST node to unwrap
144
- * @returns The underlying JavaScript expression node
145
- */
146
- declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
147
- //#endregion
148
111
  //#region src/expression-is.d.ts
149
112
  /**
150
113
  * Check if the given expression is a 'this' expression
@@ -190,6 +153,36 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
190
153
  */
191
154
  declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
192
155
  //#endregion
156
+ //#region src/file-directive.d.ts
157
+ /**
158
+ * Get all directive expression statements from the top of a program AST node
159
+ * @param node The program AST node
160
+ * @returns The array of directive string literals (e.g., "use strict")
161
+ */
162
+ declare function getFileDirectives(node: TSESTree.Program): TSESTreeDirective[];
163
+ /**
164
+ * Check if a directive with the given name exists in the file or function directives
165
+ * @param node The program or function AST node
166
+ * @param name The directive name to check (e.g., "use strict", "use memo", "use no memo")
167
+ * @returns True if the directive exists, false otherwise
168
+ */
169
+ declare function isDirectiveInFile(node: TSESTree.Program, name: string): boolean;
170
+ //#endregion
171
+ //#region src/function-directive.d.ts
172
+ /**
173
+ * Get all directive expression statements from the top of a function AST node
174
+ * @param node The function AST node
175
+ * @returns The array of directive string literals (e.g., "use memo", "use no memo")
176
+ */
177
+ declare function getFunctionDirectives(node: TSESTreeFunction): TSESTreeDirective[];
178
+ /**
179
+ * Check if a directive with the given name exists in the function directives
180
+ * @param node The function AST node
181
+ * @param name The directive name to check (e.g., "use memo", "use no memo")
182
+ * @returns True if the directive exists, false otherwise
183
+ */
184
+ declare function isDirectiveInFunction(node: TSESTreeFunction, name: string): boolean;
185
+ //#endregion
193
186
  //#region src/function-id.d.ts
194
187
  /**
195
188
  * Gets the static name of a function AST node. For function declarations it is
@@ -453,7 +446,16 @@ declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | u
453
446
  */
454
447
  declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
455
448
  //#endregion
456
- //#region src/process-env-node-env.d.ts
449
+ //#region src/node-unwrap.d.ts
450
+ /**
451
+ * Unwraps any type expressions to get the underlying JavaScript expression node.
452
+ * Recursively processes nodes until a non-type expression is found.
453
+ * @param node The AST node to unwrap
454
+ * @returns The underlying JavaScript expression node
455
+ */
456
+ declare function getUnderlyingExpression(node: TSESTree.Node): Exclude<TSESTree.Node, TSESTreeTypeExpression>;
457
+ //#endregion
458
+ //#region src/pattern-process-env-node-env.d.ts
457
459
  /**
458
460
  * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
459
461
  * @param node The AST node
@@ -469,16 +471,7 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is
469
471
  */
470
472
  declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
471
473
  //#endregion
472
- //#region src/property-name.d.ts
473
- /**
474
- * Get the name of a property from a node
475
- * Handles identifiers, private identifiers, literals, and template literals
476
- * @param node The node to get the property name from
477
- * @returns The property name or unit if not determinable
478
- */
479
- declare function getPropertyName(node: TSESTree.Node): string | unit;
480
- //#endregion
481
- //#region src/vitest-mock.d.ts
474
+ //#region src/pattern-vitest-mock.d.ts
482
475
  /**
483
476
  * Check if the given node is a `vi.mock`.
484
477
  * @param node The node to check
@@ -494,4 +487,13 @@ declare function isViMock(node: TSESTree.Node | null | unit): node is TSESTree.M
494
487
  */
495
488
  declare function isViMockCallback(node: TSESTree.Node | null | unit): boolean;
496
489
  //#endregion
490
+ //#region src/property-name.d.ts
491
+ /**
492
+ * Get the name of a property from a node
493
+ * Handles identifiers, private identifiers, literals, and template literals
494
+ * @param node The node to get the property name from
495
+ * @returns The property name or unit if not determinable
496
+ */
497
+ declare function getPropertyName(node: TSESTree.Node): string | unit;
498
+ //#endregion
497
499
  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, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, 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 };
package/dist/index.js CHANGED
@@ -60,54 +60,6 @@ function isDirectiveLike(node) {
60
60
  return node.type === AST_NODE_TYPES.ExpressionStatement && isLiteral(node.expression, "string") && isDirectiveName(node.expression.value);
61
61
  }
62
62
 
63
- //#endregion
64
- //#region src/directive-helper.ts
65
- /**
66
- * Get all directive expression statements from the top of a program AST node
67
- * @param node The program AST node
68
- * @returns The array of directive string literals (e.g., "use strict")
69
- */
70
- function getFileDirectives(node) {
71
- const directives = [];
72
- for (const stmt of node.body) {
73
- if (!isDirective(stmt)) continue;
74
- directives.push(stmt);
75
- }
76
- return directives;
77
- }
78
- /**
79
- * Get all directive expression statements from the top of a function AST node
80
- * @param node The function AST node
81
- * @returns The array of directive string literals (e.g., "use memo", "use no memo")
82
- */
83
- function getFunctionDirectives(node) {
84
- const directives = [];
85
- if (node.body.type !== AST_NODE_TYPES.BlockStatement) return directives;
86
- for (const stmt of node.body.body) {
87
- if (!isDirective(stmt)) continue;
88
- directives.push(stmt);
89
- }
90
- return directives;
91
- }
92
- /**
93
- * Check if a directive with the given name exists in the file or function directives
94
- * @param node The program or function AST node
95
- * @param name The directive name to check (e.g., "use strict", "use memo", "use no memo")
96
- * @returns True if the directive exists, false otherwise
97
- */
98
- function isDirectiveInFile(node, name) {
99
- return getFileDirectives(node).some((d) => d.directive === name);
100
- }
101
- /**
102
- * Check if a directive with the given name exists in the function directives
103
- * @param node The function AST node
104
- * @param name The directive name to check (e.g., "use memo", "use no memo")
105
- * @returns True if the directive exists, false otherwise
106
- */
107
- function isDirectiveInFunction(node, name) {
108
- return getFunctionDirectives(node).some((d) => d.directive === name);
109
- }
110
-
111
63
  //#endregion
112
64
  //#region src/directive-kind.ts
113
65
  /**
@@ -275,7 +227,7 @@ const isTypeAssertionExpression = isOneOf([
275
227
  ]);
276
228
 
277
229
  //#endregion
278
- //#region src/expression-base.ts
230
+ //#region src/node-unwrap.ts
279
231
  /**
280
232
  * Unwraps any type expressions to get the underlying JavaScript expression node.
281
233
  * Recursively processes nodes until a non-type expression is found.
@@ -495,6 +447,57 @@ const getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.NewExp
495
447
  */
496
448
  const getNestedCallExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.CallExpression);
497
449
 
450
+ //#endregion
451
+ //#region src/file-directive.ts
452
+ /**
453
+ * Get all directive expression statements from the top of a program AST node
454
+ * @param node The program AST node
455
+ * @returns The array of directive string literals (e.g., "use strict")
456
+ */
457
+ function getFileDirectives(node) {
458
+ const directives = [];
459
+ for (const stmt of node.body) {
460
+ if (!isDirective(stmt)) continue;
461
+ directives.push(stmt);
462
+ }
463
+ return directives;
464
+ }
465
+ /**
466
+ * Check if a directive with the given name exists in the file or function directives
467
+ * @param node The program or function AST node
468
+ * @param name The directive name to check (e.g., "use strict", "use memo", "use no memo")
469
+ * @returns True if the directive exists, false otherwise
470
+ */
471
+ function isDirectiveInFile(node, name) {
472
+ return getFileDirectives(node).some((d) => d.directive === name);
473
+ }
474
+
475
+ //#endregion
476
+ //#region src/function-directive.ts
477
+ /**
478
+ * Get all directive expression statements from the top of a function AST node
479
+ * @param node The function AST node
480
+ * @returns The array of directive string literals (e.g., "use memo", "use no memo")
481
+ */
482
+ function getFunctionDirectives(node) {
483
+ const directives = [];
484
+ if (node.body.type !== AST_NODE_TYPES.BlockStatement) return directives;
485
+ for (const stmt of node.body.body) {
486
+ if (!isDirective(stmt)) continue;
487
+ directives.push(stmt);
488
+ }
489
+ return directives;
490
+ }
491
+ /**
492
+ * Check if a directive with the given name exists in the function directives
493
+ * @param node The function AST node
494
+ * @param name The directive name to check (e.g., "use memo", "use no memo")
495
+ * @returns True if the directive exists, false otherwise
496
+ */
497
+ function isDirectiveInFunction(node, name) {
498
+ return getFunctionDirectives(node).some((d) => d.directive === name);
499
+ }
500
+
498
501
  //#endregion
499
502
  //#region src/function-id.ts
500
503
  /**
@@ -734,7 +737,7 @@ const SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION = [
734
737
  ].join("");
735
738
 
736
739
  //#endregion
737
- //#region src/process-env-node-env.ts
740
+ //#region src/pattern-process-env-node-env.ts
738
741
  /**
739
742
  * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
740
743
  * @param node The AST node
@@ -760,23 +763,7 @@ function isProcessEnvNodeEnvCompare(node, operator, value) {
760
763
  }
761
764
 
762
765
  //#endregion
763
- //#region src/property-name.ts
764
- /**
765
- * Get the name of a property from a node
766
- * Handles identifiers, private identifiers, literals, and template literals
767
- * @param node The node to get the property name from
768
- * @returns The property name or unit if not determinable
769
- */
770
- function getPropertyName(node) {
771
- if (isTypeExpression(node)) return getPropertyName(getUnderlyingExpression(node));
772
- if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) return node.name;
773
- if (node.type === AST_NODE_TYPES.Literal) return String(node.value);
774
- if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) return node.quasis[0]?.value.raw;
775
- return unit;
776
- }
777
-
778
- //#endregion
779
- //#region src/vitest-mock.ts
766
+ //#region src/pattern-vitest-mock.ts
780
767
  /**
781
768
  * Check if the given node is a `vi.mock`.
782
769
  * @param node The node to check
@@ -796,5 +783,21 @@ function isViMockCallback(node) {
796
783
  return node != null && isFunction(node) && node.parent.type === AST_NODE_TYPES.CallExpression && isViMock(node.parent.callee) && node.parent.arguments[1] === node;
797
784
  }
798
785
 
786
+ //#endregion
787
+ //#region src/property-name.ts
788
+ /**
789
+ * Get the name of a property from a node
790
+ * Handles identifiers, private identifiers, literals, and template literals
791
+ * @param node The node to get the property name from
792
+ * @returns The property name or unit if not determinable
793
+ */
794
+ function getPropertyName(node) {
795
+ if (isTypeExpression(node)) return getPropertyName(getUnderlyingExpression(node));
796
+ if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) return node.name;
797
+ if (node.type === AST_NODE_TYPES.Literal) return String(node.value);
798
+ if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) return node.quasis[0]?.value.raw;
799
+ return unit;
800
+ }
801
+
799
802
  //#endregion
800
803
  export { SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION, SEL_IMPLICIT_RETURN_ARROW_FUNCTION_EXPRESSION, SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR, findParentNode, getClassId, getFileDirectives, getFullyQualifiedName, getFunctionDirectives, getFunctionId, getFunctionInitPath, getHumanReadableKind, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getUnderlyingExpression, hasCallInFunctionInitPath, is, isClass, isConditional, isControlFlow, isDirective, isDirectiveInFile, isDirectiveInFunction, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "3.0.0-next.4",
3
+ "version": "3.0.0-next.41",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -30,11 +30,11 @@
30
30
  "./package.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@typescript-eslint/types": "^8.56.0",
34
- "@typescript-eslint/typescript-estree": "^8.56.0",
35
- "@typescript-eslint/utils": "^8.56.0",
33
+ "@typescript-eslint/types": "canary",
34
+ "@typescript-eslint/typescript-estree": "canary",
35
+ "@typescript-eslint/utils": "canary",
36
36
  "string-ts": "^2.3.1",
37
- "@eslint-react/eff": "3.0.0-next.4"
37
+ "@eslint-react/eff": "3.0.0-next.41"
38
38
  },
39
39
  "devDependencies": {
40
40
  "tsdown": "^0.20.3",
@@ -50,6 +50,6 @@
50
50
  "scripts": {
51
51
  "build": "tsdown --dts-resolve",
52
52
  "lint:publish": "publint",
53
- "lint:ts": "tsc --noEmit"
53
+ "lint:ts": "tsl"
54
54
  }
55
55
  }