eslint-plugin-react-x 1.53.1-beta.0 → 1.53.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 (3) hide show
  1. package/dist/index.js +56 -59
  2. package/dist/index.mjs +28 -45
  3. package/package.json +12 -12
package/dist/index.js CHANGED
@@ -27,20 +27,34 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  }) : target, mod));
28
28
 
29
29
  //#endregion
30
- const __eslint_react_shared = __toESM(require("@eslint-react/shared"));
31
- const __eslint_react_core = __toESM(require("@eslint-react/core"));
32
- const __typescript_eslint_utils = __toESM(require("@typescript-eslint/utils"));
33
- const __eslint_react_kit = __toESM(require("@eslint-react/kit"));
34
- const __typescript_eslint_types = __toESM(require("@typescript-eslint/types"));
35
- const __eslint_react_var = __toESM(require("@eslint-react/var"));
36
- const ts_pattern = __toESM(require("ts-pattern"));
37
- const __eslint_react_ast = __toESM(require("@eslint-react/ast"));
38
- const __eslint_react_eff = __toESM(require("@eslint-react/eff"));
39
- const compare_versions = __toESM(require("compare-versions"));
40
- const __typescript_eslint_type_utils = __toESM(require("@typescript-eslint/type-utils"));
41
- const ts_api_utils = __toESM(require("ts-api-utils"));
42
- const typescript = __toESM(require("typescript"));
43
- const is_immutable_type = __toESM(require("is-immutable-type"));
30
+ let __eslint_react_shared = require("@eslint-react/shared");
31
+ __eslint_react_shared = __toESM(__eslint_react_shared);
32
+ let __eslint_react_core = require("@eslint-react/core");
33
+ __eslint_react_core = __toESM(__eslint_react_core);
34
+ let __typescript_eslint_utils = require("@typescript-eslint/utils");
35
+ __typescript_eslint_utils = __toESM(__typescript_eslint_utils);
36
+ let __eslint_react_kit = require("@eslint-react/kit");
37
+ __eslint_react_kit = __toESM(__eslint_react_kit);
38
+ let __typescript_eslint_types = require("@typescript-eslint/types");
39
+ __typescript_eslint_types = __toESM(__typescript_eslint_types);
40
+ let __eslint_react_var = require("@eslint-react/var");
41
+ __eslint_react_var = __toESM(__eslint_react_var);
42
+ let ts_pattern = require("ts-pattern");
43
+ ts_pattern = __toESM(ts_pattern);
44
+ let __eslint_react_ast = require("@eslint-react/ast");
45
+ __eslint_react_ast = __toESM(__eslint_react_ast);
46
+ let __eslint_react_eff = require("@eslint-react/eff");
47
+ __eslint_react_eff = __toESM(__eslint_react_eff);
48
+ let compare_versions = require("compare-versions");
49
+ compare_versions = __toESM(compare_versions);
50
+ let __typescript_eslint_type_utils = require("@typescript-eslint/type-utils");
51
+ __typescript_eslint_type_utils = __toESM(__typescript_eslint_type_utils);
52
+ let ts_api_utils = require("ts-api-utils");
53
+ ts_api_utils = __toESM(ts_api_utils);
54
+ let typescript = require("typescript");
55
+ typescript = __toESM(typescript);
56
+ let is_immutable_type = require("is-immutable-type");
57
+ is_immutable_type = __toESM(is_immutable_type);
44
58
 
45
59
  //#region src/configs/recommended.ts
46
60
  var recommended_exports = {};
@@ -132,7 +146,7 @@ const settings = { ...settings$1 };
132
146
  //#endregion
133
147
  //#region package.json
134
148
  var name = "eslint-plugin-react-x";
135
- var version = "1.53.1-beta.0";
149
+ var version = "1.53.1-beta.1";
136
150
 
137
151
  //#endregion
138
152
  //#region src/utils/create-rule.ts
@@ -363,11 +377,10 @@ var jsx_uses_react_default = createRule({
363
377
  defaultOptions: []
364
378
  });
365
379
  function create$51(context) {
366
- const jsxConfig = {
380
+ const { jsx, jsxFactory, jsxFragmentFactory } = {
367
381
  ...__eslint_react_kit.JsxConfig.getFromContext(context),
368
382
  ...__eslint_react_kit.JsxConfig.getFromAnnotation(context)
369
383
  };
370
- const { jsx, jsxFactory, jsxFragmentFactory } = jsxConfig;
371
384
  if (jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev) return {};
372
385
  function handleJsxElement(node) {
373
386
  context.sourceCode.markVariableAsUsed(jsxFactory, node);
@@ -510,8 +523,7 @@ function create$49(context) {
510
523
  const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
511
524
  if (setState == null || hasThisState) return;
512
525
  if (node.init == null || !__eslint_react_ast.isThisExpression(node.init) || node.id.type !== __typescript_eslint_types.AST_NODE_TYPES.ObjectPattern) return;
513
- const hasState = node.id.properties.some((prop) => prop.type === __typescript_eslint_types.AST_NODE_TYPES.Property && isKeyLiteral$2(prop, prop.key) && __eslint_react_ast.getPropertyName(prop.key) === "state");
514
- if (!hasState) return;
526
+ if (!node.id.properties.some((prop) => prop.type === __typescript_eslint_types.AST_NODE_TYPES.Property && isKeyLiteral$2(prop, prop.key) && __eslint_react_ast.getPropertyName(prop.key) === "state")) return;
515
527
  context.report({
516
528
  messageId: "noAccessStateInSetstate",
517
529
  node
@@ -1089,8 +1101,7 @@ function create$34(context) {
1089
1101
  const { version: version$1 } = (0, __eslint_react_shared.getSettingsFromContext)(context);
1090
1102
  if ((0, compare_versions.compare)(version$1, "19.0.0", "<")) return {};
1091
1103
  return { JSXElement(node) {
1092
- const fullName = __eslint_react_core.getElementType(context, node);
1093
- const parts = fullName.split(".");
1104
+ const parts = __eslint_react_core.getElementType(context, node).split(".");
1094
1105
  const selfName = parts.pop();
1095
1106
  const contextFullName = parts.join(".");
1096
1107
  const contextSelfName = parts.pop();
@@ -1507,23 +1518,20 @@ function create$27(context) {
1507
1518
  type: __typescript_eslint_types.AST_NODE_TYPES.LogicalExpression,
1508
1519
  operator: "&&"
1509
1520
  }, ({ left, right }) => {
1510
- const isLeftUnaryNot = left.type === __typescript_eslint_types.AST_NODE_TYPES.UnaryExpression && left.operator === "!";
1511
- if (isLeftUnaryNot) return getReportDescriptor(right);
1521
+ if (left.type === __typescript_eslint_types.AST_NODE_TYPES.UnaryExpression && left.operator === "!") return getReportDescriptor(right);
1512
1522
  const initialScope = context.sourceCode.getScope(left);
1513
- const isLeftNan = left.type === __typescript_eslint_types.AST_NODE_TYPES.Identifier && left.name === "NaN" || __eslint_react_var.toStaticValue({
1523
+ if (left.type === __typescript_eslint_types.AST_NODE_TYPES.Identifier && left.name === "NaN" || __eslint_react_var.toStaticValue({
1514
1524
  kind: "lazy",
1515
1525
  node: left,
1516
1526
  initialScope
1517
- }).value === "NaN";
1518
- if (isLeftNan) return {
1527
+ }).value === "NaN") return {
1519
1528
  messageId: "noLeakedConditionalRendering",
1520
1529
  node: left,
1521
1530
  data: { value: context.sourceCode.getText(left) }
1522
1531
  };
1523
1532
  const leftType = (0, __typescript_eslint_type_utils.getConstrainedTypeAtLocation)(services, left);
1524
1533
  const leftTypeVariants = inspectVariantTypes((0, ts_api_utils.unionTypeParts)(leftType));
1525
- const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
1526
- if (isLeftValid) return getReportDescriptor(right);
1534
+ if (Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type))) return getReportDescriptor(right);
1527
1535
  return {
1528
1536
  messageId: "noLeakedConditionalRendering",
1529
1537
  node: left,
@@ -1532,8 +1540,7 @@ function create$27(context) {
1532
1540
  }).with({ type: __typescript_eslint_types.AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
1533
1541
  return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
1534
1542
  }).with({ type: __typescript_eslint_types.AST_NODE_TYPES.Identifier }, (n) => {
1535
- const variable = __eslint_react_var.findVariable(n.name, context.sourceCode.getScope(n));
1536
- const variableDefNode = variable?.defs.at(0)?.node;
1543
+ const variableDefNode = __eslint_react_var.findVariable(n.name, context.sourceCode.getScope(n))?.defs.at(0)?.node;
1537
1544
  return (0, ts_pattern.match)(variableDefNode).with({ init: ts_pattern.P.select({ type: ts_pattern.P.not(__typescript_eslint_types.AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => __eslint_react_eff.unit);
1538
1545
  }).otherwise(() => __eslint_react_eff.unit);
1539
1546
  }
@@ -1623,13 +1630,12 @@ function create$25(context) {
1623
1630
  });
1624
1631
  continue;
1625
1632
  }
1626
- const hasDisplayNameAssignment = displayNameAssignments.some((node) => {
1633
+ if (!displayNameAssignments.some((node) => {
1627
1634
  const left = node.left;
1628
1635
  if (left.type !== __typescript_eslint_types.AST_NODE_TYPES.MemberExpression) return false;
1629
1636
  const object = left.object;
1630
1637
  return __eslint_react_core.isInstanceIdEqual(context, id, object);
1631
- });
1632
- if (!hasDisplayNameAssignment) {
1638
+ })) {
1633
1639
  const semi = __eslint_react_kit.LanguagePreference.defaultLanguagePreference.semicolons === "always" ? ";" : "";
1634
1640
  context.report({
1635
1641
  messageId: "noMissingContextDisplayName",
@@ -1959,19 +1965,16 @@ function create$21(context) {
1959
1965
  "Program:exit"(program) {
1960
1966
  const functionComponents = [...collector.ctx.getAllComponents(program).values()];
1961
1967
  const classComponents = [...collectorLegacy.ctx.getAllComponents(program).values()];
1962
- for (const lazy of lazyComponentDeclarations) {
1963
- const significantParent = __eslint_react_ast.findParentNode(lazy, (n) => {
1964
- if (__eslint_react_ast.isJSX(n)) return true;
1965
- if (n.type === __typescript_eslint_types.AST_NODE_TYPES.CallExpression) return __eslint_react_core.isReactHookCall(n) || __eslint_react_core.isCreateElementCall(context, n) || __eslint_react_core.isCreateContextCall(context, n);
1966
- if (__eslint_react_ast.isFunction(n)) return functionComponents.some((c) => c.node === n);
1967
- if (__eslint_react_ast.isClass(n)) return classComponents.some((c) => c.node === n);
1968
- return false;
1969
- });
1970
- if (significantParent != null) context.report({
1971
- messageId: "noNestedLazyComponentDeclarations",
1972
- node: lazy
1973
- });
1974
- }
1968
+ for (const lazy of lazyComponentDeclarations) if (__eslint_react_ast.findParentNode(lazy, (n) => {
1969
+ if (__eslint_react_ast.isJSX(n)) return true;
1970
+ if (n.type === __typescript_eslint_types.AST_NODE_TYPES.CallExpression) return __eslint_react_core.isReactHookCall(n) || __eslint_react_core.isCreateElementCall(context, n) || __eslint_react_core.isCreateContextCall(context, n);
1971
+ if (__eslint_react_ast.isFunction(n)) return functionComponents.some((c) => c.node === n);
1972
+ if (__eslint_react_ast.isClass(n)) return classComponents.some((c) => c.node === n);
1973
+ return false;
1974
+ }) != null) context.report({
1975
+ messageId: "noNestedLazyComponentDeclarations",
1976
+ node: lazy
1977
+ });
1975
1978
  }
1976
1979
  };
1977
1980
  }
@@ -2363,8 +2366,7 @@ function create$11(context) {
2363
2366
  return {
2364
2367
  ...listeners,
2365
2368
  JSXOpeningElement(node) {
2366
- const fullName = __eslint_react_core.getElementType(context, node.parent);
2367
- const selfName = fullName.split(".").at(-1);
2369
+ const selfName = __eslint_react_core.getElementType(context, node.parent).split(".").at(-1);
2368
2370
  if (selfName == null) return;
2369
2371
  if (!isContextName(selfName, isReact18OrBelow)) return;
2370
2372
  const functionEntry = ctx.getCurrentEntry();
@@ -2698,11 +2700,10 @@ function create$8(context) {
2698
2700
  if (currentMethod === constructorEntries.at(-1)) return;
2699
2701
  if (!currentClass.body.body.includes(currentMethod)) return;
2700
2702
  if (node.init == null || !__eslint_react_ast.isThisExpression(node.init) || node.id.type !== __typescript_eslint_types.AST_NODE_TYPES.ObjectPattern) return;
2701
- const hasState = node.id.properties.some((prop) => {
2703
+ if (!node.id.properties.some((prop) => {
2702
2704
  if (prop.type === __typescript_eslint_types.AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) return __eslint_react_ast.getPropertyName(prop.key) === "state";
2703
2705
  return false;
2704
- });
2705
- if (!hasState) return;
2706
+ })) return;
2706
2707
  const defNode = stateDefs.get(currentClass)?.node;
2707
2708
  stateDefs.set(currentClass, {
2708
2709
  node: defNode,
@@ -2822,8 +2823,7 @@ function create$6(context) {
2822
2823
  if (!__eslint_react_core.isForwardRefCall(context, node)) return;
2823
2824
  const [component] = node.arguments;
2824
2825
  if (component == null || !__eslint_react_ast.isFunction(component)) return;
2825
- const ref = component.params[1];
2826
- if (ref != null) return;
2826
+ if (component.params[1] != null) return;
2827
2827
  context.report({
2828
2828
  messageId: "noUselessForwardRef",
2829
2829
  node: node.callee
@@ -3055,8 +3055,7 @@ function create$3(context) {
3055
3055
  const importDeclarationText = context.sourceCode.getText(node.parent);
3056
3056
  const semi = importDeclarationText.endsWith(";") ? ";" : "";
3057
3057
  const quote = node.parent.source.raw.at(0) ?? "'";
3058
- const isTypeImport = node.parent.importKind === "type";
3059
- const importStringPrefix = `import${isTypeImport ? " type" : ""}`;
3058
+ const importStringPrefix = `import${node.parent.importKind === "type" ? " type" : ""}`;
3060
3059
  const importSourceQuoted = `${quote}${importSource}${quote}`;
3061
3060
  if (!hasOtherSpecifiers) return fixer.replaceText(node.parent, `${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`);
3062
3061
  const specifiers = importDeclarationText.slice(importDeclarationText.indexOf("{"), importDeclarationText.indexOf("}") + 1);
@@ -3139,8 +3138,7 @@ function create$1(context) {
3139
3138
  return { JSXAttribute(node) {
3140
3139
  const { value } = node;
3141
3140
  const propName = __eslint_react_core.getAttributeName(context, node);
3142
- const hasValueTrue = value?.type === __typescript_eslint_types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === __typescript_eslint_types.AST_NODE_TYPES.Literal && value.expression.value === true;
3143
- if (!hasValueTrue) return;
3141
+ if (!(value?.type === __typescript_eslint_types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === __typescript_eslint_types.AST_NODE_TYPES.Literal && value.expression.value === true)) return;
3144
3142
  context.report({
3145
3143
  messageId: "preferShorthandBoolean",
3146
3144
  node: node.value ?? node,
@@ -3172,8 +3170,7 @@ var prefer_shorthand_fragment_default = createRule({
3172
3170
  function create(context) {
3173
3171
  return { JSXElement(node) {
3174
3172
  if (!__eslint_react_core.isFragmentElement(context, node)) return;
3175
- const hasAttributes = node.openingElement.attributes.length > 0;
3176
- if (hasAttributes) return;
3173
+ if (node.openingElement.attributes.length > 0) return;
3177
3174
  context.report({
3178
3175
  messageId: "preferShorthandFragment",
3179
3176
  node,
package/dist/index.mjs CHANGED
@@ -113,7 +113,7 @@ const settings = { ...settings$1 };
113
113
  //#endregion
114
114
  //#region package.json
115
115
  var name = "eslint-plugin-react-x";
116
- var version = "1.53.1-beta.0";
116
+ var version = "1.53.1-beta.1";
117
117
 
118
118
  //#endregion
119
119
  //#region src/utils/create-rule.ts
@@ -344,11 +344,10 @@ var jsx_uses_react_default = createRule({
344
344
  defaultOptions: []
345
345
  });
346
346
  function create$51(context) {
347
- const jsxConfig = {
347
+ const { jsx, jsxFactory, jsxFragmentFactory } = {
348
348
  ...JsxConfig.getFromContext(context),
349
349
  ...JsxConfig.getFromAnnotation(context)
350
350
  };
351
- const { jsx, jsxFactory, jsxFragmentFactory } = jsxConfig;
352
351
  if (jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev) return {};
353
352
  function handleJsxElement(node) {
354
353
  context.sourceCode.markVariableAsUsed(jsxFactory, node);
@@ -491,8 +490,7 @@ function create$49(context) {
491
490
  const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
492
491
  if (setState == null || hasThisState) return;
493
492
  if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
494
- const hasState = node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$2(prop, prop.key) && AST.getPropertyName(prop.key) === "state");
495
- if (!hasState) return;
493
+ if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$2(prop, prop.key) && AST.getPropertyName(prop.key) === "state")) return;
496
494
  context.report({
497
495
  messageId: "noAccessStateInSetstate",
498
496
  node
@@ -1070,8 +1068,7 @@ function create$34(context) {
1070
1068
  const { version: version$1 } = getSettingsFromContext(context);
1071
1069
  if (compare(version$1, "19.0.0", "<")) return {};
1072
1070
  return { JSXElement(node) {
1073
- const fullName = ER.getElementType(context, node);
1074
- const parts = fullName.split(".");
1071
+ const parts = ER.getElementType(context, node).split(".");
1075
1072
  const selfName = parts.pop();
1076
1073
  const contextFullName = parts.join(".");
1077
1074
  const contextSelfName = parts.pop();
@@ -1488,23 +1485,20 @@ function create$27(context) {
1488
1485
  type: AST_NODE_TYPES.LogicalExpression,
1489
1486
  operator: "&&"
1490
1487
  }, ({ left, right }) => {
1491
- const isLeftUnaryNot = left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!";
1492
- if (isLeftUnaryNot) return getReportDescriptor(right);
1488
+ if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!") return getReportDescriptor(right);
1493
1489
  const initialScope = context.sourceCode.getScope(left);
1494
- const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toStaticValue({
1490
+ if (left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toStaticValue({
1495
1491
  kind: "lazy",
1496
1492
  node: left,
1497
1493
  initialScope
1498
- }).value === "NaN";
1499
- if (isLeftNan) return {
1494
+ }).value === "NaN") return {
1500
1495
  messageId: "noLeakedConditionalRendering",
1501
1496
  node: left,
1502
1497
  data: { value: context.sourceCode.getText(left) }
1503
1498
  };
1504
1499
  const leftType = getConstrainedTypeAtLocation(services, left);
1505
1500
  const leftTypeVariants = inspectVariantTypes(unionTypeParts(leftType));
1506
- const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
1507
- if (isLeftValid) return getReportDescriptor(right);
1501
+ if (Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type))) return getReportDescriptor(right);
1508
1502
  return {
1509
1503
  messageId: "noLeakedConditionalRendering",
1510
1504
  node: left,
@@ -1513,8 +1507,7 @@ function create$27(context) {
1513
1507
  }).with({ type: AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
1514
1508
  return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
1515
1509
  }).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
1516
- const variable = VAR.findVariable(n.name, context.sourceCode.getScope(n));
1517
- const variableDefNode = variable?.defs.at(0)?.node;
1510
+ const variableDefNode = VAR.findVariable(n.name, context.sourceCode.getScope(n))?.defs.at(0)?.node;
1518
1511
  return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => unit);
1519
1512
  }).otherwise(() => unit);
1520
1513
  }
@@ -1604,13 +1597,12 @@ function create$25(context) {
1604
1597
  });
1605
1598
  continue;
1606
1599
  }
1607
- const hasDisplayNameAssignment = displayNameAssignments.some((node) => {
1600
+ if (!displayNameAssignments.some((node) => {
1608
1601
  const left = node.left;
1609
1602
  if (left.type !== AST_NODE_TYPES.MemberExpression) return false;
1610
1603
  const object = left.object;
1611
1604
  return ER.isInstanceIdEqual(context, id, object);
1612
- });
1613
- if (!hasDisplayNameAssignment) {
1605
+ })) {
1614
1606
  const semi = LanguagePreference.defaultLanguagePreference.semicolons === "always" ? ";" : "";
1615
1607
  context.report({
1616
1608
  messageId: "noMissingContextDisplayName",
@@ -1940,19 +1932,16 @@ function create$21(context) {
1940
1932
  "Program:exit"(program) {
1941
1933
  const functionComponents = [...collector.ctx.getAllComponents(program).values()];
1942
1934
  const classComponents = [...collectorLegacy.ctx.getAllComponents(program).values()];
1943
- for (const lazy of lazyComponentDeclarations) {
1944
- const significantParent = AST.findParentNode(lazy, (n) => {
1945
- if (AST.isJSX(n)) return true;
1946
- if (n.type === AST_NODE_TYPES.CallExpression) return ER.isReactHookCall(n) || ER.isCreateElementCall(context, n) || ER.isCreateContextCall(context, n);
1947
- if (AST.isFunction(n)) return functionComponents.some((c) => c.node === n);
1948
- if (AST.isClass(n)) return classComponents.some((c) => c.node === n);
1949
- return false;
1950
- });
1951
- if (significantParent != null) context.report({
1952
- messageId: "noNestedLazyComponentDeclarations",
1953
- node: lazy
1954
- });
1955
- }
1935
+ for (const lazy of lazyComponentDeclarations) if (AST.findParentNode(lazy, (n) => {
1936
+ if (AST.isJSX(n)) return true;
1937
+ if (n.type === AST_NODE_TYPES.CallExpression) return ER.isReactHookCall(n) || ER.isCreateElementCall(context, n) || ER.isCreateContextCall(context, n);
1938
+ if (AST.isFunction(n)) return functionComponents.some((c) => c.node === n);
1939
+ if (AST.isClass(n)) return classComponents.some((c) => c.node === n);
1940
+ return false;
1941
+ }) != null) context.report({
1942
+ messageId: "noNestedLazyComponentDeclarations",
1943
+ node: lazy
1944
+ });
1956
1945
  }
1957
1946
  };
1958
1947
  }
@@ -2344,8 +2333,7 @@ function create$11(context) {
2344
2333
  return {
2345
2334
  ...listeners,
2346
2335
  JSXOpeningElement(node) {
2347
- const fullName = ER.getElementType(context, node.parent);
2348
- const selfName = fullName.split(".").at(-1);
2336
+ const selfName = ER.getElementType(context, node.parent).split(".").at(-1);
2349
2337
  if (selfName == null) return;
2350
2338
  if (!isContextName(selfName, isReact18OrBelow)) return;
2351
2339
  const functionEntry = ctx.getCurrentEntry();
@@ -2679,11 +2667,10 @@ function create$8(context) {
2679
2667
  if (currentMethod === constructorEntries.at(-1)) return;
2680
2668
  if (!currentClass.body.body.includes(currentMethod)) return;
2681
2669
  if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
2682
- const hasState = node.id.properties.some((prop) => {
2670
+ if (!node.id.properties.some((prop) => {
2683
2671
  if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) return AST.getPropertyName(prop.key) === "state";
2684
2672
  return false;
2685
- });
2686
- if (!hasState) return;
2673
+ })) return;
2687
2674
  const defNode = stateDefs.get(currentClass)?.node;
2688
2675
  stateDefs.set(currentClass, {
2689
2676
  node: defNode,
@@ -2803,8 +2790,7 @@ function create$6(context) {
2803
2790
  if (!ER.isForwardRefCall(context, node)) return;
2804
2791
  const [component] = node.arguments;
2805
2792
  if (component == null || !AST.isFunction(component)) return;
2806
- const ref = component.params[1];
2807
- if (ref != null) return;
2793
+ if (component.params[1] != null) return;
2808
2794
  context.report({
2809
2795
  messageId: "noUselessForwardRef",
2810
2796
  node: node.callee
@@ -3036,8 +3022,7 @@ function create$3(context) {
3036
3022
  const importDeclarationText = context.sourceCode.getText(node.parent);
3037
3023
  const semi = importDeclarationText.endsWith(";") ? ";" : "";
3038
3024
  const quote = node.parent.source.raw.at(0) ?? "'";
3039
- const isTypeImport = node.parent.importKind === "type";
3040
- const importStringPrefix = `import${isTypeImport ? " type" : ""}`;
3025
+ const importStringPrefix = `import${node.parent.importKind === "type" ? " type" : ""}`;
3041
3026
  const importSourceQuoted = `${quote}${importSource}${quote}`;
3042
3027
  if (!hasOtherSpecifiers) return fixer.replaceText(node.parent, `${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`);
3043
3028
  const specifiers = importDeclarationText.slice(importDeclarationText.indexOf("{"), importDeclarationText.indexOf("}") + 1);
@@ -3120,8 +3105,7 @@ function create$1(context) {
3120
3105
  return { JSXAttribute(node) {
3121
3106
  const { value } = node;
3122
3107
  const propName = ER.getAttributeName(context, node);
3123
- const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
3124
- if (!hasValueTrue) return;
3108
+ if (!(value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true)) return;
3125
3109
  context.report({
3126
3110
  messageId: "preferShorthandBoolean",
3127
3111
  node: node.value ?? node,
@@ -3153,8 +3137,7 @@ var prefer_shorthand_fragment_default = createRule({
3153
3137
  function create(context) {
3154
3138
  return { JSXElement(node) {
3155
3139
  if (!ER.isFragmentElement(context, node)) return;
3156
- const hasAttributes = node.openingElement.attributes.length > 0;
3157
- if (hasAttributes) return;
3140
+ if (node.openingElement.attributes.length > 0) return;
3158
3141
  context.report({
3159
3142
  messageId: "preferShorthandFragment",
3160
3143
  node,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.53.1-beta.0",
3
+ "version": "1.53.1-beta.1",
4
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",
@@ -42,26 +42,26 @@
42
42
  "./package.json"
43
43
  ],
44
44
  "dependencies": {
45
- "@typescript-eslint/scope-manager": "^8.42.0",
46
- "@typescript-eslint/type-utils": "^8.42.0",
47
- "@typescript-eslint/types": "^8.42.0",
48
- "@typescript-eslint/utils": "^8.42.0",
45
+ "@typescript-eslint/scope-manager": "^8.43.0",
46
+ "@typescript-eslint/type-utils": "^8.43.0",
47
+ "@typescript-eslint/types": "^8.43.0",
48
+ "@typescript-eslint/utils": "^8.43.0",
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.8.0",
53
- "@eslint-react/ast": "1.53.1-beta.0",
54
- "@eslint-react/core": "1.53.1-beta.0",
55
- "@eslint-react/kit": "1.53.1-beta.0",
56
- "@eslint-react/var": "1.53.1-beta.0",
57
- "@eslint-react/shared": "1.53.1-beta.0",
58
- "@eslint-react/eff": "1.53.1-beta.0"
53
+ "@eslint-react/ast": "1.53.1-beta.1",
54
+ "@eslint-react/core": "1.53.1-beta.1",
55
+ "@eslint-react/kit": "1.53.1-beta.1",
56
+ "@eslint-react/eff": "1.53.1-beta.1",
57
+ "@eslint-react/shared": "1.53.1-beta.1",
58
+ "@eslint-react/var": "1.53.1-beta.1"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/react": "^19.1.12",
62
62
  "@types/react-dom": "^19.1.9",
63
63
  "ts-api-utils": "^2.1.0",
64
- "tsdown": "^0.14.2",
64
+ "tsdown": "^0.15.0",
65
65
  "@local/configs": "0.0.0"
66
66
  },
67
67
  "peerDependencies": {