@eslint-react/ast 1.40.4-next.4 → 1.40.4-next.6

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 CHANGED
@@ -1,9 +1,10 @@
1
- import { _ } from '@eslint-react/eff';
2
1
  import { TSESTree } from '@typescript-eslint/types';
2
+ import { _ } from '@eslint-react/eff';
3
3
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
4
4
  import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
5
5
 
6
- declare const ITERATOR_FUNCTION_INDEX_PARAM_POSITION: Map<string, number>;
6
+ declare function getArrayMethodIndexParamPosition(methodName: string): number;
7
+ declare function isArrayMapCall(node: TSESTree.Node): node is TSESTree.CallExpression;
7
8
 
8
9
  /**
9
10
  * Find the parent node that satisfies the test function
@@ -226,16 +227,8 @@ declare const isLeftHandSideExpressionType: (node: TSESTree$1.Node | null | unde
226
227
  declare const isTypeExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSAsExpression | TSESTree$1.TSInstantiationExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
227
228
  declare const isTypeAssertionExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
228
229
 
229
- declare function isArrayMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression;
230
-
231
230
  declare function isEmptyFunction(node: TSESTreeFunction): boolean;
232
231
 
233
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "boolean"): node is TSESTree.BooleanLiteral;
234
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "null"): node is TSESTree.NullLiteral;
235
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "number"): node is TSESTree.NumberLiteral;
236
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "regexp"): node is TSESTree.RegExpLiteral;
237
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "string"): node is TSESTree.StringLiteral;
238
-
239
232
  /**
240
233
  * Check if a node is a line break
241
234
  * @param node The AST node to check
@@ -243,6 +236,13 @@ declare function isKindOfLiteral(node: TSESTree.Node, kind: "string"): node is T
243
236
  */
244
237
  declare function isLineBreak(node: TSESTree.Node): boolean;
245
238
 
239
+ declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
240
+ declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
241
+ declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
242
+ declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
243
+ declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
244
+ declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
245
+
246
246
  /**
247
247
  * Check if a node is multiline
248
248
  * @param node The AST node to check
@@ -280,4 +280,4 @@ declare function toReadableNodeName(node: TSESTree.Node, getText: (node: TSESTre
280
280
  declare function toReadableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "string literal" | "number literal" | "bigint literal" | "boolean literal" | "symbol literal" | "undefined literal" | "object literal" | "function literal" | "null literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
281
281
  type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
282
282
 
283
- export { type FunctionInitPath, ITERATOR_FUNCTION_INDEX_PARAM_POSITION, type ReadableNodeType, 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, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayMapCallLoose, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
283
+ export { type FunctionInitPath, type ReadableNodeType, 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, getArrayMethodIndexParamPosition, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { _ } from '@eslint-react/eff';
2
1
  import { TSESTree } from '@typescript-eslint/types';
2
+ import { _ } from '@eslint-react/eff';
3
3
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
4
4
  import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree';
5
5
 
6
- declare const ITERATOR_FUNCTION_INDEX_PARAM_POSITION: Map<string, number>;
6
+ declare function getArrayMethodIndexParamPosition(methodName: string): number;
7
+ declare function isArrayMapCall(node: TSESTree.Node): node is TSESTree.CallExpression;
7
8
 
8
9
  /**
9
10
  * Find the parent node that satisfies the test function
@@ -226,16 +227,8 @@ declare const isLeftHandSideExpressionType: (node: TSESTree$1.Node | null | unde
226
227
  declare const isTypeExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSAsExpression | TSESTree$1.TSInstantiationExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
227
228
  declare const isTypeAssertionExpression: (node: TSESTree$1.Node | null | undefined) => node is TSESTree$1.TSAsExpression | TSESTree$1.TSNonNullExpression | TSESTree$1.TSSatisfiesExpression | TSESTree$1.TSTypeAssertion;
228
229
 
229
- declare function isArrayMapCallLoose(node: TSESTree.Node): node is TSESTree.CallExpression;
230
-
231
230
  declare function isEmptyFunction(node: TSESTreeFunction): boolean;
232
231
 
233
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "boolean"): node is TSESTree.BooleanLiteral;
234
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "null"): node is TSESTree.NullLiteral;
235
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "number"): node is TSESTree.NumberLiteral;
236
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "regexp"): node is TSESTree.RegExpLiteral;
237
- declare function isKindOfLiteral(node: TSESTree.Node, kind: "string"): node is TSESTree.StringLiteral;
238
-
239
232
  /**
240
233
  * Check if a node is a line break
241
234
  * @param node The AST node to check
@@ -243,6 +236,13 @@ declare function isKindOfLiteral(node: TSESTree.Node, kind: "string"): node is T
243
236
  */
244
237
  declare function isLineBreak(node: TSESTree.Node): boolean;
245
238
 
239
+ declare function isLiteral(node: TSESTree.Node): node is TSESTree.Literal;
240
+ declare function isLiteral(node: TSESTree.Node, type: "boolean"): node is TSESTree.BooleanLiteral;
241
+ declare function isLiteral(node: TSESTree.Node, type: "null"): node is TSESTree.NullLiteral;
242
+ declare function isLiteral(node: TSESTree.Node, type: "number"): node is TSESTree.NumberLiteral;
243
+ declare function isLiteral(node: TSESTree.Node, type: "regexp"): node is TSESTree.RegExpLiteral;
244
+ declare function isLiteral(node: TSESTree.Node, type: "string"): node is TSESTree.StringLiteral;
245
+
246
246
  /**
247
247
  * Check if a node is multiline
248
248
  * @param node The AST node to check
@@ -280,4 +280,4 @@ declare function toReadableNodeName(node: TSESTree.Node, getText: (node: TSESTre
280
280
  declare function toReadableNodeType(node: TSESTree.Node): "property" | "RegExp literal" | "string literal" | "number literal" | "bigint literal" | "boolean literal" | "symbol literal" | "undefined literal" | "object literal" | "function literal" | "null literal" | "identifier" | "member expression" | "JSX attribute" | "JSX element" | "JSX fragment" | "JSX identifier" | "JSX text" | "JSX closing element" | "JSX closing fragment" | "JSX empty expression" | "JSX expression container" | "JSX member expression" | "JSX namespaced name" | "JSX opening element" | "JSX opening fragment" | "JSX spread attribute" | "JSX spread child" | "decorator" | "program" | "super" | "accessor property" | "array expression" | "array pattern" | "function expression" | "arrow function expression" | "assignment expression" | "assignment pattern" | "await expression" | "binary expression" | "block statement" | "break statement" | "call expression" | "catch clause" | "chain expression" | "class body" | "class declaration" | "class expression" | "conditional expression" | "continue statement" | "debugger statement" | "while statement" | "do while statement" | "empty statement" | "export all declaration" | "export default declaration" | "export named declaration" | "export specifier" | "expression statement" | "for in statement" | "for of statement" | "for statement" | "function declaration" | "if statement" | "import attribute" | "import declaration" | "import default specifier" | "import expression" | "import namespace specifier" | "import specifier" | "labeled statement" | "logical expression" | "meta property" | "method definition" | "new expression" | "object expression" | "object pattern" | "private identifier" | "property definition" | "rest element" | "return statement" | "sequence expression" | "spread element" | "static block" | "switch case" | "switch statement" | "tagged template expression" | "template element" | "template literal" | "this expression" | "throw statement" | "try statement" | "unary expression" | "update expression" | "variable declaration" | "variable declarator" | "with statement" | "yield expression" | "ts abstract accessor property" | "ts abstract keyword" | "ts abstract method definition" | "ts abstract property definition" | "ts any keyword" | "ts array type" | "ts as expression" | "ts async keyword" | "ts big int keyword" | "ts boolean keyword" | "ts call signature declaration" | "ts class implements" | "ts conditional type" | "ts constructor type" | "ts construct signature declaration" | "ts declare function" | "ts declare keyword" | "ts empty body function expression" | "ts enum body" | "ts enum declaration" | "ts enum member" | "ts export assignment" | "ts export keyword" | "ts external module reference" | "ts function type" | "ts import equals declaration" | "ts import type" | "ts indexed access type" | "ts index signature" | "ts infer type" | "ts instantiation expression" | "ts interface body" | "ts interface declaration" | "ts interface heritage" | "ts intersection type" | "ts intrinsic keyword" | "ts literal type" | "ts mapped type" | "ts method signature" | "ts module block" | "ts module declaration" | "ts named tuple member" | "ts namespace export declaration" | "ts never keyword" | "ts non null expression" | "ts null keyword" | "ts number keyword" | "ts object keyword" | "ts optional type" | "ts parameter property" | "ts private keyword" | "ts property signature" | "ts protected keyword" | "ts public keyword" | "ts qualified name" | "ts readonly keyword" | "ts rest type" | "ts satisfies expression" | "ts static keyword" | "ts string keyword" | "ts symbol keyword" | "ts template literal type" | "ts this type" | "ts tuple type" | "ts type alias declaration" | "ts type annotation" | "ts type assertion" | "ts type literal" | "ts type operator" | "ts type parameter" | "ts type parameter declaration" | "ts type parameter instantiation" | "ts type predicate" | "ts type query" | "ts type reference" | "ts undefined keyword" | "ts union type" | "ts unknown keyword" | "ts void keyword";
281
281
  type ReadableNodeType = ReturnType<typeof toReadableNodeType>;
282
282
 
283
- export { type FunctionInitPath, ITERATOR_FUNCTION_INDEX_PARAM_POSITION, type ReadableNodeType, 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, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayMapCallLoose, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
283
+ export { type FunctionInitPath, type ReadableNodeType, 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, getArrayMethodIndexParamPosition, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var eff = require('@eslint-react/eff');
4
3
  var types = require('@typescript-eslint/types');
4
+ var eff = require('@eslint-react/eff');
5
5
  var utils = require('@typescript-eslint/utils');
6
6
  var typescriptEstree = require('@typescript-eslint/typescript-estree');
7
7
  var stringTs = require('string-ts');
8
8
 
9
- // src/constants.ts
10
- var ITERATOR_FUNCTION_INDEX_PARAM_POSITION = /* @__PURE__ */ new Map([
9
+ // src/array-methods.ts
10
+ var indexParamPosition = /* @__PURE__ */ new Map([
11
11
  ["every", 1],
12
12
  ["filter", 1],
13
13
  ["find", 1],
@@ -21,6 +21,16 @@ var ITERATOR_FUNCTION_INDEX_PARAM_POSITION = /* @__PURE__ */ new Map([
21
21
  ["reduceRight", 2],
22
22
  ["some", 1]
23
23
  ]);
24
+ function getArrayMethodIndexParamPosition(methodName) {
25
+ return indexParamPosition.get(methodName) ?? -1;
26
+ }
27
+ function isArrayMapCall(node) {
28
+ if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
29
+ if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
30
+ if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) return false;
31
+ const { name } = node.callee.property;
32
+ return name === "map" || name.endsWith("Map");
33
+ }
24
34
  function findParentNode(node, test) {
25
35
  if (node == null) return eff._;
26
36
  let parent = node.parent;
@@ -456,19 +466,23 @@ function getTopLevelIdentifier(node) {
456
466
  return eff._;
457
467
  }
458
468
  }
459
- function isArrayMapCallLoose(node) {
460
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
461
- if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
462
- if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) return false;
463
- const { name } = node.callee.property;
464
- return name === "map" || name.endsWith("Map");
465
- }
466
469
  function isEmptyFunction(node) {
467
470
  return node.body.type === types.AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
468
471
  }
469
- function isKindOfLiteral(node, kind) {
472
+
473
+ // src/is-multi-line.ts
474
+ function isMultiLine(node) {
475
+ return node.loc.start.line !== node.loc.end.line;
476
+ }
477
+
478
+ // src/is-line-break.ts
479
+ function isLineBreak(node) {
480
+ return isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
481
+ }
482
+ function isLiteral(node, type) {
470
483
  if (node.type !== types.AST_NODE_TYPES.Literal) return false;
471
- switch (kind) {
484
+ if (type == null) return true;
485
+ switch (type) {
472
486
  case "boolean":
473
487
  return typeof node.value === "boolean";
474
488
  case "null":
@@ -481,16 +495,6 @@ function isKindOfLiteral(node, kind) {
481
495
  return typeof node.value === "string";
482
496
  }
483
497
  }
484
-
485
- // src/is-multi-line.ts
486
- function isMultiLine(node) {
487
- return node.loc.start.line !== node.loc.end.line;
488
- }
489
-
490
- // src/is-line-break.ts
491
- function isLineBreak(node) {
492
- return isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
493
- }
494
498
  var isNodeEqual = eff.dual(2, (a, b) => {
495
499
  switch (true) {
496
500
  case a === b:
@@ -581,8 +585,8 @@ function toReadableNodeType(node) {
581
585
  return stringTs.toLowerCase(stringTs.delimiterCase(node.type, " "));
582
586
  }
583
587
 
584
- exports.ITERATOR_FUNCTION_INDEX_PARAM_POSITION = ITERATOR_FUNCTION_INDEX_PARAM_POSITION;
585
588
  exports.findParentNode = findParentNode;
589
+ exports.getArrayMethodIndexParamPosition = getArrayMethodIndexParamPosition;
586
590
  exports.getClassIdentifier = getClassIdentifier;
587
591
  exports.getEcmaExpression = getEcmaExpression;
588
592
  exports.getFunctionIdentifier = getFunctionIdentifier;
@@ -597,7 +601,7 @@ exports.getPropertyName = getPropertyName;
597
601
  exports.getTopLevelIdentifier = getTopLevelIdentifier;
598
602
  exports.hasCallInFunctionInitPath = hasCallInFunctionInitPath;
599
603
  exports.is = is;
600
- exports.isArrayMapCallLoose = isArrayMapCallLoose;
604
+ exports.isArrayMapCall = isArrayMapCall;
601
605
  exports.isArrayTupleType = isArrayTupleType;
602
606
  exports.isClass = isClass;
603
607
  exports.isConditional = isConditional;
@@ -610,10 +614,10 @@ exports.isJSX = isJSX;
610
614
  exports.isJSXElement = isJSXElement;
611
615
  exports.isJSXFragment = isJSXFragment;
612
616
  exports.isJSXTagNameExpression = isJSXTagNameExpression;
613
- exports.isKindOfLiteral = isKindOfLiteral;
614
617
  exports.isLeftHandSideExpression = isLeftHandSideExpression;
615
618
  exports.isLeftHandSideExpressionType = isLeftHandSideExpressionType;
616
619
  exports.isLineBreak = isLineBreak;
620
+ exports.isLiteral = isLiteral;
617
621
  exports.isLoop = isLoop;
618
622
  exports.isMethodOrProperty = isMethodOrProperty;
619
623
  exports.isMultiLine = isMultiLine;
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { or, dual, _ } from '@eslint-react/eff';
2
1
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
+ import { or, dual, _ } from '@eslint-react/eff';
3
3
  import { ASTUtils } from '@typescript-eslint/utils';
4
4
  import { AST_NODE_TYPES as AST_NODE_TYPES$1, simpleTraverse } from '@typescript-eslint/typescript-estree';
5
5
  import { toLowerCase, delimiterCase, replace } from 'string-ts';
6
6
 
7
- // src/constants.ts
8
- var ITERATOR_FUNCTION_INDEX_PARAM_POSITION = /* @__PURE__ */ new Map([
7
+ // src/array-methods.ts
8
+ var indexParamPosition = /* @__PURE__ */ new Map([
9
9
  ["every", 1],
10
10
  ["filter", 1],
11
11
  ["find", 1],
@@ -19,6 +19,16 @@ var ITERATOR_FUNCTION_INDEX_PARAM_POSITION = /* @__PURE__ */ new Map([
19
19
  ["reduceRight", 2],
20
20
  ["some", 1]
21
21
  ]);
22
+ function getArrayMethodIndexParamPosition(methodName) {
23
+ return indexParamPosition.get(methodName) ?? -1;
24
+ }
25
+ function isArrayMapCall(node) {
26
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
27
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
28
+ if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
29
+ const { name } = node.callee.property;
30
+ return name === "map" || name.endsWith("Map");
31
+ }
22
32
  function findParentNode(node, test) {
23
33
  if (node == null) return _;
24
34
  let parent = node.parent;
@@ -454,19 +464,23 @@ function getTopLevelIdentifier(node) {
454
464
  return _;
455
465
  }
456
466
  }
457
- function isArrayMapCallLoose(node) {
458
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
459
- if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
460
- if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
461
- const { name } = node.callee.property;
462
- return name === "map" || name.endsWith("Map");
463
- }
464
467
  function isEmptyFunction(node) {
465
468
  return node.body.type === AST_NODE_TYPES.BlockStatement && node.body.body.length === 0;
466
469
  }
467
- function isKindOfLiteral(node, kind) {
470
+
471
+ // src/is-multi-line.ts
472
+ function isMultiLine(node) {
473
+ return node.loc.start.line !== node.loc.end.line;
474
+ }
475
+
476
+ // src/is-line-break.ts
477
+ function isLineBreak(node) {
478
+ return isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
479
+ }
480
+ function isLiteral(node, type) {
468
481
  if (node.type !== AST_NODE_TYPES.Literal) return false;
469
- switch (kind) {
482
+ if (type == null) return true;
483
+ switch (type) {
470
484
  case "boolean":
471
485
  return typeof node.value === "boolean";
472
486
  case "null":
@@ -479,16 +493,6 @@ function isKindOfLiteral(node, kind) {
479
493
  return typeof node.value === "string";
480
494
  }
481
495
  }
482
-
483
- // src/is-multi-line.ts
484
- function isMultiLine(node) {
485
- return node.loc.start.line !== node.loc.end.line;
486
- }
487
-
488
- // src/is-line-break.ts
489
- function isLineBreak(node) {
490
- return isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText])(node) && typeof node.value === "string" && node.value.trim() === "" && isMultiLine(node);
491
- }
492
496
  var isNodeEqual = dual(2, (a, b) => {
493
497
  switch (true) {
494
498
  case a === b:
@@ -579,4 +583,4 @@ function toReadableNodeType(node) {
579
583
  return toLowerCase(delimiterCase(node.type, " "));
580
584
  }
581
585
 
582
- export { ITERATOR_FUNCTION_INDEX_PARAM_POSITION, findParentNode, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayMapCallLoose, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isKindOfLiteral, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
586
+ export { findParentNode, getArrayMethodIndexParamPosition, getClassIdentifier, getEcmaExpression, getFunctionIdentifier, getFunctionInitPath, getLiteralValueType, getNestedCallExpressions, getNestedExpressionsOfType, getNestedIdentifiers, getNestedNewExpressions, getNestedReturnStatements, getPropertyName, getTopLevelIdentifier, hasCallInFunctionInitPath, is, isArrayMapCall, isArrayTupleType, isClass, isConditional, isControlFlow, isDestructuringPattern, isEmptyFunction, isFunction, isFunctionType, isJSX, isJSXElement, isJSXFragment, isJSXTagNameExpression, isLeftHandSideExpression, isLeftHandSideExpressionType, isLineBreak, isLiteral, isLoop, isMethodOrProperty, isMultiLine, isNodeEqual, isOneOf, isProperty, isThisExpression, isTypeAssertionExpression, isTypeDeclaration, isTypeExpression, toReadableNodeName, toReadableNodeType };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "1.40.4-next.4",
3
+ "version": "1.40.4-next.6",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -40,7 +40,7 @@
40
40
  "@typescript-eslint/utils": "^8.29.0",
41
41
  "string-ts": "^2.2.1",
42
42
  "ts-pattern": "^5.7.0",
43
- "@eslint-react/eff": "1.40.4-next.4"
43
+ "@eslint-react/eff": "1.40.4-next.6"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.4.0",