eslint-plugin-react-x 2.7.1-beta.0 → 2.7.1-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -24
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -68,7 +68,7 @@ const rules$7 = {
68
68
  //#endregion
69
69
  //#region package.json
70
70
  var name$6 = "eslint-plugin-react-x";
71
- var version = "2.7.1-beta.0";
71
+ var version = "2.7.1-beta.1";
72
72
 
73
73
  //#endregion
74
74
  //#region src/utils/create-rule.ts
@@ -657,22 +657,22 @@ function create$53(context) {
657
657
  //#region src/rules/no-array-index-key.ts
658
658
  const RULE_NAME$52 = "no-array-index-key";
659
659
  const REACT_CHILDREN_METHOD = ["forEach", "map"];
660
- const arrayIndexParamPosition = new Map([
661
- ["every", 1],
662
- ["filter", 1],
663
- ["find", 1],
664
- ["findIndex", 1],
665
- ["findLast", 1],
666
- ["findLastIndex", 1],
667
- ["flatMap", 1],
668
- ["forEach", 1],
669
- ["map", 1],
670
- ["reduce", 2],
671
- ["reduceRight", 2],
672
- ["some", 1]
673
- ]);
674
- function getArrayIndexParamPosition(methodName) {
675
- return arrayIndexParamPosition.get(methodName) ?? -1;
660
+ function getIndexParamPosition(methodName) {
661
+ switch (methodName) {
662
+ case "every":
663
+ case "filter":
664
+ case "find":
665
+ case "findIndex":
666
+ case "findLast":
667
+ case "findLastIndex":
668
+ case "flatMap":
669
+ case "forEach":
670
+ case "map":
671
+ case "some": return 1;
672
+ case "reduce":
673
+ case "reduceRight": return 2;
674
+ default: return -1;
675
+ }
676
676
  }
677
677
  function isReactChildrenMethod(name$9) {
678
678
  return REACT_CHILDREN_METHOD.includes(name$9);
@@ -692,7 +692,7 @@ function getMapIndexParamName(context, node) {
692
692
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return unit;
693
693
  if (callee.property.type !== AST_NODE_TYPES.Identifier) return unit;
694
694
  const { name: name$9 } = callee.property;
695
- const indexPosition = getArrayIndexParamPosition(name$9);
695
+ const indexPosition = getIndexParamPosition(name$9);
696
696
  if (indexPosition === -1) return unit;
697
697
  const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
698
698
  if (callbackArg == null) return unit;
@@ -2151,16 +2151,24 @@ function create$20(context) {
2151
2151
  }
2152
2152
  };
2153
2153
  }
2154
+ function getArrayMethodCallbackPosition(methodName) {
2155
+ switch (methodName) {
2156
+ case "filter":
2157
+ case "flatMap":
2158
+ case "forEach":
2159
+ case "map":
2160
+ case "reduce":
2161
+ case "reduceRight": return 0;
2162
+ case "from":
2163
+ case "fromAsync": return 1;
2164
+ default: return -1;
2165
+ }
2166
+ }
2154
2167
  function isArrayMethodCallback(node) {
2155
2168
  const parent = node.parent;
2156
2169
  if (parent?.type !== AST_NODE_TYPES.CallExpression) return false;
2157
2170
  if (parent.callee.type !== AST_NODE_TYPES.MemberExpression || parent.callee.property.type !== AST_NODE_TYPES.Identifier) return false;
2158
- switch (parent.callee.property.name) {
2159
- case "map":
2160
- case "flatMap": return parent.arguments[0] === node;
2161
- case "from": return parent.arguments[1] === node;
2162
- default: return false;
2163
- }
2171
+ return parent.arguments[getArrayMethodCallbackPosition(parent.callee.property.name)] === node;
2164
2172
  }
2165
2173
 
2166
2174
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.7.1-beta.0",
3
+ "version": "2.7.1-beta.1",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -46,11 +46,11 @@
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-api-utils": "^2.4.0",
48
48
  "ts-pattern": "^5.9.0",
49
- "@eslint-react/ast": "2.7.1-beta.0",
50
- "@eslint-react/core": "2.7.1-beta.0",
51
- "@eslint-react/eff": "2.7.1-beta.0",
52
- "@eslint-react/shared": "2.7.1-beta.0",
53
- "@eslint-react/var": "2.7.1-beta.0"
49
+ "@eslint-react/ast": "2.7.1-beta.1",
50
+ "@eslint-react/eff": "2.7.1-beta.1",
51
+ "@eslint-react/core": "2.7.1-beta.1",
52
+ "@eslint-react/shared": "2.7.1-beta.1",
53
+ "@eslint-react/var": "2.7.1-beta.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.8",