@eslint-react/ast 2.0.0-next.5 → 2.0.0-next.50

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
@@ -1,6 +1,6 @@
1
1
  import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types';
2
2
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
3
- import { _ } from '@eslint-react/eff';
3
+ import { unit } from '@eslint-react/eff';
4
4
 
5
5
  declare function isArrayFromCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
6
6
  declare function isArrayMapCall(node: TSESTree.Node, loose?: boolean): node is TSESTree.CallExpression;
@@ -20,12 +20,7 @@ type TSESTreeTypeDeclaration = TSESTree$1.TSInterfaceDeclaration | TSESTree$1.TS
20
20
  type TSESTreeTypeExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion | TSESTree$1.TSInstantiationExpression;
21
21
  type TSESTreeTypeAssertionExpression = TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
22
22
 
23
- /**
24
- * Gets class identifier from ClassDeclaration or ClassExpression
25
- * @param node The AST node to check
26
- * @returns class identifier or null
27
- */
28
- declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | _;
23
+ declare function getClassId(node: TSESTreeClass): TSESTree.Identifier | unit;
29
24
 
30
25
  /**
31
26
  * Recursively get the inner expression until it's not a TypeExpression
@@ -42,8 +37,7 @@ declare function isThisExpression(node: TSESTree.Expression): boolean;
42
37
  * where JS gives anonymous function expressions names. We roughly detect the
43
38
  * same AST nodes with some exceptions to better fit our use case.
44
39
  */
45
-
46
- declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | _;
40
+ declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.Identifier | unit;
47
41
 
48
42
  type FunctionInitPath =
49
43
  /**
@@ -143,7 +137,7 @@ readonly [TSESTree.FunctionDeclaration]
143
137
  TSESTree.PropertyDefinition,
144
138
  TSESTreeFunction
145
139
  ];
146
- declare function getFunctionInitPath(node: TSESTreeFunction): FunctionInitPath | _;
140
+ declare function getFunctionInitPath(node: TSESTreeFunction): unit | FunctionInitPath;
147
141
  declare function hasCallInFunctionInitPath(callName: string, initPath: FunctionInitPath): boolean;
148
142
 
149
143
  declare function isEmptyFunction(node: TSESTreeFunction): boolean;
@@ -155,14 +149,14 @@ declare function isImmediatelyInvokedFunction(node: TSESTreeFunction): boolean;
155
149
  * @param test The test function
156
150
  * @returns The parent node that satisfies the test function or `_` if not found
157
151
  */
158
- declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | _, test: (n: TSESTree.Node) => n is A): A | _;
152
+ declare function findParentNode<A extends TSESTree.Node>(node: TSESTree.Node | unit, test: (n: TSESTree.Node) => n is A): A | unit;
159
153
  /**
160
154
  * Find the parent node that satisfies the test function or `_` if not found
161
155
  * @param node The AST node
162
156
  * @param test The test function
163
157
  * @returns The parent node that satisfies the test function
164
158
  */
165
- declare function findParentNode(node: TSESTree.Node | _, test: (node: TSESTree.Node) => boolean): TSESTree.Node | _;
159
+ declare function findParentNode(node: TSESTree.Node | unit, test: (node: TSESTree.Node) => boolean): TSESTree.Node | unit;
166
160
 
167
161
  /**
168
162
  * Get all nested identifiers in a expression like node
@@ -198,32 +192,6 @@ declare const getNestedNewExpressions: (node: TSESTree.Node) => TSESTree.NewExpr
198
192
  */
199
193
  declare const getNestedCallExpressions: (node: TSESTree.Node) => TSESTree.CallExpression[];
200
194
 
201
- declare const is: <NodeType extends TSESTree.AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
202
- type: NodeType;
203
- }>;
204
- declare const isOneOf: <NodeTypes extends readonly TSESTree.AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
205
- type: NodeTypes[number];
206
- }>;
207
- declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
208
- 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;
209
- declare const isClass: (node: TSESTree.Node | null | undefined) => node is TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.ClassExpression;
210
- declare const isMethodOrProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.MethodDefinitionComputedName | TSESTree.MethodDefinitionNonComputedName | TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName;
211
- declare const isLoop: (node: TSESTree.Node | null | undefined) => node is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.WhileStatement;
212
- declare const isControlFlow: (data: TSESTree.Node | null | undefined) => data is TSESTree.DoWhileStatement | TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement | TSESTree.IfStatement | TSESTree.SwitchStatement | TSESTree.WhileStatement;
213
- 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;
214
- declare const isArrayTupleType: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSArrayType | TSESTree.TSTupleType;
215
- declare const isProperty: (node: TSESTree.Node | null | undefined) => node is TSESTree.PropertyDefinitionComputedName | TSESTree.PropertyDefinitionNonComputedName | TSESTree.TSIndexSignature | TSESTree.TSParameterProperty | TSESTree.TSPropertySignatureComputedName | TSESTree.TSPropertySignatureNonComputedName;
216
- declare const isJSXElement: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXElement;
217
- declare const isJSXFragment: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXFragment;
218
- declare const isJSXTagNameExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.JSXIdentifier | TSESTree.JSXMemberExpression | TSESTree.JSXNamespacedName;
219
- 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;
220
- declare const isDestructuringPattern: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrayPattern | TSESTree.AssignmentPattern | TSESTree.ObjectPattern | TSESTree.RestElement;
221
- declare const isTypeDeclaration: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration;
222
- 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;
223
- 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;
224
- declare const isTypeExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
225
- declare const isTypeAssertionExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSAsExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion;
226
-
227
195
  /**
228
196
  * Check if a node is multiline
229
197
  * @param node The AST node to check
@@ -256,12 +224,47 @@ declare const isNodeEqual: {
256
224
  (a: TSESTree.Node, b: TSESTree.Node): boolean;
257
225
  };
258
226
 
227
+ /**
228
+ * @internal
229
+ */
230
+ declare function toDelimiterFormat(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
231
+ /**
232
+ * @internal
233
+ */
234
+ declare function toStringFormat(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
235
+
236
+ declare const is: <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
237
+ type: NodeType;
238
+ }>;
239
+ declare const isOneOf: <NodeTypes extends readonly AST_NODE_TYPES[]>(nodeTypes: NodeTypes) => (node: TSESTree.Node | null | undefined) => node is Extract<TSESTree.Node, {
240
+ type: NodeTypes[number];
241
+ }>;
242
+ declare const isFunction: (node: TSESTree.Node | null | undefined) => node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName | TSESTree.FunctionExpression;
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
+
259
262
  /**
260
263
  * Check if the given node is a member expression that accesses `process.env.NODE_ENV`
261
264
  * @param node The AST node
262
265
  * @returns True if the node is a member expression that accesses `process.env.NODE_ENV`, false otherwise
263
266
  */
264
- declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TSESTree.MemberExpression;
267
+ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | unit): node is TSESTree.MemberExpression;
265
268
  /**
266
269
  * Check if the given node is a binary expression that compares `process.env.NODE_ENV` with a string literal
267
270
  * @param node The AST node
@@ -269,19 +272,10 @@ declare function isProcessEnvNodeEnv(node: TSESTree.Node | null | _): node is TS
269
272
  * @param value The string literal value to compare against
270
273
  * @returns True if the node is a binary expression that compares `process.env.NODE_ENV` with the specified value, false otherwise
271
274
  */
272
- declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | _, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
275
+ declare function isProcessEnvNodeEnvCompare(node: TSESTree.Node | null | unit, operator: "===" | "!==", value: "development" | "production"): node is TSESTree.BinaryExpression;
273
276
 
274
- declare function getPropertyName(node: TSESTree.Node): string | _;
277
+ declare function getPropertyName(node: TSESTree.Node): string | unit;
275
278
 
276
279
  declare function isThenCall(node: TSESTree.CallExpression): boolean;
277
280
 
278
- declare function toDelimiterCaseType(node: TSESTree.Node, delimiter?: string): "RegExp literal" | Lowercase<string> | `JSX ${Lowercase<string>}`;
279
- /**
280
- * Returns human readable node name for given AST node
281
- * @param node AST node
282
- * @param getText A function that returns the text of the node in the source code
283
- * @returns Human readable node name
284
- */
285
- declare function toString(node: TSESTree.Node, getText: (node: TSESTree.Node) => string): string;
286
-
287
- 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, toDelimiterCaseType, toString };
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 };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
- import { or, dual, _ } from '@eslint-react/eff';
2
+ import { or, dual, unit } from '@eslint-react/eff';
3
3
  import { ASTUtils } from '@typescript-eslint/utils';
4
4
  import { simpleTraverse } from '@typescript-eslint/typescript-estree';
5
5
  import { toLowerCase, delimiterCase, replace } from 'string-ts';
@@ -43,7 +43,7 @@ function getClassId(node) {
43
43
  if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
44
44
  return node.parent.id;
45
45
  }
46
- return _;
46
+ return unit;
47
47
  }
48
48
  var is = ASTUtils.isNodeOfType;
49
49
  var isOneOf = ASTUtils.isNodeOfTypes;
@@ -230,7 +230,7 @@ function getFunctionId(node) {
230
230
  case isTypeAssertionExpression(node.parent):
231
231
  return getFunctionId(node.parent);
232
232
  }
233
- return _;
233
+ return unit;
234
234
  }
235
235
  function getFunctionInitPath(node) {
236
236
  if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
@@ -251,7 +251,7 @@ function getFunctionInitPath(node) {
251
251
  case (parent.type === AST_NODE_TYPES.PropertyDefinition && parent.parent.parent.type === AST_NODE_TYPES.ClassDeclaration):
252
252
  return [parent.parent.parent, parent.parent, parent, node];
253
253
  }
254
- return _;
254
+ return unit;
255
255
  }
256
256
  function hasCallInFunctionInitPath(callName, initPath) {
257
257
  return initPath.some((n) => {
@@ -275,7 +275,7 @@ function isImmediatelyInvokedFunction(node) {
275
275
  return node.type !== AST_NODE_TYPES.FunctionDeclaration && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
276
276
  }
277
277
  function findParentNode(node, test) {
278
- if (node == null) return _;
278
+ if (node == null) return unit;
279
279
  let parent = node.parent;
280
280
  while (parent != null && parent.type !== AST_NODE_TYPES.Program) {
281
281
  if (test(parent)) {
@@ -283,7 +283,7 @@ function findParentNode(node, test) {
283
283
  }
284
284
  parent = parent.parent;
285
285
  }
286
- return _;
286
+ return unit;
287
287
  }
288
288
  function getNestedIdentifiers(node) {
289
289
  const identifiers = [];
@@ -523,44 +523,11 @@ var isNodeEqual = dual(2, (a, b) => {
523
523
  return false;
524
524
  }
525
525
  });
526
- function isProcessEnvNodeEnv(node) {
527
- return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
528
- }
529
- function isProcessEnvNodeEnvCompare(node, operator, value) {
530
- if (node == null) return false;
531
- if (node.type !== AST_NODE_TYPES.BinaryExpression) return false;
532
- if (node.operator !== operator) return false;
533
- if (isProcessEnvNodeEnv(node.left) && isLiteral(node.right, "string")) {
534
- return node.right.value === value;
535
- }
536
- if (isLiteral(node.left, "string") && isProcessEnvNodeEnv(node.right)) {
537
- return node.left.value === value;
538
- }
539
- return false;
540
- }
541
- function getPropertyName(node) {
542
- if (isTypeExpression(node)) {
543
- return getPropertyName(getJSExpression(node));
544
- }
545
- if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
546
- return node.name;
547
- }
548
- if (node.type === AST_NODE_TYPES.Literal) {
549
- return String(node.value);
550
- }
551
- if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
552
- return node.quasis[0]?.value.raw;
553
- }
554
- return _;
555
- }
556
- function isThenCall(node) {
557
- return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "then";
558
- }
559
526
  function getLiteralValueType(input) {
560
527
  if (input === null) return "null";
561
528
  return typeof input;
562
529
  }
563
- function toDelimiterCaseType(node, delimiter = " ") {
530
+ function toDelimiterFormat(node, delimiter = " ") {
564
531
  if (node.type === AST_NODE_TYPES.Literal) {
565
532
  if ("regex" in node) {
566
533
  return "RegExp literal";
@@ -572,7 +539,7 @@ function toDelimiterCaseType(node, delimiter = " ") {
572
539
  }
573
540
  return toLowerCase(delimiterCase(node.type, delimiter));
574
541
  }
575
- function toString(node, getText) {
542
+ function toStringFormat(node, getText) {
576
543
  switch (node.type) {
577
544
  case AST_NODE_TYPES.Identifier:
578
545
  case AST_NODE_TYPES.JSXIdentifier:
@@ -580,7 +547,7 @@ function toString(node, getText) {
580
547
  return node.name;
581
548
  case AST_NODE_TYPES.MemberExpression:
582
549
  case AST_NODE_TYPES.JSXMemberExpression:
583
- return `${toString(node.object, getText)}.${toString(node.property, getText)}`;
550
+ return `${toStringFormat(node.object, getText)}.${toStringFormat(node.property, getText)}`;
584
551
  case AST_NODE_TYPES.JSXNamespacedName:
585
552
  return `${node.namespace.name}:${node.name.name}`;
586
553
  case AST_NODE_TYPES.JSXText:
@@ -591,5 +558,38 @@ function toString(node, getText) {
591
558
  return getText(node);
592
559
  }
593
560
  }
561
+ function isProcessEnvNodeEnv(node) {
562
+ return node != null && node.type === AST_NODE_TYPES.MemberExpression && node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && node.object.object.name === "process" && node.object.property.type === AST_NODE_TYPES.Identifier && node.object.property.name === "env" && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === "NODE_ENV";
563
+ }
564
+ function isProcessEnvNodeEnvCompare(node, operator, value) {
565
+ if (node == null) return false;
566
+ if (node.type !== AST_NODE_TYPES.BinaryExpression) return false;
567
+ if (node.operator !== operator) return false;
568
+ if (isProcessEnvNodeEnv(node.left) && isLiteral(node.right, "string")) {
569
+ return node.right.value === value;
570
+ }
571
+ if (isLiteral(node.left, "string") && isProcessEnvNodeEnv(node.right)) {
572
+ return node.left.value === value;
573
+ }
574
+ return false;
575
+ }
576
+ function getPropertyName(node) {
577
+ if (isTypeExpression(node)) {
578
+ return getPropertyName(getJSExpression(node));
579
+ }
580
+ if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
581
+ return node.name;
582
+ }
583
+ if (node.type === AST_NODE_TYPES.Literal) {
584
+ return String(node.value);
585
+ }
586
+ if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
587
+ return node.quasis[0]?.value.raw;
588
+ }
589
+ return unit;
590
+ }
591
+ function isThenCall(node) {
592
+ return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "then";
593
+ }
594
594
 
595
- export { 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, toDelimiterCaseType, toString };
595
+ export { 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "2.0.0-next.5",
3
+ "version": "2.0.0-next.50",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -27,15 +27,15 @@
27
27
  "./package.json"
28
28
  ],
29
29
  "dependencies": {
30
- "@typescript-eslint/types": "^8.31.0",
31
- "@typescript-eslint/typescript-estree": "^8.31.0",
32
- "@typescript-eslint/utils": "^8.31.0",
30
+ "@typescript-eslint/types": "^8.34.1",
31
+ "@typescript-eslint/typescript-estree": "^8.34.1",
32
+ "@typescript-eslint/utils": "^8.34.1",
33
33
  "string-ts": "^2.2.1",
34
- "ts-pattern": "^5.7.0",
35
- "@eslint-react/eff": "2.0.0-next.5"
34
+ "ts-pattern": "^5.7.1",
35
+ "@eslint-react/eff": "2.0.0-next.50"
36
36
  },
37
37
  "devDependencies": {
38
- "tsup": "^8.4.0",
38
+ "tsup": "^8.5.0",
39
39
  "@local/configs": "0.0.0"
40
40
  },
41
41
  "engines": {