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

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 +7 -18
  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.58";
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;
@@ -3990,7 +3976,6 @@ function create$9(context, [option]) {
3990
3976
  * Check if a fragment node is useless and should be reported
3991
3977
  */
3992
3978
  function checkNode(context, node) {
3993
- if (node.type === AST_NODE_TYPES.JSXElement && core.getJsxAttribute(context, node)("key") != null) return;
3994
3979
  if (core.isJsxHostElement(context, node.parent)) context.report({
3995
3980
  messageId: "default",
3996
3981
  node,
@@ -4056,6 +4041,8 @@ function create$9(context, [option]) {
4056
4041
  return defineRuleListener({
4057
4042
  JSXElement(node) {
4058
4043
  if (!core.isJsxFragmentElement(context, node, jsxConfig)) return;
4044
+ if (core.getJsxAttribute(context, node)("key") != null) return;
4045
+ if (core.getJsxAttribute(context, node)("ref") != null) return;
4059
4046
  checkNode(context, node);
4060
4047
  },
4061
4048
  JSXFragment(node) {
@@ -4262,6 +4249,8 @@ function create$5(context) {
4262
4249
  /**
4263
4250
  * Check if a test expression is a null check on `ref.current` for a given ref name.
4264
4251
  * Matches forms like `ref.current === null`, `null === ref.current`, and their != variants.
4252
+ * @param test
4253
+ * @param refName
4265
4254
  */
4266
4255
  function isRefCurrentNullCheck(test, refName) {
4267
4256
  if (test.type !== AST_NODE_TYPES.BinaryExpression) return false;
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.58",
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.58",
49
+ "@eslint-react/core": "3.0.0-next.58",
50
+ "@eslint-react/eff": "3.0.0-next.58",
51
+ "@eslint-react/var": "3.0.0-next.58",
52
+ "@eslint-react/shared": "3.0.0-next.58"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",