eslint-plugin-react-x 3.0.0-next.56 → 3.0.0-next.57

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 +3 -17
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_ESLINT_REACT_SETTINGS, IMPURE_CTORS, IMPURE_FUNCS, WEBSITE_URL, coerceSettings, defineRuleListener, getSettingsFromContext, report, toRegExp } from "@eslint-react/shared";
1
+ import { DEFAULT_ESLINT_REACT_SETTINGS, IMPURE_CTORS, IMPURE_FUNCS, WEBSITE_URL, defineRuleListener, getSettingsFromContext, report, toRegExp } from "@eslint-react/shared";
2
2
  import * as ast from "@eslint-react/ast";
3
3
  import * as core from "@eslint-react/core";
4
4
  import { ESLintUtils } from "@typescript-eslint/utils";
@@ -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 = "3.0.0-next.56";
71
+ var version = "3.0.0-next.57";
72
72
 
73
73
  //#endregion
74
74
  //#region src/utils/create-rule.ts
@@ -1812,7 +1812,6 @@ function create$51(context) {
1812
1812
  //#endregion
1813
1813
  //#region src/rules/no-array-index-key/no-array-index-key.ts
1814
1814
  const RULE_NAME$50 = "no-array-index-key";
1815
- const REACT_CHILDREN_METHOD = ["forEach", "map"];
1816
1815
  function getIndexParamPosition(methodName) {
1817
1816
  switch (methodName) {
1818
1817
  case "every":
@@ -1830,19 +1829,6 @@ function getIndexParamPosition(methodName) {
1830
1829
  default: return -1;
1831
1830
  }
1832
1831
  }
1833
- function isReactChildrenMethod(name) {
1834
- return REACT_CHILDREN_METHOD.includes(name);
1835
- }
1836
- function isUsingReactChildren(context, node) {
1837
- const { importSource = "react" } = coerceSettings(context.settings);
1838
- const { callee } = node;
1839
- if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) return false;
1840
- if (!isReactChildrenMethod(callee.property.name)) return false;
1841
- const initialScope = context.sourceCode.getScope(node);
1842
- if (callee.object.type === AST_NODE_TYPES.Identifier && callee.object.name === "Children") return true;
1843
- if (callee.object.type === AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) return core.isInitializedFromReact(callee.object.object.name, initialScope, importSource);
1844
- return false;
1845
- }
1846
1832
  function getMapIndexParamName(context, node) {
1847
1833
  const { callee } = node;
1848
1834
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return unit;
@@ -1850,7 +1836,7 @@ function getMapIndexParamName(context, node) {
1850
1836
  const { name } = callee.property;
1851
1837
  const indexPosition = getIndexParamPosition(name);
1852
1838
  if (indexPosition === -1) return unit;
1853
- const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
1839
+ const callbackArg = node.arguments[core.isChildrenMap(context, callee) || core.isChildrenForEach(context, callee) ? 1 : 0];
1854
1840
  if (callbackArg == null) return unit;
1855
1841
  if (!ast.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(callbackArg)) return unit;
1856
1842
  const { params } = callbackArg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-next.56",
3
+ "version": "3.0.0-next.57",
4
4
  "description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -45,11 +45,11 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.4.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/core": "3.0.0-next.56",
49
- "@eslint-react/eff": "3.0.0-next.56",
50
- "@eslint-react/shared": "3.0.0-next.56",
51
- "@eslint-react/ast": "3.0.0-next.56",
52
- "@eslint-react/var": "3.0.0-next.56"
48
+ "@eslint-react/ast": "3.0.0-next.57",
49
+ "@eslint-react/eff": "3.0.0-next.57",
50
+ "@eslint-react/shared": "3.0.0-next.57",
51
+ "@eslint-react/var": "3.0.0-next.57",
52
+ "@eslint-react/core": "3.0.0-next.57"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",