eslint-plugin-react-x 1.52.3-beta.1 → 1.52.3-beta.10

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # eslint-plugin-react-x
2
2
 
3
- A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.
3
+ 4-7x faster composable ESLint rules for for libraries and frameworks that use React as a UI runtime.
4
4
 
5
5
  ## Install
6
6
 
package/dist/index.js CHANGED
@@ -142,7 +142,7 @@ var settings3 = {
142
142
 
143
143
  // package.json
144
144
  var name4 = "eslint-plugin-react-x";
145
- var version = "1.52.3-beta.1";
145
+ var version = "1.52.3-beta.10";
146
146
  var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
147
147
 
148
148
  // src/rules/avoid-shorthand-boolean.ts
@@ -603,29 +603,29 @@ function isUsingReactChildren(context, node) {
603
603
  function getMapIndexParamName(context, node) {
604
604
  const { callee } = node;
605
605
  if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
606
- return eff._;
606
+ return eff.unit;
607
607
  }
608
608
  if (callee.property.type !== types.AST_NODE_TYPES.Identifier) {
609
- return eff._;
609
+ return eff.unit;
610
610
  }
611
611
  const { name: name5 } = callee.property;
612
612
  const indexPosition = AST8__namespace.getArrayMethodCallbackIndexParamPosition(name5);
613
613
  if (indexPosition === -1) {
614
- return eff._;
614
+ return eff.unit;
615
615
  }
616
616
  const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
617
617
  if (callbackArg == null) {
618
- return eff._;
618
+ return eff.unit;
619
619
  }
620
620
  if (!AST8__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
621
- return eff._;
621
+ return eff.unit;
622
622
  }
623
623
  const { params } = callbackArg;
624
624
  if (params.length < indexPosition + 1) {
625
- return eff._;
625
+ return eff.unit;
626
626
  }
627
627
  const param = params.at(indexPosition);
628
- return param != null && "name" in param ? param.name : eff._;
628
+ return param != null && "name" in param ? param.name : eff.unit;
629
629
  }
630
630
  function getIdentifiersFromBinaryExpression(side) {
631
631
  if (side.type === types.AST_NODE_TYPES.Identifier) {
@@ -1673,20 +1673,15 @@ function inspectVariantTypes(types) {
1673
1673
  variantTypes.add("nullish");
1674
1674
  }
1675
1675
  const booleans = types.filter(tsHelpers.isBooleanType);
1676
- switch (true) {
1677
- case (booleans.length === 1 && booleans[0] != null): {
1678
- const first = booleans[0];
1679
- if (tsApiUtils.isTrueLiteralType(first)) {
1680
- variantTypes.add("truthy boolean");
1681
- } else if (tsApiUtils.isFalseLiteralType(first)) {
1682
- variantTypes.add("falsy boolean");
1683
- }
1684
- break;
1685
- }
1686
- case booleans.length === 2: {
1687
- variantTypes.add("boolean");
1688
- break;
1676
+ const boolean0 = booleans[0];
1677
+ if (booleans.length === 1 && boolean0 != null) {
1678
+ if (tsApiUtils.isFalseLiteralType(boolean0)) {
1679
+ variantTypes.add("falsy boolean");
1680
+ } else if (tsApiUtils.isTrueLiteralType(boolean0)) {
1681
+ variantTypes.add("truthy boolean");
1689
1682
  }
1683
+ } else if (booleans.length === 2) {
1684
+ variantTypes.add("boolean");
1690
1685
  }
1691
1686
  const strings = types.filter(tsHelpers.isStringType);
1692
1687
  if (strings.length > 0) {
@@ -1750,9 +1745,9 @@ function create31(context) {
1750
1745
  ];
1751
1746
  const services = utils.ESLintUtils.getParserServices(context, false);
1752
1747
  function getReportDescriptor(node) {
1753
- if (node == null) return eff._;
1748
+ if (node == null) return eff.unit;
1754
1749
  if (AST8__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(node)) return getReportDescriptor(node.expression);
1755
- if (AST8__namespace.isJSX(node)) return eff._;
1750
+ if (AST8__namespace.isJSX(node)) return eff.unit;
1756
1751
  if (AST8__namespace.isTypeExpression(node)) return getReportDescriptor(node.expression);
1757
1752
  return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1758
1753
  const isLeftUnaryNot = left.type === types.AST_NODE_TYPES.UnaryExpression && left.operator === "!";
@@ -1784,8 +1779,8 @@ function create31(context) {
1784
1779
  }).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
1785
1780
  const variable = VAR2__namespace.findVariable(n.name, context.sourceCode.getScope(n));
1786
1781
  const variableDefNode = variable?.defs.at(0)?.node;
1787
- return tsPattern.match(variableDefNode).with({ init: tsPattern.P.select({ type: tsPattern.P.not(types.AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => eff._);
1788
- }).otherwise(() => eff._);
1782
+ return tsPattern.match(variableDefNode).with({ init: tsPattern.P.select({ type: tsPattern.P.not(types.AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => eff.unit);
1783
+ }).otherwise(() => eff.unit);
1789
1784
  }
1790
1785
  return {
1791
1786
  JSXExpressionContainer: eff.flow(getReportDescriptor, kit.Reporter.make(context).send)
package/dist/index.mjs CHANGED
@@ -6,10 +6,10 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';
6
6
  import * as VAR2 from '@eslint-react/var';
7
7
  import { match, isMatching, P } from 'ts-pattern';
8
8
  import * as AST8 from '@eslint-react/ast';
9
- import { flow, getOrElseUpdate, constTrue, constFalse, _ } from '@eslint-react/eff';
9
+ import { flow, getOrElseUpdate, constTrue, constFalse, unit } from '@eslint-react/eff';
10
10
  import { compare } from 'compare-versions';
11
11
  import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
12
- import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
12
+ import { unionTypeParts, isTypeFlagSet, isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
13
13
  import ts from 'typescript';
14
14
  import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
15
15
 
@@ -115,7 +115,7 @@ var settings3 = {
115
115
 
116
116
  // package.json
117
117
  var name4 = "eslint-plugin-react-x";
118
- var version = "1.52.3-beta.1";
118
+ var version = "1.52.3-beta.10";
119
119
  var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
120
120
 
121
121
  // src/rules/avoid-shorthand-boolean.ts
@@ -576,29 +576,29 @@ function isUsingReactChildren(context, node) {
576
576
  function getMapIndexParamName(context, node) {
577
577
  const { callee } = node;
578
578
  if (callee.type !== AST_NODE_TYPES.MemberExpression) {
579
- return _;
579
+ return unit;
580
580
  }
581
581
  if (callee.property.type !== AST_NODE_TYPES.Identifier) {
582
- return _;
582
+ return unit;
583
583
  }
584
584
  const { name: name5 } = callee.property;
585
585
  const indexPosition = AST8.getArrayMethodCallbackIndexParamPosition(name5);
586
586
  if (indexPosition === -1) {
587
- return _;
587
+ return unit;
588
588
  }
589
589
  const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
590
590
  if (callbackArg == null) {
591
- return _;
591
+ return unit;
592
592
  }
593
593
  if (!AST8.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
594
- return _;
594
+ return unit;
595
595
  }
596
596
  const { params } = callbackArg;
597
597
  if (params.length < indexPosition + 1) {
598
- return _;
598
+ return unit;
599
599
  }
600
600
  const param = params.at(indexPosition);
601
- return param != null && "name" in param ? param.name : _;
601
+ return param != null && "name" in param ? param.name : unit;
602
602
  }
603
603
  function getIdentifiersFromBinaryExpression(side) {
604
604
  if (side.type === AST_NODE_TYPES.Identifier) {
@@ -1646,20 +1646,15 @@ function inspectVariantTypes(types) {
1646
1646
  variantTypes.add("nullish");
1647
1647
  }
1648
1648
  const booleans = types.filter(tsHelpers.isBooleanType);
1649
- switch (true) {
1650
- case (booleans.length === 1 && booleans[0] != null): {
1651
- const first = booleans[0];
1652
- if (isTrueLiteralType(first)) {
1653
- variantTypes.add("truthy boolean");
1654
- } else if (isFalseLiteralType(first)) {
1655
- variantTypes.add("falsy boolean");
1656
- }
1657
- break;
1658
- }
1659
- case booleans.length === 2: {
1660
- variantTypes.add("boolean");
1661
- break;
1649
+ const boolean0 = booleans[0];
1650
+ if (booleans.length === 1 && boolean0 != null) {
1651
+ if (isFalseLiteralType(boolean0)) {
1652
+ variantTypes.add("falsy boolean");
1653
+ } else if (isTrueLiteralType(boolean0)) {
1654
+ variantTypes.add("truthy boolean");
1662
1655
  }
1656
+ } else if (booleans.length === 2) {
1657
+ variantTypes.add("boolean");
1663
1658
  }
1664
1659
  const strings = types.filter(tsHelpers.isStringType);
1665
1660
  if (strings.length > 0) {
@@ -1723,9 +1718,9 @@ function create31(context) {
1723
1718
  ];
1724
1719
  const services = ESLintUtils.getParserServices(context, false);
1725
1720
  function getReportDescriptor(node) {
1726
- if (node == null) return _;
1721
+ if (node == null) return unit;
1727
1722
  if (AST8.is(AST_NODE_TYPES.JSXExpressionContainer)(node)) return getReportDescriptor(node.expression);
1728
- if (AST8.isJSX(node)) return _;
1723
+ if (AST8.isJSX(node)) return unit;
1729
1724
  if (AST8.isTypeExpression(node)) return getReportDescriptor(node.expression);
1730
1725
  return match(node).with({ type: AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1731
1726
  const isLeftUnaryNot = left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!";
@@ -1757,8 +1752,8 @@ function create31(context) {
1757
1752
  }).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
1758
1753
  const variable = VAR2.findVariable(n.name, context.sourceCode.getScope(n));
1759
1754
  const variableDefNode = variable?.defs.at(0)?.node;
1760
- return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => _);
1761
- }).otherwise(() => _);
1755
+ return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => unit);
1756
+ }).otherwise(() => unit);
1762
1757
  }
1763
1758
  return {
1764
1759
  JSXExpressionContainer: flow(getReportDescriptor, Reporter.make(context).send)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.52.3-beta.1",
4
- "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
3
+ "version": "1.52.3-beta.10",
4
+ "description": "4-7x faster composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
7
7
  "eslint",
@@ -42,20 +42,20 @@
42
42
  "./package.json"
43
43
  ],
44
44
  "dependencies": {
45
- "@typescript-eslint/scope-manager": "^8.34.0",
46
- "@typescript-eslint/type-utils": "^8.34.0",
47
- "@typescript-eslint/types": "^8.34.0",
48
- "@typescript-eslint/utils": "^8.34.0",
45
+ "@typescript-eslint/scope-manager": "^8.35.1",
46
+ "@typescript-eslint/type-utils": "^8.35.1",
47
+ "@typescript-eslint/types": "^8.35.1",
48
+ "@typescript-eslint/utils": "^8.35.1",
49
49
  "compare-versions": "^6.1.1",
50
50
  "is-immutable-type": "^5.0.1",
51
51
  "string-ts": "^2.2.1",
52
52
  "ts-pattern": "^5.7.1",
53
- "@eslint-react/ast": "1.52.3-beta.1",
54
- "@eslint-react/eff": "1.52.3-beta.1",
55
- "@eslint-react/core": "1.52.3-beta.1",
56
- "@eslint-react/shared": "1.52.3-beta.1",
57
- "@eslint-react/kit": "1.52.3-beta.1",
58
- "@eslint-react/var": "1.52.3-beta.1"
53
+ "@eslint-react/ast": "1.52.3-beta.10",
54
+ "@eslint-react/core": "1.52.3-beta.10",
55
+ "@eslint-react/kit": "1.52.3-beta.10",
56
+ "@eslint-react/shared": "1.52.3-beta.10",
57
+ "@eslint-react/var": "1.52.3-beta.10",
58
+ "@eslint-react/eff": "1.52.3-beta.10"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/react": "^19.1.8",