@eslint-react/ast 1.23.2-next.6 → 1.23.3-next.0

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.js CHANGED
@@ -41,7 +41,9 @@ function findParentNodeStop(node, stopNode, predicate) {
41
41
  }
42
42
  function getFunctionInitPath(node) {
43
43
  const { parent } = node;
44
- if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) return eff.O.some([node]);
44
+ if (node.type === types.AST_NODE_TYPES.FunctionDeclaration) {
45
+ return eff.O.some([node]);
46
+ }
45
47
  if (parent.type === types.AST_NODE_TYPES.VariableDeclarator) {
46
48
  return eff.O.some([
47
49
  parent.parent,
@@ -101,8 +103,12 @@ function hasCallInFunctionInitPath(callName) {
101
103
  eff.O.exists((nodes) => {
102
104
  return nodes.some(
103
105
  (n) => {
104
- if (n.type !== types.AST_NODE_TYPES.CallExpression) return false;
105
- if (n.callee.type === types.AST_NODE_TYPES.Identifier) return n.callee.name === callName;
106
+ if (n.type !== types.AST_NODE_TYPES.CallExpression) {
107
+ return false;
108
+ }
109
+ if (n.callee.type === types.AST_NODE_TYPES.Identifier) {
110
+ return n.callee.name === callName;
111
+ }
106
112
  return "property" in n.callee && "name" in n.callee.property && n.callee.property.name === callName;
107
113
  }
108
114
  );
@@ -111,7 +117,9 @@ function hasCallInFunctionInitPath(callName) {
111
117
  };
112
118
  }
113
119
  function getClassIdentifier(node) {
114
- if (node.id) return eff.O.fromNullable(node.id);
120
+ if (node.id) {
121
+ return eff.O.fromNullable(node.id);
122
+ }
115
123
  if (node.parent.type === types.AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === types.AST_NODE_TYPES.Identifier) {
116
124
  return eff.O.fromNullable(node.parent.id);
117
125
  }
@@ -286,7 +294,9 @@ function getFunctionIdentifier(node) {
286
294
  return eff.O.none();
287
295
  }
288
296
  function getIdentifiersFromBinaryExpression(side) {
289
- if (side.type === types.AST_NODE_TYPES.Identifier) return [side];
297
+ if (side.type === types.AST_NODE_TYPES.Identifier) {
298
+ return [side];
299
+ }
290
300
  if (side.type === types.AST_NODE_TYPES.BinaryExpression) {
291
301
  return [
292
302
  ...getIdentifiersFromBinaryExpression(side.left),
@@ -453,9 +463,13 @@ function getNestedReturnStatements(node) {
453
463
  const functionNode = isFunction(node) ? node : eff.O.getOrNull(findParentNodeGuard(node, isFunction));
454
464
  typescriptEstree.simpleTraverse(node, {
455
465
  enter(node2) {
456
- if (node2.type !== types.AST_NODE_TYPES.ReturnStatement) return;
466
+ if (node2.type !== types.AST_NODE_TYPES.ReturnStatement) {
467
+ return;
468
+ }
457
469
  const parentFunction = eff.O.getOrNull(findParentNodeGuard(node2, isFunction));
458
- if (parentFunction !== functionNode) return;
470
+ if (parentFunction !== functionNode) {
471
+ return;
472
+ }
459
473
  returnStatements.push(node2);
460
474
  }
461
475
  });
@@ -508,9 +522,15 @@ function isKeyLiteralLike(node, property) {
508
522
  return tsPattern.match(property).with({ type: types.AST_NODE_TYPES.Literal }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.TemplateLiteral, expressions: [] }, eff.F.constTrue).with({ type: types.AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(eff.F.constFalse);
509
523
  }
510
524
  function isMapCallLoose(node) {
511
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
512
- if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) return false;
513
- if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) return false;
525
+ if (node.type !== types.AST_NODE_TYPES.CallExpression) {
526
+ return false;
527
+ }
528
+ if (node.callee.type !== types.AST_NODE_TYPES.MemberExpression) {
529
+ return false;
530
+ }
531
+ if (node.callee.property.type !== types.AST_NODE_TYPES.Identifier) {
532
+ return false;
533
+ }
514
534
  const { name } = node.callee.property;
515
535
  return name === "map" || name.endsWith("Map");
516
536
  }
@@ -530,9 +550,15 @@ var isNodeEqual = eff.F.dual(2, (a, b) => {
530
550
  case (a.type === types.AST_NODE_TYPES.TemplateElement && b.type === types.AST_NODE_TYPES.TemplateElement):
531
551
  return a.value.raw === b.value.raw;
532
552
  case (a.type === types.AST_NODE_TYPES.TemplateLiteral && b.type === types.AST_NODE_TYPES.TemplateLiteral):
533
- if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) return false;
534
- if (!types$1.zip(a.quasis, b.quasis).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
535
- if (!types$1.zip(a.expressions, b.expressions).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
553
+ if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) {
554
+ return false;
555
+ }
556
+ if (!types$1.zip(a.quasis, b.quasis).every(([a2, b2]) => isNodeEqual(a2, b2))) {
557
+ return false;
558
+ }
559
+ if (!types$1.zip(a.expressions, b.expressions).every(([a2, b2]) => isNodeEqual(a2, b2))) {
560
+ return false;
561
+ }
536
562
  return true;
537
563
  case (a.type === types.AST_NODE_TYPES.Identifier && b.type === types.AST_NODE_TYPES.Identifier):
538
564
  return a.name === b.name;
@@ -541,8 +567,12 @@ var isNodeEqual = eff.F.dual(2, (a, b) => {
541
567
  case (a.type === types.AST_NODE_TYPES.MemberExpression && b.type === types.AST_NODE_TYPES.MemberExpression):
542
568
  return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
543
569
  case (a.type === types.AST_NODE_TYPES.JSXAttribute && b.type === types.AST_NODE_TYPES.JSXAttribute): {
544
- if (a.name.name !== b.name.name) return false;
545
- if (a.value === null || b.value === null) return a.value === b.value;
570
+ if (a.name.name !== b.name.name) {
571
+ return false;
572
+ }
573
+ if (a.value === null || b.value === null) {
574
+ return a.value === b.value;
575
+ }
546
576
  return isNodeEqual(a.value, b.value);
547
577
  }
548
578
  case (a.type === types.AST_NODE_TYPES.ThisExpression && b.type === types.AST_NODE_TYPES.ThisExpression):
@@ -587,16 +617,22 @@ function toReadableNodeName(node, getText) {
587
617
  }
588
618
  function toReadableNodeType(node) {
589
619
  if (node.type === types.AST_NODE_TYPES.Literal) {
590
- if ("regex" in node) return "RegExp literal";
620
+ if ("regex" in node) {
621
+ return "RegExp literal";
622
+ }
591
623
  return `${getLiteralValueType(node.value)} literal`;
592
624
  }
593
- if (isJSX(node)) return `JSX ${stringTs.toLowerCase(stringTs.delimiterCase(stringTs.replace(node.type, "JSX", ""), " "))}`;
625
+ if (isJSX(node)) {
626
+ return `JSX ${stringTs.toLowerCase(stringTs.delimiterCase(stringTs.replace(node.type, "JSX", ""), " "))}`;
627
+ }
594
628
  return stringTs.toLowerCase(stringTs.delimiterCase(node.type, " "));
595
629
  }
596
630
 
597
631
  // src/unwrap-type-expression.ts
598
632
  function unwrapTypeExpression(node) {
599
- if (isTypeExpression(node)) return unwrapTypeExpression(node.expression);
633
+ if (isTypeExpression(node)) {
634
+ return unwrapTypeExpression(node.expression);
635
+ }
600
636
  return node;
601
637
  }
602
638
 
package/dist/index.mjs CHANGED
@@ -39,7 +39,9 @@ function findParentNodeStop(node, stopNode, predicate) {
39
39
  }
40
40
  function getFunctionInitPath(node) {
41
41
  const { parent } = node;
42
- if (node.type === AST_NODE_TYPES.FunctionDeclaration) return O.some([node]);
42
+ if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
43
+ return O.some([node]);
44
+ }
43
45
  if (parent.type === AST_NODE_TYPES.VariableDeclarator) {
44
46
  return O.some([
45
47
  parent.parent,
@@ -99,8 +101,12 @@ function hasCallInFunctionInitPath(callName) {
99
101
  O.exists((nodes) => {
100
102
  return nodes.some(
101
103
  (n) => {
102
- if (n.type !== AST_NODE_TYPES.CallExpression) return false;
103
- if (n.callee.type === AST_NODE_TYPES.Identifier) return n.callee.name === callName;
104
+ if (n.type !== AST_NODE_TYPES.CallExpression) {
105
+ return false;
106
+ }
107
+ if (n.callee.type === AST_NODE_TYPES.Identifier) {
108
+ return n.callee.name === callName;
109
+ }
104
110
  return "property" in n.callee && "name" in n.callee.property && n.callee.property.name === callName;
105
111
  }
106
112
  );
@@ -109,7 +115,9 @@ function hasCallInFunctionInitPath(callName) {
109
115
  };
110
116
  }
111
117
  function getClassIdentifier(node) {
112
- if (node.id) return O.fromNullable(node.id);
118
+ if (node.id) {
119
+ return O.fromNullable(node.id);
120
+ }
113
121
  if (node.parent.type === AST_NODE_TYPES.VariableDeclarator && node.parent.id.type === AST_NODE_TYPES.Identifier) {
114
122
  return O.fromNullable(node.parent.id);
115
123
  }
@@ -284,7 +292,9 @@ function getFunctionIdentifier(node) {
284
292
  return O.none();
285
293
  }
286
294
  function getIdentifiersFromBinaryExpression(side) {
287
- if (side.type === AST_NODE_TYPES.Identifier) return [side];
295
+ if (side.type === AST_NODE_TYPES.Identifier) {
296
+ return [side];
297
+ }
288
298
  if (side.type === AST_NODE_TYPES.BinaryExpression) {
289
299
  return [
290
300
  ...getIdentifiersFromBinaryExpression(side.left),
@@ -451,9 +461,13 @@ function getNestedReturnStatements(node) {
451
461
  const functionNode = isFunction(node) ? node : O.getOrNull(findParentNodeGuard(node, isFunction));
452
462
  simpleTraverse(node, {
453
463
  enter(node2) {
454
- if (node2.type !== AST_NODE_TYPES.ReturnStatement) return;
464
+ if (node2.type !== AST_NODE_TYPES.ReturnStatement) {
465
+ return;
466
+ }
455
467
  const parentFunction = O.getOrNull(findParentNodeGuard(node2, isFunction));
456
- if (parentFunction !== functionNode) return;
468
+ if (parentFunction !== functionNode) {
469
+ return;
470
+ }
457
471
  returnStatements.push(node2);
458
472
  }
459
473
  });
@@ -506,9 +520,15 @@ function isKeyLiteralLike(node, property) {
506
520
  return match(property).with({ type: AST_NODE_TYPES.Literal }, F.constTrue).with({ type: AST_NODE_TYPES.TemplateLiteral, expressions: [] }, F.constTrue).with({ type: AST_NODE_TYPES.Identifier }, () => !node.computed).otherwise(F.constFalse);
507
521
  }
508
522
  function isMapCallLoose(node) {
509
- if (node.type !== AST_NODE_TYPES.CallExpression) return false;
510
- if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
511
- if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
523
+ if (node.type !== AST_NODE_TYPES.CallExpression) {
524
+ return false;
525
+ }
526
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression) {
527
+ return false;
528
+ }
529
+ if (node.callee.property.type !== AST_NODE_TYPES.Identifier) {
530
+ return false;
531
+ }
512
532
  const { name } = node.callee.property;
513
533
  return name === "map" || name.endsWith("Map");
514
534
  }
@@ -528,9 +548,15 @@ var isNodeEqual = F.dual(2, (a, b) => {
528
548
  case (a.type === AST_NODE_TYPES.TemplateElement && b.type === AST_NODE_TYPES.TemplateElement):
529
549
  return a.value.raw === b.value.raw;
530
550
  case (a.type === AST_NODE_TYPES.TemplateLiteral && b.type === AST_NODE_TYPES.TemplateLiteral):
531
- if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) return false;
532
- if (!zip(a.quasis, b.quasis).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
533
- if (!zip(a.expressions, b.expressions).every(([a2, b2]) => isNodeEqual(a2, b2))) return false;
551
+ if (a.quasis.length !== b.quasis.length || a.expressions.length !== b.expressions.length) {
552
+ return false;
553
+ }
554
+ if (!zip(a.quasis, b.quasis).every(([a2, b2]) => isNodeEqual(a2, b2))) {
555
+ return false;
556
+ }
557
+ if (!zip(a.expressions, b.expressions).every(([a2, b2]) => isNodeEqual(a2, b2))) {
558
+ return false;
559
+ }
534
560
  return true;
535
561
  case (a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier):
536
562
  return a.name === b.name;
@@ -539,8 +565,12 @@ var isNodeEqual = F.dual(2, (a, b) => {
539
565
  case (a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression):
540
566
  return isNodeEqual(a.property, b.property) && isNodeEqual(a.object, b.object);
541
567
  case (a.type === AST_NODE_TYPES.JSXAttribute && b.type === AST_NODE_TYPES.JSXAttribute): {
542
- if (a.name.name !== b.name.name) return false;
543
- if (a.value === null || b.value === null) return a.value === b.value;
568
+ if (a.name.name !== b.name.name) {
569
+ return false;
570
+ }
571
+ if (a.value === null || b.value === null) {
572
+ return a.value === b.value;
573
+ }
544
574
  return isNodeEqual(a.value, b.value);
545
575
  }
546
576
  case (a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression):
@@ -585,16 +615,22 @@ function toReadableNodeName(node, getText) {
585
615
  }
586
616
  function toReadableNodeType(node) {
587
617
  if (node.type === AST_NODE_TYPES.Literal) {
588
- if ("regex" in node) return "RegExp literal";
618
+ if ("regex" in node) {
619
+ return "RegExp literal";
620
+ }
589
621
  return `${getLiteralValueType(node.value)} literal`;
590
622
  }
591
- if (isJSX(node)) return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), " "))}`;
623
+ if (isJSX(node)) {
624
+ return `JSX ${toLowerCase(delimiterCase(replace(node.type, "JSX", ""), " "))}`;
625
+ }
592
626
  return toLowerCase(delimiterCase(node.type, " "));
593
627
  }
594
628
 
595
629
  // src/unwrap-type-expression.ts
596
630
  function unwrapTypeExpression(node) {
597
- if (isTypeExpression(node)) return unwrapTypeExpression(node.expression);
631
+ if (isTypeExpression(node)) {
632
+ return unwrapTypeExpression(node.expression);
633
+ }
598
634
  return node;
599
635
  }
600
636
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/ast",
3
- "version": "1.23.2-next.6",
3
+ "version": "1.23.3-next.0",
4
4
  "description": "ESLint React's TSESTree AST utility module.",
5
5
  "homepage": "https://github.com/rEl1cx/eslint-react",
6
6
  "bugs": {
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Eva1ent<rel1cx@proton.me>",
16
+ "sideEffects": false,
16
17
  "exports": {
17
18
  ".": {
18
19
  "import": {
@@ -27,6 +28,7 @@
27
28
  "./package.json": "./package.json"
28
29
  },
29
30
  "main": "dist/index.js",
31
+ "module": "dist/index.mjs",
30
32
  "types": "dist/index.d.ts",
31
33
  "files": [
32
34
  "dist",
@@ -38,8 +40,8 @@
38
40
  "@typescript-eslint/utils": "^8.19.1",
39
41
  "string-ts": "^2.2.0",
40
42
  "ts-pattern": "^5.6.0",
41
- "@eslint-react/eff": "1.23.2-next.6",
42
- "@eslint-react/types": "1.23.2-next.6"
43
+ "@eslint-react/types": "1.23.3-next.0",
44
+ "@eslint-react/eff": "1.23.3-next.0"
43
45
  },
44
46
  "devDependencies": {
45
47
  "tsup": "^8.3.5",
@@ -49,8 +51,6 @@
49
51
  "bun": ">=1.0.15",
50
52
  "node": ">=18.18.0"
51
53
  },
52
- "sideEffects": false,
53
- "module": "dist/index.mjs",
54
54
  "scripts": {
55
55
  "build": "tsup",
56
56
  "lint:publish": "publint",