eslint-plugin-react-x 1.53.1-next.0 → 1.53.1-next.2

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