eslint-plugin-react-x 5.28.7 → 5.30.0-beta.0

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.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { DEFAULT_ESLINT_REACT_SETTINGS, getSettingsFromContext, toRegExp } from
2
2
  import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
3
3
  import { Check, Compare, Extract, Traverse } from "@eslint-react/ast";
4
4
  import * as core from "@eslint-react/core";
5
- import { getConstrainedTypeAtLocation, merge, report } from "@eslint-react/eslint";
5
+ import { getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
6
6
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
7
7
  import { P, isMatching, match } from "ts-pattern";
8
8
  import { isAssignmentTargetEqual, isInitializedFromReact, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin } from "@eslint-react/var";
@@ -14,7 +14,7 @@ import { unionConstituents } from "ts-api-utils";
14
14
  import "typescript";
15
15
  import { simpleTraverse } from "@typescript-eslint/typescript-estree";
16
16
  import { delimiterCase, snakeCase, toLowerCase } from "string-ts";
17
- //#region \0rolldown/runtime.js
17
+ // \0rolldown/runtime.js
18
18
  var __defProp = Object.defineProperty;
19
19
  var __exportAll = (all, no_symbols) => {
20
20
  let target = {};
@@ -25,8 +25,7 @@ var __exportAll = (all, no_symbols) => {
25
25
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
26
26
  return target;
27
27
  };
28
- //#endregion
29
- //#region src/configs/disable-conflict-eslint-plugin-react.ts
28
+ // src/configs/disable-conflict-eslint-plugin-react.ts
30
29
  var disable_conflict_eslint_plugin_react_exports = /* @__PURE__ */ __exportAll({
31
30
  name: () => name$10,
32
31
  rules: () => rules$9
@@ -75,8 +74,7 @@ const conflictingRules$1 = [
75
74
  ];
76
75
  const name$10 = "react-x/disable-conflict-eslint-plugin-react";
77
76
  const rules$9 = Object.fromEntries(conflictingRules$1.map((key) => [key, "off"]));
78
- //#endregion
79
- //#region src/configs/disable-conflict-eslint-plugin-react-hooks.ts
77
+ // src/configs/disable-conflict-eslint-plugin-react-hooks.ts
80
78
  var disable_conflict_eslint_plugin_react_hooks_exports = /* @__PURE__ */ __exportAll({
81
79
  name: () => name$9,
82
80
  rules: () => rules$8
@@ -97,8 +95,7 @@ const conflictingRules = [
97
95
  ];
98
96
  const name$9 = "react-x/disable-conflict-eslint-plugin-react-hooks";
99
97
  const rules$8 = Object.fromEntries(conflictingRules.map((key) => [key, "off"]));
100
- //#endregion
101
- //#region src/configs/disable-experimental.ts
98
+ // src/configs/disable-experimental.ts
102
99
  var disable_experimental_exports = /* @__PURE__ */ __exportAll({
103
100
  name: () => name$8,
104
101
  rules: () => rules$7
@@ -118,8 +115,7 @@ const rules$7 = {
118
115
  "react-x/set-state-in-render": "off",
119
116
  "react-x/static-components": "off"
120
117
  };
121
- //#endregion
122
- //#region src/configs/disable-type-checked.ts
118
+ // src/configs/disable-type-checked.ts
123
119
  var disable_type_checked_exports = /* @__PURE__ */ __exportAll({
124
120
  name: () => name$7,
125
121
  rules: () => rules$6
@@ -132,12 +128,10 @@ const rules$6 = {
132
128
  "react-x/no-leaked-conditional-rendering": "off",
133
129
  "react-x/no-unused-props": "off"
134
130
  };
135
- //#endregion
136
- //#region package.json
131
+ // package.json
137
132
  var name$6 = "eslint-plugin-react-x";
138
- var version = "5.28.7";
139
- //#endregion
140
- //#region src/utils/create-rule.ts
133
+ var version = "5.30.0-beta.0";
134
+ // src/utils/create-rule.ts
141
135
  function getDocsUrl(ruleName) {
142
136
  return `https://eslint-react.xyz/docs/rules/${ruleName}`;
143
137
  }
@@ -197,8 +191,7 @@ function create$50(context) {
197
191
  }
198
192
  });
199
193
  }
200
- //#endregion
201
- //#region src/rules/exhaustive-deps/exhaustive-deps.ts
194
+ // src/rules/exhaustive-deps/exhaustive-deps.ts
202
195
  const rule$1 = {
203
196
  meta: {
204
197
  type: "suggestion",
@@ -1068,8 +1061,7 @@ function isUseEffectEventIdentifier$1(node) {
1068
1061
  function getUnknownDependenciesMessage(reactiveHookName) {
1069
1062
  return `React Hook ${reactiveHookName} received a function whose dependencies are unknown. Pass an inline function instead.`;
1070
1063
  }
1071
- //#endregion
1072
- //#region src/rules/globals/helpers.ts
1064
+ // src/rules/globals/helpers.ts
1073
1065
  const MUTATING_ARRAY_METHODS = /* @__PURE__ */ new Set([
1074
1066
  "copyWithin",
1075
1067
  "fill",
@@ -1081,8 +1073,7 @@ const MUTATING_ARRAY_METHODS = /* @__PURE__ */ new Set([
1081
1073
  "splice",
1082
1074
  "unshift"
1083
1075
  ]);
1084
- //#endregion
1085
- //#region src/rules/globals/collect.ts
1076
+ // src/rules/globals/collect.ts
1086
1077
  function createFactCollector$6() {
1087
1078
  const facts = {
1088
1079
  callEdges: [],
@@ -1147,8 +1138,7 @@ function createFactCollector$6() {
1147
1138
  }
1148
1139
  };
1149
1140
  }
1150
- //#endregion
1151
- //#region src/rules/globals/origins.ts
1141
+ // src/rules/globals/origins.ts
1152
1142
  function isGlobalVariable(context, node) {
1153
1143
  const variable = findVariable(context.sourceCode.getScope(node), node);
1154
1144
  if (variable == null || variable.defs.length === 0) return true;
@@ -1179,8 +1169,7 @@ function resolveToFunction(context, node, seen = /* @__PURE__ */ new Set()) {
1179
1169
  if (resolved == null) return null;
1180
1170
  return resolveToFunction(context, resolved, seen);
1181
1171
  }
1182
- //#endregion
1183
- //#region src/rules/globals/effects.ts
1172
+ // src/rules/globals/effects.ts
1184
1173
  function inferGlobalMutations(context, facts) {
1185
1174
  const directEffects = /* @__PURE__ */ new Map();
1186
1175
  function pushEffect(enclosingFunction, effect) {
@@ -1202,7 +1191,7 @@ function inferGlobalMutations(context, facts) {
1202
1191
  if (resolveGlobalOrigin(context, write.target.object) == null) continue;
1203
1192
  pushEffect(write.enclosingFunction, {
1204
1193
  kind: "property",
1205
- name: context.sourceCode.getText(write.target),
1194
+ name: getText(context, write.target),
1206
1195
  method: null,
1207
1196
  node: write.node
1208
1197
  });
@@ -1282,8 +1271,7 @@ function create$49(context) {
1282
1271
  }
1283
1272
  } });
1284
1273
  }
1285
- //#endregion
1286
- //#region src/rules/immutability/helpers.ts
1274
+ // src/rules/immutability/helpers.ts
1287
1275
  const KNOWN_MUTATING_METHODS = /* @__PURE__ */ new Set([
1288
1276
  "add",
1289
1277
  "clear",
@@ -1313,16 +1301,15 @@ function isNodeWithin(node, ancestor) {
1313
1301
  }
1314
1302
  return false;
1315
1303
  }
1316
- function isRefLikeName$1(name) {
1304
+ function isRefLikeName$2(name) {
1317
1305
  return name === "ref" || name.endsWith("Ref");
1318
1306
  }
1319
1307
  function hasRefLikeNameInChain(node) {
1320
1308
  const expr = Extract.unwrap(node);
1321
1309
  if (!Check.isExpression(expr)) return false;
1322
- return Extract.getMemberChain(expr).some((member) => Check.isIdentifier(member) && isRefLikeName$1(member.name));
1310
+ return Extract.getMemberChain(expr).some((member) => Check.isIdentifier(member) && isRefLikeName$2(member.name));
1323
1311
  }
1324
- //#endregion
1325
- //#region src/rules/immutability/collect.ts
1312
+ // src/rules/immutability/collect.ts
1326
1313
  function createFactCollector$5() {
1327
1314
  const facts = {
1328
1315
  mutations: [],
@@ -1409,8 +1396,7 @@ function createFactCollector$5() {
1409
1396
  }
1410
1397
  };
1411
1398
  }
1412
- //#endregion
1413
- //#region src/rules/immutability/origins.ts
1399
+ // src/rules/immutability/origins.ts
1414
1400
  function resolveVariableOrigin(context, variable, mode = "alias", seen = /* @__PURE__ */ new Set()) {
1415
1401
  if (seen.has(variable)) return variable;
1416
1402
  seen.add(variable);
@@ -1522,13 +1508,12 @@ function classifyFrozenOrigin(context, variable, components, mode = "alias", see
1522
1508
  default: return null;
1523
1509
  }
1524
1510
  }
1525
- //#endregion
1526
- //#region src/rules/immutability/effects.ts
1511
+ // src/rules/immutability/effects.ts
1527
1512
  function isGlobalOrModuleVariable(variable) {
1528
1513
  return variable.defs.length === 0 || variable.scope.type === ScopeType.global || variable.scope.type === ScopeType.module;
1529
1514
  }
1530
1515
  function isRefMutation(context, mutation) {
1531
- if (Check.isIdentifier(mutation.target)) return isRefLikeName$1(mutation.target.name);
1516
+ if (Check.isIdentifier(mutation.target)) return isRefLikeName$2(mutation.target.name);
1532
1517
  return isRefLikeChain(context, mutation.target);
1533
1518
  }
1534
1519
  function isKnownNonMutatingMethodCall(context, node) {
@@ -1708,8 +1693,7 @@ function create$47(context) {
1708
1693
  });
1709
1694
  } };
1710
1695
  }
1711
- //#endregion
1712
- //#region src/rules/no-array-index-key/lib.ts
1696
+ // src/rules/no-array-index-key/lib.ts
1713
1697
  const KNOWN_COERCION_FUNCTIONS = /* @__PURE__ */ new Set(["Number", "String"]);
1714
1698
  const KNOWN_INDEX_PARAM_POSITIONS = /* @__PURE__ */ new Map([
1715
1699
  ["every", 1],
@@ -1910,8 +1894,7 @@ function create$41(context) {
1910
1894
  });
1911
1895
  } };
1912
1896
  }
1913
- //#endregion
1914
- //#region ../../.pkgs/eff/dist/index.js
1897
+ // ../../.pkgs/eff/dist/index.js
1915
1898
  const pipeArguments = (self, args) => {
1916
1899
  switch (args.length) {
1917
1900
  case 0: return self;
@@ -2003,6 +1986,14 @@ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
2003
1986
  }
2004
1987
  }
2005
1988
  cast(absurd);
1989
+ function memoize(f) {
1990
+ const objects = /* @__PURE__ */ new WeakMap();
1991
+ const primitives = /* @__PURE__ */ new Map();
1992
+ return (a) => {
1993
+ if (isObjectKeyword(a)) return getOrInsertComputed(objects, a, () => f(a));
1994
+ return getOrInsertComputed(primitives, a, () => f(a));
1995
+ };
1996
+ }
2006
1997
  function not(predicate) {
2007
1998
  return (data) => !predicate(data);
2008
1999
  }
@@ -2403,18 +2394,17 @@ function buildFix(context, node) {
2403
2394
  };
2404
2395
  }
2405
2396
  function buildFixForComponentProps(context, fixer, node, typeArguments) {
2406
- const getText = (node) => context.sourceCode.getText(node);
2407
2397
  const [arg0, arg1] = node.params;
2408
2398
  const [typeArg0, typeArg1] = typeArguments;
2409
2399
  if (arg0 == null) {
2410
2400
  const openParen = context.sourceCode.getFirstToken(node, { filter: (t) => t.value === "(" });
2411
2401
  if (openParen == null) return [];
2412
2402
  if (typeArg0 == null || typeArg1 == null) return [];
2413
- const typeArg0Text = getText(typeArg0);
2414
- const typeArg1Text = getText(typeArg1);
2403
+ const typeArg0Text = getText(context, typeArg0);
2404
+ const typeArg1Text = getText(context, typeArg1);
2415
2405
  return [fixer.insertTextAfter(openParen, `{ ref }: ${typeArg1Text} & { ref?: React.RefObject<${typeArg0Text} | null> }`)];
2416
2406
  }
2417
- const fixedArg0Text = match(arg0).with({ type: AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() => null);
2407
+ const fixedArg0Text = match(arg0).with({ type: AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText(context)).join(", ")).otherwise(() => null);
2418
2408
  const fixedArg1Text = match(arg1).with(P.nullish, () => "ref").with({
2419
2409
  type: AST_NODE_TYPES.Identifier,
2420
2410
  name: "ref"
@@ -2429,8 +2419,8 @@ function buildFixForComponentProps(context, fixer, node, typeArguments) {
2429
2419
  fixedArg0Text,
2430
2420
  "}"
2431
2421
  ].join(" ")), ...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]];
2432
- const typeArg0Text = getText(typeArg0);
2433
- const typeArg1Text = getText(typeArg1);
2422
+ const typeArg0Text = getText(context, typeArg0);
2423
+ const typeArg1Text = getText(context, typeArg1);
2434
2424
  return [fixer.replaceText(arg0, [
2435
2425
  "{",
2436
2426
  fixedArg1Text + ",",
@@ -2444,8 +2434,7 @@ function buildFixForComponentProps(context, fixer, node, typeArguments) {
2444
2434
  "}"
2445
2435
  ].join(" ")), ...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]];
2446
2436
  }
2447
- //#endregion
2448
- //#region src/utils/create-implicit-prop-listener.ts
2437
+ // src/utils/create-implicit-prop-listener.ts
2449
2438
  function createImplicitPropListener(context, options) {
2450
2439
  const { name, isAllowedProp, isAllowedType, onImplicitProp } = options;
2451
2440
  const services = ESLintUtils.getParserServices(context, false);
@@ -2463,8 +2452,7 @@ function createImplicitPropListener(context, options) {
2463
2452
  }
2464
2453
  } };
2465
2454
  }
2466
- //#endregion
2467
- //#region src/rules/no-implicit-children/no-implicit-children.ts
2455
+ // src/rules/no-implicit-children/no-implicit-children.ts
2468
2456
  const RULE_NAME$30 = "no-implicit-children";
2469
2457
  const RE_REACT_CHILDREN_TYPE = /react\.(reactnode|reactelement|reactportal)$/i;
2470
2458
  var no_implicit_children_default = createRule({
@@ -2513,8 +2501,7 @@ function create$29(context) {
2513
2501
  }
2514
2502
  });
2515
2503
  }
2516
- //#endregion
2517
- //#region src/rules/no-implicit-ref/no-implicit-ref.ts
2504
+ // src/rules/no-implicit-ref/no-implicit-ref.ts
2518
2505
  const RULE_NAME$28 = "no-implicit-ref";
2519
2506
  const RE_REACT_REF_TYPE = /react\.(ref|legacyref|refcallback|refobject)$/i;
2520
2507
  var no_implicit_ref_default = createRule({
@@ -2579,7 +2566,7 @@ function create$27(context) {
2579
2566
  if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!") return visit(right, seen);
2580
2567
  const initialScope = context.sourceCode.getScope(left);
2581
2568
  if (Check.isIdentifier(left, "NaN") || getStaticValue(left, initialScope)?.value === "NaN") return {
2582
- data: { value: context.sourceCode.getText(left) },
2569
+ data: { value: getText(context, left) },
2583
2570
  messageId: "default",
2584
2571
  node: left
2585
2572
  };
@@ -2587,7 +2574,7 @@ function create$27(context) {
2587
2574
  const leftTypeVariants = core.getTypeVariants(unionConstituents(leftType));
2588
2575
  if (Array.from(leftTypeVariants.values()).every((t) => allowedTypeVariants.some((a) => a === t))) return visit(right, seen);
2589
2576
  return {
2590
- data: { value: context.sourceCode.getText(left) },
2577
+ data: { value: getText(context, left) },
2591
2578
  messageId: "default",
2592
2579
  node: left
2593
2580
  };
@@ -2691,22 +2678,21 @@ function create$25(context) {
2691
2678
  }
2692
2679
  };
2693
2680
  }
2694
- //#endregion
2695
- //#region src/rules/no-missing-key/lib.ts
2681
+ // src/rules/no-missing-key/lib.ts
2696
2682
  const KNOWN_CALLBACK_POSITIONS = /* @__PURE__ */ new Map([
2697
2683
  ["flatMap", 0],
2698
2684
  ["from", 1],
2699
2685
  ["map", 0]
2700
2686
  ]);
2701
- function getNestedReturnStatements$1(node) {
2702
- const statements = [];
2687
+ function getReturnStatements$1(node) {
2688
+ const stmts = [];
2703
2689
  const boundary = Check.isFunction(node) ? node : Traverse.findParent(node, Check.isFunction);
2704
2690
  simpleTraverse(node, { enter(node) {
2705
2691
  if (node.type !== AST_NODE_TYPES.ReturnStatement) return;
2706
2692
  if (Traverse.hasParent(node, Check.isFunction, (n) => n === boundary)) return;
2707
- statements.push(node);
2693
+ stmts.push(node);
2708
2694
  } });
2709
- return statements;
2695
+ return stmts;
2710
2696
  }
2711
2697
  var no_missing_key_default = createRule({
2712
2698
  meta: {
@@ -2756,7 +2742,7 @@ function create$24(context) {
2756
2742
  }
2757
2743
  function visitIteratorCallback(node) {
2758
2744
  if (node.body.type !== AST_NODE_TYPES.BlockStatement) return visitItemExpression(node.body);
2759
- return getNestedReturnStatements$1(node.body).flatMap((stmt) => stmt.argument == null ? [] : visitItemExpression(stmt.argument));
2745
+ return getReturnStatements$1(node.body).flatMap((stmt) => stmt.argument == null ? [] : visitItemExpression(stmt.argument));
2760
2746
  }
2761
2747
  return {
2762
2748
  ArrayExpression(node) {
@@ -2781,8 +2767,7 @@ function create$24(context) {
2781
2767
  }
2782
2768
  };
2783
2769
  }
2784
- //#endregion
2785
- //#region src/rules/no-misused-capture-owner-stack/lib.ts
2770
+ // src/rules/no-misused-capture-owner-stack/lib.ts
2786
2771
  function isProcessEnvNodeEnv(context, node) {
2787
2772
  return node != null && core.isAPI("process.env.NODE_ENV")(context, node);
2788
2773
  }
@@ -2839,8 +2824,7 @@ function create$23(context) {
2839
2824
  }
2840
2825
  };
2841
2826
  }
2842
- //#endregion
2843
- //#region src/rules/no-nested-component-definitions/lib.ts
2827
+ // src/rules/no-nested-component-definitions/lib.ts
2844
2828
  const isConnectCall = core.isAPICall("connect");
2845
2829
  const isCreateFragmentContainerCall = core.isAPICall("createFragmentContainer");
2846
2830
  const isCreatePaginationContainerCall = core.isAPICall("createPaginationContainer");
@@ -3086,8 +3070,7 @@ function create$18(context) {
3086
3070
  });
3087
3071
  } };
3088
3072
  }
3089
- //#endregion
3090
- //#region src/rules/no-unnecessary-use-prefix/lib.ts
3073
+ // src/rules/no-unnecessary-use-prefix/lib.ts
3091
3074
  const WELL_KNOWN_HOOKS = ["use", "useMDXComponents"];
3092
3075
  function containsUseComments(context, node) {
3093
3076
  return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
@@ -3201,8 +3184,7 @@ function create$14(context) {
3201
3184
  }
3202
3185
  } });
3203
3186
  }
3204
- //#endregion
3205
- //#region src/rules/no-unstable-context-value/lib.ts
3187
+ // src/rules/no-unstable-context-value/lib.ts
3206
3188
  function isContextName(name, isReact18OrBelow) {
3207
3189
  if (name === "Provider") return true;
3208
3190
  if (!isReact18OrBelow) return name.endsWith("Context") || name.endsWith("CONTEXT");
@@ -3246,7 +3228,7 @@ function create$13(context) {
3246
3228
  const valueExpression = attribute.value.expression;
3247
3229
  const construction = resolveObjectType(context, valueExpression);
3248
3230
  if (construction == null) return;
3249
- if (core.isHookCall(construction.node)) return;
3231
+ if (construction.node.type === AST_NODE_TYPES.CallExpression && core.isHookCall(construction.node)) return;
3250
3232
  getOrInsertComputed(constructions, enclosingFunction, () => []).push(construction);
3251
3233
  },
3252
3234
  "Program:exit"(program) {
@@ -3268,8 +3250,7 @@ function create$13(context) {
3268
3250
  }
3269
3251
  });
3270
3252
  }
3271
- //#endregion
3272
- //#region src/rules/no-unstable-default-props/lib.ts
3253
+ // src/rules/no-unstable-default-props/lib.ts
3273
3254
  const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
3274
3255
  "VariableDeclarator",
3275
3256
  "[id.type='ObjectPattern']",
@@ -3283,8 +3264,7 @@ function getHumanReadableKind(node) {
3283
3264
  }
3284
3265
  return toLowerCase(delimiterCase(node.type, " "));
3285
3266
  }
3286
- //#endregion
3287
- //#region src/rules/no-unstable-default-props/no-unstable-default-props.ts
3267
+ // src/rules/no-unstable-default-props/no-unstable-default-props.ts
3288
3268
  const RULE_NAME$12 = "no-unstable-default-props";
3289
3269
  const defaultOptions$1 = [{ safeDefaultProps: [] }];
3290
3270
  const schema$1 = [{
@@ -3334,7 +3314,7 @@ function create$12(context, [options]) {
3334
3314
  const { right } = value;
3335
3315
  const construction = resolveObjectType(context, value);
3336
3316
  if (construction == null) continue;
3337
- if (core.isHookCall(construction.node)) continue;
3317
+ if (construction.node.type === AST_NODE_TYPES.CallExpression && core.isHookCall(construction.node)) continue;
3338
3318
  if (safePatterns.length > 0) {
3339
3319
  const getName = (n) => Check.isIdentifier(n) ? n.name : null;
3340
3320
  const name = match(right).with({ type: AST_NODE_TYPES.NewExpression }, (n) => getName(n.callee)).with({ type: AST_NODE_TYPES.CallExpression }, (n) => {
@@ -3352,8 +3332,7 @@ function create$12(context, [options]) {
3352
3332
  }
3353
3333
  });
3354
3334
  }
3355
- //#endregion
3356
- //#region src/rules/no-unused-class-component-members/lib.ts
3335
+ // src/rules/no-unused-class-component-members/lib.ts
3357
3336
  const LIFECYCLE_METHODS = /* @__PURE__ */ new Set([
3358
3337
  "componentDidCatch",
3359
3338
  "componentDidMount",
@@ -3425,7 +3404,7 @@ function create$11(context) {
3425
3404
  if (exported && isPublicMethod(def)) continue;
3426
3405
  context.report({
3427
3406
  data: {
3428
- className: id != null ? context.sourceCode.getText(id) : "Component",
3407
+ className: id != null ? getText(context, id) : "Component",
3429
3408
  methodName
3430
3409
  },
3431
3410
  messageId: "default",
@@ -3467,8 +3446,7 @@ function create$11(context) {
3467
3446
  }
3468
3447
  };
3469
3448
  }
3470
- //#endregion
3471
- //#region src/rules/no-unused-props/lib.ts
3449
+ // src/rules/no-unused-props/lib.ts
3472
3450
  function collectUsedPropKeysOfParameter(context, usedPropKeys, parameter) {
3473
3451
  switch (parameter.type) {
3474
3452
  case AST_NODE_TYPES.Identifier: return collectUsedPropKeysOfIdentifier(context, usedPropKeys, parameter);
@@ -3663,8 +3641,7 @@ function create$8(context) {
3663
3641
  });
3664
3642
  } };
3665
3643
  }
3666
- //#endregion
3667
- //#region src/rules/purity/lib.ts
3644
+ // src/rules/purity/lib.ts
3668
3645
  const IMPURE_FUNCS = /* @__PURE__ */ new Map([
3669
3646
  ["Atomics", /* @__PURE__ */ new Set([
3670
3647
  "add",
@@ -4061,6 +4038,7 @@ function getDestructuredPropertyName(pattern, name) {
4061
4038
  return null;
4062
4039
  }
4063
4040
  function resolveBuiltinMember(context, node, seen = /* @__PURE__ */ new Set()) {
4041
+ for (let current = node; current.type === AST_NODE_TYPES.MemberExpression; current = Extract.unwrap(current.object)) if (current.computed) return null;
4064
4042
  const chain = Extract.getMemberChain(node);
4065
4043
  const rootId = chain.at(0);
4066
4044
  if (rootId == null || !Check.isIdentifier(rootId)) return null;
@@ -4071,7 +4049,7 @@ function resolveBuiltinMember(context, node, seen = /* @__PURE__ */ new Set()) {
4071
4049
  let object = resolved.property ?? resolved.object;
4072
4050
  const names = segments.map((segment) => segment.name);
4073
4051
  if (isCatalogObject(object)) for (const name of names.slice(0, -1)) {
4074
- if (!isCatalogObject(name)) break;
4052
+ if (!isCatalogObject(name)) return null;
4075
4053
  object = name;
4076
4054
  }
4077
4055
  return {
@@ -4183,7 +4161,7 @@ function create$7(context) {
4183
4161
  if (!funcs.some((f) => f.node === func)) continue;
4184
4162
  if (!isClientModule && func.async && comps.some((comp) => comp.node === func)) continue;
4185
4163
  context.report({
4186
- data: { name: context.sourceCode.getText(node) },
4164
+ data: { name: getText(context, node) },
4187
4165
  messageId: "default",
4188
4166
  node
4189
4167
  });
@@ -4191,8 +4169,7 @@ function create$7(context) {
4191
4169
  }
4192
4170
  });
4193
4171
  }
4194
- //#endregion
4195
- //#region src/rules/refs/helpers.ts
4172
+ // src/rules/refs/helpers.ts
4196
4173
  const SYNC_ARRAY_CALLBACKS = /* @__PURE__ */ new Set([
4197
4174
  "every",
4198
4175
  "filter",
@@ -4211,7 +4188,7 @@ const SYNC_ARRAY_CALLBACKS = /* @__PURE__ */ new Set([
4211
4188
  function isFunctionExpressionLike(node) {
4212
4189
  return node.type === AST_NODE_TYPES.FunctionExpression || node.type === AST_NODE_TYPES.ArrowFunctionExpression;
4213
4190
  }
4214
- function isRefLikeName(name) {
4191
+ function isRefLikeName$1(name) {
4215
4192
  return name === "ref" || name.endsWith("Ref");
4216
4193
  }
4217
4194
  function getSynchronousCallbackIndexes(node) {
@@ -4356,8 +4333,7 @@ function isAfterTerminatingNonNullGuard(node, getNullBranch) {
4356
4333
  }
4357
4334
  return false;
4358
4335
  }
4359
- //#endregion
4360
- //#region src/rules/refs/collect.ts
4336
+ // src/rules/refs/collect.ts
4361
4337
  function createFactCollector$4() {
4362
4338
  const facts = {
4363
4339
  bindings: [],
@@ -4454,8 +4430,7 @@ function createFactCollector$4() {
4454
4430
  }
4455
4431
  };
4456
4432
  }
4457
- //#endregion
4458
- //#region src/rules/refs/effects.ts
4433
+ // src/rules/refs/effects.ts
4459
4434
  function findBoundary(node, boundaries) {
4460
4435
  return Traverse.findParent(node, (candidate) => Check.isFunction(candidate) && boundaries.has(candidate));
4461
4436
  }
@@ -4578,8 +4553,7 @@ function inferRefPassViolations(passSites, boundaries, reachability, resolver) {
4578
4553
  }
4579
4554
  return violations;
4580
4555
  }
4581
- //#endregion
4582
- //#region src/rules/refs/origins.ts
4556
+ // src/rules/refs/origins.ts
4583
4557
  function createBindingResolver(context, facts) {
4584
4558
  const { additionalRefHooks } = getSettingsFromContext(context);
4585
4559
  const bindings = /* @__PURE__ */ new Map();
@@ -4603,7 +4577,7 @@ function createBindingResolver(context, facts) {
4603
4577
  };
4604
4578
  if (value.type === AST_NODE_TYPES.CallExpression && (core.isUseRefLikeCall(value, additionalRefHooks) || core.isCreateRefCall(context, value))) return { kind: "ref" };
4605
4579
  if (value.type === AST_NODE_TYPES.MemberExpression && Check.isIdentifier(value.property)) {
4606
- if (isRefLikeName(value.property.name)) return { kind: "ref" };
4580
+ if (isRefLikeName$1(value.property.name)) return { kind: "ref" };
4607
4581
  }
4608
4582
  return { kind: "unknown" };
4609
4583
  }
@@ -4650,7 +4624,7 @@ function createBindingResolver(context, facts) {
4650
4624
  function resolveRef(variable, position, seen = /* @__PURE__ */ new Set()) {
4651
4625
  if (seen.has(variable)) return null;
4652
4626
  seen.add(variable);
4653
- if (jsxRefs.has(variable) || isRefLikeName(variable.name)) return variable;
4627
+ if (jsxRefs.has(variable) || isRefLikeName$1(variable.name)) return variable;
4654
4628
  const event = getLatestValue(bindings.get(variable), position);
4655
4629
  if (event != null) switch (event.value.kind) {
4656
4630
  case "ref": return variable;
@@ -4707,7 +4681,7 @@ function createBindingResolver(context, facts) {
4707
4681
  return identity == null ? null : { identity };
4708
4682
  }
4709
4683
  if (object.type === AST_NODE_TYPES.MemberExpression && Check.isIdentifier(object.property)) {
4710
- if (isRefLikeName(object.property.name)) return { identity: null };
4684
+ if (isRefLikeName$1(object.property.name)) return { identity: null };
4711
4685
  }
4712
4686
  return null;
4713
4687
  }
@@ -4771,8 +4745,7 @@ function create$6(context) {
4771
4745
  });
4772
4746
  } });
4773
4747
  }
4774
- //#endregion
4775
- //#region src/rules/rules-of-hooks/lib.ts
4748
+ // src/rules/rules-of-hooks/lib.ts
4776
4749
  function assert(cond, message) {
4777
4750
  if (!cond) throw new Error(message ?? "Assertion violated.");
4778
4751
  }
@@ -6045,8 +6018,7 @@ var CodePathAnalyzer = class {
6045
6018
  if (fromSegment.reachable && toSegment.reachable) this.emitter.emit("onCodePathSegmentLoop", fromSegment, toSegment, this.currentNode);
6046
6019
  }
6047
6020
  };
6048
- //#endregion
6049
- //#region src/rules/rules-of-hooks/rules-of-hooks.ts
6021
+ // src/rules/rules-of-hooks/rules-of-hooks.ts
6050
6022
  function isHookName(s) {
6051
6023
  return s === "use" || /^use[A-Z0-9]/.test(s);
6052
6024
  }
@@ -6368,8 +6340,51 @@ function getFunctionName(node) {
6368
6340
  function last(array) {
6369
6341
  return array[array.length - 1];
6370
6342
  }
6371
- //#endregion
6372
- //#region src/rules/set-state-in-effect/helpers.ts
6343
+ // src/rules/set-state-in-effect/collect.ts
6344
+ function createFactCollector$3(additionalStateHooks, additionalEffectHooks) {
6345
+ const facts = {
6346
+ calls: [],
6347
+ effectRoots: [],
6348
+ jsxRefExprs: []
6349
+ };
6350
+ const functionEntries = [];
6351
+ const isUseStateCall = (node) => node.type === AST_NODE_TYPES.CallExpression && core.isUseStateLikeCall(node, additionalStateHooks);
6352
+ const isUseEffectCall = (node) => node.type === AST_NODE_TYPES.CallExpression && core.isUseEffectLikeCall(node, additionalEffectHooks);
6353
+ return {
6354
+ facts,
6355
+ visitor: {
6356
+ ":function"(node) {
6357
+ functionEntries.push(node);
6358
+ },
6359
+ ":function:exit"() {
6360
+ functionEntries.pop();
6361
+ },
6362
+ JSXAttribute(node) {
6363
+ if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.name.name !== "ref") return;
6364
+ if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
6365
+ facts.jsxRefExprs.push(node.value.expression);
6366
+ },
6367
+ CallExpression(node) {
6368
+ if (isUseStateCall(node)) return;
6369
+ if (isUseEffectCall(node)) {
6370
+ const setup = node.arguments.at(0);
6371
+ if (setup != null) facts.effectRoots.push({
6372
+ node,
6373
+ setup
6374
+ });
6375
+ return;
6376
+ }
6377
+ const enclosingFunction = functionEntries.at(-1);
6378
+ if (enclosingFunction == null) return;
6379
+ facts.calls.push({
6380
+ enclosingFunction,
6381
+ node
6382
+ });
6383
+ }
6384
+ }
6385
+ };
6386
+ }
6387
+ // src/rules/set-state-in-effect/helpers.ts
6373
6388
  const IDENTIFIER_VISITOR_KEYS = {
6374
6389
  [AST_NODE_TYPES.ArrayExpression]: ["elements"],
6375
6390
  [AST_NODE_TYPES.ArrayPattern]: ["elements"],
@@ -6406,7 +6421,7 @@ const IDENTIFIER_VISITOR_KEYS = {
6406
6421
  [AST_NODE_TYPES.UpdateExpression]: ["argument"],
6407
6422
  [AST_NODE_TYPES.YieldExpression]: ["argument"]
6408
6423
  };
6409
- function getNestedIdentifiers(node) {
6424
+ function getIdentifiers(node) {
6410
6425
  const identifiers = [];
6411
6426
  simpleTraverse(node, {
6412
6427
  enter(node, parent) {
@@ -6418,263 +6433,85 @@ function getNestedIdentifiers(node) {
6418
6433
  });
6419
6434
  return identifiers;
6420
6435
  }
6421
- function isHookDecl(node) {
6422
- if (node.type !== AST_NODE_TYPES.VariableDeclarator) return false;
6423
- if (!Check.isIdentifier(node.id)) return false;
6424
- const init = node.init;
6425
- if (init == null) return false;
6426
- if (init.type !== AST_NODE_TYPES.CallExpression) return false;
6427
- const name = Extract.getCalleeName(init);
6428
- return name != null && core.isHookName(name);
6429
- }
6430
- function isThenCall(node) {
6431
- return Extract.unwrap(node.callee).type === AST_NODE_TYPES.MemberExpression && Extract.getCalleeName(node) === "then";
6432
- }
6433
6436
  function isTerminatingStatement(node) {
6434
6437
  if (node.type === AST_NODE_TYPES.ReturnStatement || node.type === AST_NODE_TYPES.ThrowStatement) return true;
6435
6438
  if (node.type === AST_NODE_TYPES.BlockStatement) return node.body.some(isTerminatingStatement);
6436
6439
  return false;
6437
6440
  }
6438
- function getCallName(node, getText) {
6439
- if (node.type === AST_NODE_TYPES.CallExpression) return Extract.getFullyQualifiedName(node.callee, getText);
6440
- return Extract.getFullyQualifiedName(node, getText);
6441
- }
6442
- function getSetStateCallExpression(node) {
6443
- return Check.isIdentifier(node) && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node ? node.parent : node;
6444
- }
6445
- //#endregion
6446
- //#region src/rules/set-state-in-effect/collect.ts
6447
- function createFactCollector$3(additionalStateHooks, additionalEffectHooks) {
6448
- const facts = {
6449
- calls: [],
6450
- setStateReferences: [],
6451
- setupIdentifiers: []
6452
- };
6453
- const functionEntries = [];
6454
- const setupFnRef = { current: null };
6455
- function isUseStateCall(node) {
6456
- return core.isUseStateLikeCall(node, additionalStateHooks);
6457
- }
6458
- function isUseEffectCall(node) {
6459
- return core.isUseEffectLikeCall(node, additionalEffectHooks);
6460
- }
6461
- function isUseEffectSetupCallback(node) {
6462
- return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectCall(node.parent);
6463
- }
6464
- function getFunctionKind(node) {
6465
- const parent = Traverse.findParent(node, not(Check.isTypeExpression)) ?? node.parent;
6466
- if (node.async) return "deferred";
6467
- if (parent.type === AST_NODE_TYPES.CallExpression && isThenCall(parent)) return "deferred";
6468
- if (node.type !== AST_NODE_TYPES.FunctionDeclaration && parent.type === AST_NODE_TYPES.CallExpression && parent.callee === node) return "immediate";
6469
- if (isUseEffectSetupCallback(node)) return "setup";
6470
- return "other";
6471
- }
6472
- return {
6473
- facts,
6474
- visitor: {
6475
- ":function"(node) {
6476
- const kind = getFunctionKind(node);
6477
- functionEntries.push({
6478
- kind,
6479
- node
6480
- });
6481
- if (kind === "setup") setupFnRef.current = node;
6482
- },
6483
- ":function:exit"(node) {
6484
- const { kind } = functionEntries.at(-1) ?? {};
6485
- if (kind === "setup" && setupFnRef.current === node) setupFnRef.current = null;
6486
- functionEntries.pop();
6487
- },
6488
- CallExpression(node) {
6489
- const entry = functionEntries.at(-1);
6490
- if (entry == null) return;
6491
- if (entry.node.async) return;
6492
- if (isUseStateCall(node)) return;
6493
- if (isUseEffectCall(node)) {
6494
- const setup = node.arguments.at(0);
6495
- if (setup != null && !Check.isFunction(setup)) facts.setupIdentifiers.push(...getNestedIdentifiers(setup));
6496
- return;
6497
- }
6498
- facts.calls.push({
6499
- enclosingFunction: entry.node,
6500
- enclosingFunctionKind: entry.kind,
6501
- node,
6502
- setupFunction: setupFnRef.current
6503
- });
6504
- },
6505
- Identifier(node) {
6506
- if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) return;
6507
- if (node.parent.type === AST_NODE_TYPES.ArrowFunctionExpression && node === node.parent.body) {
6508
- facts.setStateReferences.push({
6509
- kind: "callback-body",
6510
- node
6511
- });
6512
- return;
6513
- }
6514
- if (node.parent.type === AST_NODE_TYPES.CallExpression && node === node.parent.arguments.at(0)) facts.setStateReferences.push({
6515
- kind: "call-argument",
6516
- node
6517
- });
6518
- }
6519
- }
6520
- };
6521
- }
6522
- //#endregion
6523
- //#region src/rules/set-state-in-effect/origins.ts
6524
- function createSetStateResolver$1(context) {
6525
- const { additionalStateHooks } = getSettingsFromContext(context);
6526
- function isUseStateCall(node) {
6527
- return core.isUseStateLikeCall(node, additionalStateHooks);
6528
- }
6529
- function isSetStateId(id, at) {
6530
- const initNode = resolveOrigin(context, id);
6531
- if (initNode == null) return false;
6532
- if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6533
- if (!isUseStateCall(initNode)) return false;
6534
- const variableNodeParent = initNode.parent;
6535
- if (!hasProperty(variableNodeParent, "id")) return true;
6536
- if (variableNodeParent.id?.type === AST_NODE_TYPES.ObjectPattern) return variableNodeParent.id.properties.some((p) => p.type === AST_NODE_TYPES.Property && p.key.type === AST_NODE_TYPES.Literal && p.key.value === (at ?? 1) && Check.isIdentifier(p.value, id.name));
6537
- if (variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6538
- return variableNodeParent.id.elements.findIndex((e) => e != null && Check.isIdentifier(e, id.name)) === at;
6539
- }
6540
- function isSetStateCall(node) {
6541
- const callee = Extract.unwrap(node.callee);
6542
- switch (callee.type) {
6543
- case AST_NODE_TYPES.CallExpression: {
6544
- const innerCallee = Extract.unwrap(callee.callee);
6545
- if (innerCallee.type !== AST_NODE_TYPES.MemberExpression) return false;
6546
- if (!hasProperty(innerCallee.object, "name")) return false;
6547
- if (!(Extract.getCalleeName(callee) === "at")) return false;
6548
- const [index] = callee.arguments;
6549
- if (index == null) return false;
6550
- const indexScope = context.sourceCode.getScope(node);
6551
- return getStaticValue(index, indexScope)?.value === 1 && isSetStateId(innerCallee.object);
6552
- }
6553
- case AST_NODE_TYPES.Identifier: return isSetStateId(callee, 1);
6554
- case AST_NODE_TYPES.MemberExpression: {
6555
- if (!hasProperty(callee.object, "name")) return false;
6556
- const property = callee.property;
6557
- const propertyScope = context.sourceCode.getScope(node);
6558
- return getStaticValue(property, propertyScope)?.value === 1 && isSetStateId(callee.object, 1);
6559
- }
6560
- default: return false;
6561
- }
6562
- }
6563
- return {
6564
- isSetStateCall,
6565
- isSetStateId,
6566
- isUseStateCall
6567
- };
6568
- }
6569
- function isInitializedFromRef(context, id, refParams, seen = /* @__PURE__ */ new Set()) {
6570
- const name = id.name;
6571
- if (seen.has(name)) return false;
6572
- seen.add(name);
6573
- const variable = findVariable(context.sourceCode.getScope(id), name);
6574
- for (const def of variable?.defs ?? []) {
6575
- if (def.type === DefinitionType.Parameter) {
6576
- if (refParams?.has(def.name) === true) return true;
6577
- if (def.name.type === AST_NODE_TYPES.Identifier && (def.name.name === "ref" || def.name.name.endsWith("Ref"))) return true;
6578
- continue;
6579
- }
6580
- const { node } = def;
6581
- if (node.type !== AST_NODE_TYPES.VariableDeclarator) continue;
6582
- const init = node.init == null ? null : Extract.unwrap(node.init);
6583
- if (init == null) continue;
6584
- if (isExpressionFromRef(context, init, refParams, seen)) return true;
6585
- }
6586
- for (const reference of variable?.references ?? []) {
6587
- if (!reference.isWrite()) continue;
6588
- const writeExpr = reference.writeExpr == null ? null : Extract.unwrap(reference.writeExpr);
6589
- if (writeExpr == null) continue;
6590
- if (writeExpr.range[1] > id.range[0]) continue;
6591
- if (Traverse.hasParent(writeExpr, and(Check.isFunction, (n) => !Traverse.hasParent(id, (m) => m === n)))) continue;
6592
- if (isExpressionFromRef(context, writeExpr, refParams, seen)) return true;
6593
- }
6594
- return false;
6595
- }
6596
- function isExpressionFromRef(context, init, refParams, seen) {
6597
- const { additionalRefHooks } = getSettingsFromContext(context);
6598
- if (init.type === AST_NODE_TYPES.CallExpression && core.isUseRefLikeCall(init, additionalRefHooks)) return true;
6599
- if (init.type === AST_NODE_TYPES.MemberExpression) {
6600
- let current = init;
6601
- while (current.type === AST_NODE_TYPES.MemberExpression) {
6602
- const property = Extract.unwrap(current.property);
6603
- const object = Extract.unwrap(current.object);
6604
- if (!current.computed && Check.isIdentifier(property, "current")) {
6605
- const sourceName = getRefSourceName(object);
6606
- if (sourceName === "ref" || sourceName?.endsWith("Ref") === true) return true;
6607
- if (object.type === AST_NODE_TYPES.Identifier && isParameterId(context, object)) return true;
6608
- }
6609
- current = object;
6610
- }
6611
- if (Check.isIdentifier(current) && (current.name === "ref" || current.name.endsWith("Ref"))) return true;
6612
- return getNestedIdentifiers(init).some((id) => isInitializedFromRef(context, id, refParams, seen));
6613
- }
6614
- return getNestedIdentifiers(init).some((id) => isInitializedFromRef(context, id, refParams, seen));
6615
- }
6616
- function isArgumentUsingRefValue(context, node, refParams) {
6617
- const isUsingRefValue = (n) => {
6618
- switch (n.type) {
6619
- case AST_NODE_TYPES.Identifier: return isInitializedFromRef(context, n, refParams);
6620
- case AST_NODE_TYPES.MemberExpression: {
6621
- const property = Extract.unwrap(n.property);
6622
- if (!n.computed && Check.isIdentifier(property, "current") && n.object.type === AST_NODE_TYPES.Identifier && isParameterId(context, n.object)) return true;
6623
- return isUsingRefValue(n.object);
6624
- }
6625
- case AST_NODE_TYPES.CallExpression: return isUsingRefValue(n.callee) || getNestedIdentifiers(n).some(isUsingRefValue);
6626
- case AST_NODE_TYPES.ChainExpression: return isUsingRefValue(n.expression);
6627
- case AST_NODE_TYPES.BinaryExpression:
6628
- case AST_NODE_TYPES.LogicalExpression: return isUsingRefValue(n.left) || isUsingRefValue(n.right);
6629
- case AST_NODE_TYPES.UnaryExpression:
6630
- case AST_NODE_TYPES.UpdateExpression: return isUsingRefValue(n.argument);
6631
- case AST_NODE_TYPES.ConditionalExpression: return isUsingRefValue(n.consequent) || isUsingRefValue(n.alternate);
6632
- case AST_NODE_TYPES.SequenceExpression: return n.expressions.some(isUsingRefValue);
6633
- case AST_NODE_TYPES.TemplateLiteral: return n.expressions.some(isUsingRefValue);
6634
- case AST_NODE_TYPES.TaggedTemplateExpression: return isUsingRefValue(n.tag) || isUsingRefValue(n.quasi);
6635
- case AST_NODE_TYPES.ObjectExpression: return n.properties.some(isUsingRefValue);
6636
- case AST_NODE_TYPES.Property: return isUsingRefValue(n.value);
6637
- case AST_NODE_TYPES.ArrayExpression: return n.elements.some((element) => element != null && isUsingRefValue(element));
6638
- case AST_NODE_TYPES.SpreadElement: return isUsingRefValue(n.argument);
6639
- case AST_NODE_TYPES.AssignmentExpression: return isUsingRefValue(n.right);
6640
- default: return false;
6441
+ function getReturnExpressions(fn) {
6442
+ if (fn.type === AST_NODE_TYPES.ArrowFunctionExpression && fn.body.type !== AST_NODE_TYPES.BlockStatement) return [fn.body];
6443
+ const returns = [];
6444
+ const visitStatements = (statements) => {
6445
+ for (const statement of statements) switch (statement.type) {
6446
+ case AST_NODE_TYPES.ReturnStatement:
6447
+ if (statement.argument != null) returns.push(statement.argument);
6448
+ break;
6449
+ case AST_NODE_TYPES.BlockStatement:
6450
+ visitStatements(statement.body);
6451
+ break;
6452
+ case AST_NODE_TYPES.IfStatement:
6453
+ visitStatements([statement.consequent]);
6454
+ if (statement.alternate != null) visitStatements([statement.alternate]);
6455
+ break;
6456
+ case AST_NODE_TYPES.SwitchStatement:
6457
+ for (const switchCase of statement.cases) visitStatements(switchCase.consequent);
6458
+ break;
6459
+ case AST_NODE_TYPES.TryStatement:
6460
+ visitStatements([statement.block]);
6461
+ if (statement.handler != null) visitStatements([statement.handler.body]);
6462
+ if (statement.finalizer != null) visitStatements([statement.finalizer]);
6463
+ break;
6464
+ case AST_NODE_TYPES.DoWhileStatement:
6465
+ case AST_NODE_TYPES.ForInStatement:
6466
+ case AST_NODE_TYPES.ForOfStatement:
6467
+ case AST_NODE_TYPES.ForStatement:
6468
+ case AST_NODE_TYPES.LabeledStatement:
6469
+ case AST_NODE_TYPES.WhileStatement:
6470
+ case AST_NODE_TYPES.WithStatement: visitStatements([statement.body]);
6641
6471
  }
6642
6472
  };
6643
- if (isUsingRefValue(node)) return true;
6644
- return Check.isFunction(node) && context.sourceCode.getScope(node.body).references.some((r) => isUsingRefValue(r.identifier));
6473
+ if (fn.body.type !== AST_NODE_TYPES.BlockStatement) return [];
6474
+ visitStatements(fn.body.body);
6475
+ return returns;
6645
6476
  }
6646
- function isRefGatedContext(context, node, refParams) {
6477
+ function getConditionalBranch(node) {
6647
6478
  let child = node;
6648
6479
  let current = node.parent;
6649
- while (current != null) {
6650
- if (Check.isFunction(current)) break;
6651
- if (current.type === AST_NODE_TYPES.IfStatement) {
6652
- if (isRefInExpression(context, current.test, refParams)) return true;
6653
- }
6654
- if (current.type === AST_NODE_TYPES.ConditionalExpression) {
6655
- if (isRefInExpression(context, current.test, refParams)) return true;
6656
- }
6657
- if (current.type === AST_NODE_TYPES.LogicalExpression && child === current.right) {
6658
- if (isRefInExpression(context, current.left, refParams)) return true;
6659
- }
6660
- if (current.type === AST_NODE_TYPES.BlockStatement) {
6661
- const index = current.body.findIndex((statement) => statement === child);
6662
- for (const statement of current.body.slice(0, Math.max(0, index))) {
6663
- if (statement.type !== AST_NODE_TYPES.IfStatement) continue;
6664
- if (!isRefInExpression(context, statement.test, refParams)) continue;
6665
- if (isTerminatingStatement(statement.consequent)) return true;
6666
- }
6480
+ while (current != null && !Check.isFunction(current)) {
6481
+ if (Check.isLoopStatement(current) && child === current.body) return child;
6482
+ switch (current.type) {
6483
+ case AST_NODE_TYPES.IfStatement:
6484
+ case AST_NODE_TYPES.ConditionalExpression:
6485
+ if (child === current.consequent || child === current.alternate) return child;
6486
+ break;
6487
+ case AST_NODE_TYPES.LogicalExpression:
6488
+ if (child === current.right) return child;
6489
+ break;
6490
+ case AST_NODE_TYPES.SwitchCase: return current;
6667
6491
  }
6668
6492
  child = current;
6669
6493
  current = current.parent;
6670
6494
  }
6671
- return false;
6495
+ return null;
6672
6496
  }
6673
- function isRefInExpression(context, node, refParams) {
6674
- return getNestedIdentifiers(node).some((id) => isInitializedFromRef(context, id, refParams));
6497
+ function uniqueTargets(targets) {
6498
+ const seen = /* @__PURE__ */ new Set();
6499
+ return targets.filter((target) => {
6500
+ const key = `${target.kind}:${String(target.node.range[0])}`;
6501
+ if (seen.has(key)) return false;
6502
+ seen.add(key);
6503
+ return true;
6504
+ });
6675
6505
  }
6676
- function isParameterId(context, id) {
6677
- return findVariable(context.sourceCode.getScope(id), id)?.defs.some((def) => def.type === DefinitionType.Parameter) ?? false;
6506
+ function isRefLikeName(name) {
6507
+ return name === "ref" || name.endsWith("Ref");
6508
+ }
6509
+ function getParameterId(param) {
6510
+ switch (param.type) {
6511
+ case AST_NODE_TYPES.Identifier: return param;
6512
+ case AST_NODE_TYPES.AssignmentPattern: return param.left.type === AST_NODE_TYPES.Identifier ? param.left : null;
6513
+ default: return null;
6514
+ }
6678
6515
  }
6679
6516
  function getRefSourceName(node) {
6680
6517
  switch (node.type) {
@@ -6686,133 +6523,329 @@ function getRefSourceName(node) {
6686
6523
  default: return null;
6687
6524
  }
6688
6525
  }
6689
- //#endregion
6690
- //#region src/rules/set-state-in-effect/effects.ts
6691
- function inferViolations$2(context, facts) {
6692
- const { additionalEffectHooks } = getSettingsFromContext(context);
6693
- const resolver = createSetStateResolver$1(context);
6694
- const getText = (n) => context.sourceCode.getText(n);
6695
- const isUseEffectCall = (node) => core.isUseEffectLikeCall(node, additionalEffectHooks);
6696
- const isUseStateOrThenCall = or(resolver.isUseStateCall, isThenCall);
6697
- const setStateCallsByFn = /* @__PURE__ */ new Map();
6698
- const setStateInHookCallbacks = /* @__PURE__ */ new Map();
6699
- const setStateInEffectArg = /* @__PURE__ */ new Map();
6700
- const setStateInEffectSetup = /* @__PURE__ */ new Map();
6701
- const trackedFnCalls = [];
6702
- const violations = [];
6703
- for (const { enclosingFunction, enclosingFunctionKind, node, setupFunction } of facts.calls) {
6704
- if (isUseStateOrThenCall(node)) continue;
6705
- if (!resolver.isSetStateCall(node)) {
6706
- if (setupFunction == null) continue;
6707
- if (enclosingFunction !== setupFunction) continue;
6708
- trackedFnCalls.push(node);
6709
- continue;
6526
+ // src/rules/set-state-in-effect/origins.ts
6527
+ const EMPTY_FACTS = {
6528
+ calls: [],
6529
+ effectRoots: [],
6530
+ jsxRefExprs: []
6531
+ };
6532
+ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
6533
+ const { additionalRefHooks, additionalStateHooks } = getSettingsFromContext(context);
6534
+ const getReturnExpressions$1 = memoize(getReturnExpressions);
6535
+ function isUseRefCall(node) {
6536
+ return node.type === AST_NODE_TYPES.CallExpression && core.isUseRefLikeCall(node, additionalRefHooks);
6537
+ }
6538
+ function isUseStateCall(node) {
6539
+ return node.type === AST_NODE_TYPES.CallExpression && core.isUseStateLikeCall(node, additionalStateHooks);
6540
+ }
6541
+ function getStateSetterVariable(definition) {
6542
+ if (definition.type !== DefinitionType.Variable || definition.node.init == null) return null;
6543
+ const pattern = definition.node.id;
6544
+ if (pattern.type !== AST_NODE_TYPES.ArrayPattern || pattern.elements[0] !== definition.name) return null;
6545
+ const init = Extract.unwrap(definition.node.init);
6546
+ if (init.type !== AST_NODE_TYPES.CallExpression || !isUseStateCall(init)) return null;
6547
+ const setter = pattern.elements[1];
6548
+ if (setter?.type !== AST_NODE_TYPES.Identifier) return null;
6549
+ return findVariable(context.sourceCode.getScope(setter), setter) ?? null;
6550
+ }
6551
+ function isJsxRefTargetForSetter(target, setterVariable) {
6552
+ if (target.kind === "setter") {
6553
+ if (!Check.isIdentifier(target.node)) return false;
6554
+ return findVariable(context.sourceCode.getScope(target.node), target.node) === setterVariable;
6555
+ }
6556
+ if (target.node.async) return false;
6557
+ return setterVariable.references.some((r) => Traverse.hasParent(r.identifier, (n) => n === target.node));
6558
+ }
6559
+ const isStateHeldDomNode = memoize((variable) => variable.defs.some((definition) => {
6560
+ const setterVariable = getStateSetterVariable(definition);
6561
+ if (setterVariable == null) return false;
6562
+ return facts.jsxRefExprs.some((e) => resolveValues(e).some((t) => isJsxRefTargetForSetter(t, setterVariable)));
6563
+ }));
6564
+ function isSetStateId(id) {
6565
+ const initNode = resolveOrigin(context, id);
6566
+ if (initNode?.type !== AST_NODE_TYPES.CallExpression || !isUseStateCall(initNode)) return false;
6567
+ const initNodeParent = initNode.parent;
6568
+ if (!hasProperty(initNodeParent, "id")) return false;
6569
+ if (initNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return false;
6570
+ return initNodeParent.id.elements.findIndex((e) => e != null && Check.isIdentifier(e, id.name)) === 1;
6571
+ }
6572
+ function isSetStateExpression(node) {
6573
+ const expression = Extract.unwrap(node);
6574
+ return Check.isIdentifier(expression) && isSetStateId(expression);
6575
+ }
6576
+ function isSetStateCall(node) {
6577
+ return isSetStateExpression(node.callee);
6578
+ }
6579
+ function resolveValues(node, seen = /* @__PURE__ */ new Set()) {
6580
+ const expression = Extract.unwrap(node);
6581
+ if (isSetStateExpression(expression)) return [{
6582
+ kind: "setter",
6583
+ node: expression
6584
+ }];
6585
+ if (Check.isFunction(expression)) return [{
6586
+ kind: "function",
6587
+ node: expression
6588
+ }];
6589
+ switch (expression.type) {
6590
+ case AST_NODE_TYPES.Identifier: return resolveIdentifierValues(expression, seen);
6591
+ case AST_NODE_TYPES.ConditionalExpression: return uniqueTargets([...resolveValues(expression.consequent, new Set(seen)), ...resolveValues(expression.alternate, new Set(seen))]);
6592
+ case AST_NODE_TYPES.CallExpression: return resolveCallValues(expression, seen);
6593
+ default: return [];
6710
6594
  }
6711
- if (enclosingFunctionKind === "deferred") continue;
6712
- const syncEnclosingFunction = enclosingFunctionKind === "immediate" ? Traverse.findParent(enclosingFunction, Check.isFunction) : enclosingFunction;
6713
- if (setupFunction != null && syncEnclosingFunction === setupFunction) {
6714
- const args0 = node.arguments.at(0);
6715
- if (args0 == null) continue;
6716
- if (isArgumentUsingRefValue(context, args0)) continue;
6717
- if (isRefGatedContext(context, node)) continue;
6718
- violations.push({
6719
- name: getText(Extract.unwrap(node.callee)),
6720
- node
6595
+ }
6596
+ function resolveIdentifierValues(id, seen) {
6597
+ const variable = findVariable(context.sourceCode.getScope(id), id);
6598
+ if (variable == null || seen.has(variable)) return [];
6599
+ const definition = variable.defs.length === 1 ? variable.defs[0] : null;
6600
+ if (definition == null || definition.type === DefinitionType.Parameter || definition.type === DefinitionType.ImportBinding) return [];
6601
+ if (definition.type === DefinitionType.FunctionName) return Check.isFunction(definition.node) ? [{
6602
+ kind: "function",
6603
+ node: definition.node
6604
+ }] : [];
6605
+ if (definition.type !== DefinitionType.Variable) return [];
6606
+ if (definition.node.id !== definition.name || definition.node.init == null) return [];
6607
+ if (definition.node.parent.kind !== "const") return [];
6608
+ seen.add(variable);
6609
+ return resolveValues(definition.node.init, seen);
6610
+ }
6611
+ function resolveCallValues(call, seen) {
6612
+ const [argument] = call.arguments;
6613
+ if (argument == null || argument.type === AST_NODE_TYPES.SpreadElement) return [];
6614
+ if (core.isUseCallbackCall(context, call) || Extract.getCalleeName(call) === "useEffectEvent") return resolveValues(argument, seen);
6615
+ if (!core.isUseMemoCall(context, call)) return [];
6616
+ const factories = resolveValues(argument, seen);
6617
+ const targets = [];
6618
+ for (const factory of factories) {
6619
+ if (factory.kind !== "function" || factory.node.async) continue;
6620
+ for (const returnExpression of getReturnExpressions$1(factory.node)) targets.push(...resolveValues(returnExpression, new Set(seen)));
6621
+ }
6622
+ return uniqueTargets(targets);
6623
+ }
6624
+ function getSetterName(node) {
6625
+ return Extract.getFullyQualifiedName(node, getText(context));
6626
+ }
6627
+ function getRefDerivedParams(call, fn, currentRefParams = /* @__PURE__ */ new Set()) {
6628
+ const refParams = new Set(currentRefParams);
6629
+ const parameterIds = fn.params.map(getParameterId);
6630
+ for (const id of parameterIds) if (id != null) refParams.delete(id);
6631
+ for (const [index, id] of parameterIds.entries()) {
6632
+ if (id == null) continue;
6633
+ const argument = call.arguments.at(index);
6634
+ if (argument == null || argument.type === AST_NODE_TYPES.SpreadElement) continue;
6635
+ if (isArgumentUsingRefValue(argument, currentRefParams)) refParams.add(id);
6636
+ }
6637
+ return refParams;
6638
+ }
6639
+ function isInitializedFromRef(id, refParams, seen = /* @__PURE__ */ new Set()) {
6640
+ const variable = findVariable(context.sourceCode.getScope(id), id);
6641
+ if (variable == null) return false;
6642
+ const key = `${String(variable.identifiers.at(0)?.range[0] ?? variable.name)}:${String(id.range[0])}`;
6643
+ if (seen.has(key)) return false;
6644
+ seen.add(key);
6645
+ if (isStateHeldDomNode(variable)) return true;
6646
+ const candidates = [];
6647
+ const addCandidate = (value, previous) => {
6648
+ if (value.range[1] > id.range[0] || candidates.some((c) => c.value === value)) return;
6649
+ candidates.push({
6650
+ branch: getConditionalBranch(value),
6651
+ position: value.range[1],
6652
+ previous,
6653
+ value
6721
6654
  });
6722
- continue;
6655
+ };
6656
+ for (const definition of variable.defs) {
6657
+ if (definition.type !== DefinitionType.Variable || definition.node.init == null) continue;
6658
+ addCandidate(definition.node.init);
6659
+ }
6660
+ for (const reference of variable.references) {
6661
+ if (!reference.isWrite() || reference.writeExpr == null) continue;
6662
+ if (reference.init === true && variable.defs.some((d) => d.type === DefinitionType.Parameter && refParams?.has(d.name) === true)) continue;
6663
+ const writeExpr = reference.writeExpr;
6664
+ if (Traverse.hasParent(writeExpr, and(Check.isFunction, (fn) => !Traverse.hasParent(id, (n) => n === fn)))) continue;
6665
+ const parent = reference.identifier.parent;
6666
+ addCandidate(writeExpr, parent.type === AST_NODE_TYPES.AssignmentExpression && parent.operator !== "=" && Extract.unwrap(parent.left) === reference.identifier ? reference.identifier : void 0);
6667
+ }
6668
+ const survivingCandidates = [];
6669
+ for (const candidate of [...candidates].sort((a, b) => a.position - b.position)) {
6670
+ if (candidate.branch == null) survivingCandidates.length = 0;
6671
+ else {
6672
+ const previousIndex = survivingCandidates.findIndex((o) => o.branch === candidate.branch);
6673
+ if (previousIndex >= 0) survivingCandidates.splice(previousIndex, 1);
6674
+ }
6675
+ survivingCandidates.push(candidate);
6723
6676
  }
6724
- const init = Traverse.findParent(node, isHookDecl)?.init;
6725
- if (init == null) getOrInsertComputed(setStateCallsByFn, enclosingFunction, () => []).push(node);
6726
- else getOrInsertComputed(setStateInHookCallbacks, init, () => []).push(node);
6727
- }
6728
- for (const { kind, node } of facts.setStateReferences) {
6729
- if (!resolver.isSetStateId(node, 1)) continue;
6730
- if (kind === "callback-body") {
6731
- const parent = node.parent.parent;
6732
- if (parent?.type !== AST_NODE_TYPES.CallExpression) continue;
6733
- if (!core.isUseMemoCall(context, parent)) continue;
6734
- const init = Traverse.findParent(parent, isHookDecl)?.init;
6735
- if (init != null) getOrInsertComputed(setStateInEffectArg, init, () => []).push(node);
6736
- continue;
6677
+ if (survivingCandidates.length > 0) return survivingCandidates.some((c) => c.previous != null && isInitializedFromRef(c.previous, refParams, seen) || isRefValue(c.value, refParams, seen, "initializer"));
6678
+ return variable.defs.some((d) => d.type === DefinitionType.Parameter && (refParams?.has(d.name) === true || d.name.type === AST_NODE_TYPES.Identifier && isRefLikeName(d.name.name)));
6679
+ }
6680
+ function isRefValue(node, refParams, seen, mode) {
6681
+ const expression = Extract.unwrap(node);
6682
+ if (isUseRefCall(expression)) return true;
6683
+ switch (expression.type) {
6684
+ case AST_NODE_TYPES.Identifier: return isInitializedFromRef(expression, refParams, seen);
6685
+ case AST_NODE_TYPES.MemberExpression: {
6686
+ const property = Extract.unwrap(expression.property);
6687
+ const object = Extract.unwrap(expression.object);
6688
+ if (!expression.computed && Check.isIdentifier(property, "current") && object.type === AST_NODE_TYPES.Identifier && isParameterId(object)) return true;
6689
+ if (mode === "initializer") {
6690
+ let current = expression;
6691
+ while (current.type === AST_NODE_TYPES.MemberExpression) {
6692
+ const currentProperty = Extract.unwrap(current.property);
6693
+ const currentObject = Extract.unwrap(current.object);
6694
+ if (!current.computed && Check.isIdentifier(currentProperty, "current")) {
6695
+ const sourceName = getRefSourceName(currentObject);
6696
+ if (sourceName != null && isRefLikeName(sourceName)) return true;
6697
+ if (currentObject.type === AST_NODE_TYPES.Identifier && isParameterId(currentObject)) return true;
6698
+ }
6699
+ current = currentObject;
6700
+ }
6701
+ if (Check.isIdentifier(current) && isRefLikeName(current.name)) return true;
6702
+ }
6703
+ return isRefValue(expression.object, refParams, seen, mode) || expression.computed && isRefValue(expression.property, refParams, seen, mode);
6704
+ }
6705
+ case AST_NODE_TYPES.CallExpression:
6706
+ for (const target of resolveValues(expression.callee)) {
6707
+ if (target.kind !== "function" || target.node.async) continue;
6708
+ const key = `getter:${String(target.node.range[0])}`;
6709
+ if (seen.has(key)) continue;
6710
+ seen.add(key);
6711
+ const childRefParams = getRefDerivedParams(expression, target.node, refParams);
6712
+ if (getReturnExpressions$1(target.node).some((r) => isRefValue(r, childRefParams, seen, mode))) return true;
6713
+ }
6714
+ return isRefValue(expression.callee, refParams, seen, mode) || expression.arguments.some((a) => isRefValue(a, refParams, seen, mode));
6715
+ case AST_NODE_TYPES.BinaryExpression:
6716
+ case AST_NODE_TYPES.LogicalExpression: return isRefValue(expression.left, refParams, seen, mode) || isRefValue(expression.right, refParams, seen, mode);
6717
+ case AST_NODE_TYPES.UnaryExpression:
6718
+ case AST_NODE_TYPES.UpdateExpression: return isRefValue(expression.argument, refParams, seen, mode);
6719
+ case AST_NODE_TYPES.ConditionalExpression: return mode === "initializer" && isRefValue(expression.test, refParams, seen, mode) || isRefValue(expression.consequent, refParams, seen, mode) || isRefValue(expression.alternate, refParams, seen, mode);
6720
+ case AST_NODE_TYPES.SequenceExpression: return expression.expressions.some((p) => isRefValue(p, refParams, seen, mode));
6721
+ case AST_NODE_TYPES.TemplateLiteral: return expression.expressions.some((p) => isRefValue(p, refParams, seen, mode));
6722
+ case AST_NODE_TYPES.TaggedTemplateExpression: return isRefValue(expression.tag, refParams, seen, mode) || isRefValue(expression.quasi, refParams, seen, mode);
6723
+ case AST_NODE_TYPES.ObjectExpression: return expression.properties.some((p) => isRefValue(p, refParams, seen, mode));
6724
+ case AST_NODE_TYPES.Property: return isRefValue(expression.value, refParams, seen, mode);
6725
+ case AST_NODE_TYPES.ArrayExpression: return expression.elements.some((e) => e != null && isRefValue(e, refParams, seen, mode));
6726
+ case AST_NODE_TYPES.SpreadElement:
6727
+ case AST_NODE_TYPES.AssignmentExpression:
6728
+ case AST_NODE_TYPES.AwaitExpression: return isRefValue(expression.type === AST_NODE_TYPES.AssignmentExpression ? expression.right : expression.argument, refParams, seen, mode);
6729
+ default: return false;
6737
6730
  }
6738
- const parent = node.parent;
6739
- if (parent.type !== AST_NODE_TYPES.CallExpression) continue;
6740
- if (core.isUseCallbackCall(context, parent)) {
6741
- const init = Traverse.findParent(parent, isHookDecl)?.init;
6742
- if (init != null) getOrInsertComputed(setStateInEffectArg, init, () => []).push(node);
6743
- continue;
6731
+ }
6732
+ function isArgumentUsingRefValue(node, refParams) {
6733
+ const seen = /* @__PURE__ */ new Set();
6734
+ if (isRefValue(node, refParams, seen, "argument")) return true;
6735
+ const expression = Extract.unwrap(node);
6736
+ if (!Check.isFunction(expression)) return false;
6737
+ return context.sourceCode.getScope(expression.body).references.some((r) => isRefValue(r.identifier, refParams, seen, "argument"));
6738
+ }
6739
+ function isRefInExpression(node, refParams) {
6740
+ return getIdentifiers(node).some((id) => isInitializedFromRef(id, refParams));
6741
+ }
6742
+ function isRefGatedContext(node, refParams) {
6743
+ let child = node;
6744
+ let current = node.parent;
6745
+ while (current != null) {
6746
+ if (Check.isFunction(current)) break;
6747
+ switch (current.type) {
6748
+ case AST_NODE_TYPES.IfStatement:
6749
+ case AST_NODE_TYPES.ConditionalExpression:
6750
+ if ((child === current.consequent || child === current.alternate) && isRefInExpression(current.test, refParams)) return true;
6751
+ break;
6752
+ case AST_NODE_TYPES.LogicalExpression:
6753
+ if (child === current.right && isRefInExpression(current.left, refParams)) return true;
6754
+ break;
6755
+ case AST_NODE_TYPES.BlockStatement: {
6756
+ const index = current.body.findIndex((s) => s === child);
6757
+ for (const statement of current.body.slice(0, Math.max(0, index))) {
6758
+ if (statement.type !== AST_NODE_TYPES.IfStatement) continue;
6759
+ if (!isRefInExpression(statement.test, refParams)) continue;
6760
+ if (isTerminatingStatement(statement.consequent)) return true;
6761
+ }
6762
+ break;
6763
+ }
6764
+ }
6765
+ child = current;
6766
+ current = current.parent;
6744
6767
  }
6745
- if (isUseEffectCall(parent)) getOrInsertComputed(setStateInEffectSetup, parent, () => []).push(node);
6768
+ return false;
6746
6769
  }
6747
- const isExemptSetStateCall = (setStateCall, refParams) => {
6748
- const callNode = getSetStateCallExpression(setStateCall);
6749
- if (isRefGatedContext(context, callNode, refParams)) return true;
6750
- if (callNode.type !== AST_NODE_TYPES.CallExpression) return false;
6751
- const args0 = callNode.arguments.at(0);
6752
- return args0 != null && isArgumentUsingRefValue(context, args0, refParams);
6770
+ function isParameterId(id) {
6771
+ return findVariable(context.sourceCode.getScope(id), id)?.defs.some((d) => d.type === DefinitionType.Parameter) ?? false;
6772
+ }
6773
+ return {
6774
+ getRefDerivedParams,
6775
+ getSetterName,
6776
+ isArgumentUsingRefValue,
6777
+ isInitializedFromRef,
6778
+ isRefGatedContext,
6779
+ isSetStateCall,
6780
+ isSetStateId,
6781
+ isUseStateCall,
6782
+ resolveValues
6753
6783
  };
6754
- const getHelperFunction = (callee) => {
6755
- const origin = resolveOrigin(context, callee);
6756
- if (Check.isFunction(origin)) return origin;
6757
- if (!core.isUseCallbackCall(context, origin)) return null;
6758
- const callback = origin.arguments.at(0);
6759
- if (callback == null || callback.type === AST_NODE_TYPES.SpreadElement) return null;
6760
- const unwrapped = Extract.unwrap(callback);
6761
- return Check.isFunction(unwrapped) ? unwrapped : null;
6784
+ }
6785
+ // src/rules/set-state-in-effect/effects.ts
6786
+ function inferViolations$2(context, facts) {
6787
+ if (facts.effectRoots.length === 0) return [];
6788
+ const resolver = createSetStateResolver$1(context, facts);
6789
+ const callsByFunction = /* @__PURE__ */ new Map();
6790
+ for (const fact of facts.calls) getOrInsertComputed(callsByFunction, fact.enclosingFunction, () => []).push(fact.node);
6791
+ const queue = [];
6792
+ const visited = /* @__PURE__ */ new Set();
6793
+ const violations = /* @__PURE__ */ new Map();
6794
+ const enqueue = (state) => {
6795
+ if (state.fn.async) return;
6796
+ const refParamsKey = [...state.refParams].map((n) => n.range[0]).sort((a, b) => a - b).join(",");
6797
+ const key = `${String(state.fn.range[0])}:${state.inheritedRefGate ? "gated" : "plain"}:${refParamsKey}`;
6798
+ if (visited.has(key)) return;
6799
+ visited.add(key);
6800
+ queue.push(state);
6762
6801
  };
6763
- const getRefDerivedParams = (call, callee) => {
6764
- const origin = getHelperFunction(callee);
6765
- if (origin == null) return void 0;
6766
- const refParams = /* @__PURE__ */ new Set();
6767
- origin.params.forEach((param, index) => {
6768
- const paramId = param.type === AST_NODE_TYPES.Identifier ? param : param.type === AST_NODE_TYPES.AssignmentPattern && param.left.type === AST_NODE_TYPES.Identifier ? param.left : null;
6769
- if (paramId == null) return;
6770
- const arg = call.arguments.at(index);
6771
- if (arg == null || arg.type === AST_NODE_TYPES.SpreadElement) return;
6772
- if (isArgumentUsingRefValue(context, arg)) refParams.add(paramId);
6802
+ const report = (sink, setter, reportNode) => {
6803
+ if (violations.has(sink)) return;
6804
+ violations.set(sink, {
6805
+ name: resolver.getSetterName(setter.node),
6806
+ node: reportNode
6773
6807
  });
6774
- return refParams.size > 0 ? refParams : void 0;
6775
6808
  };
6776
- const getSetStateCalls = (id) => {
6777
- const variable = findVariable(context.sourceCode.getScope(id), id);
6778
- if (variable != null && variable.defs.some((def) => def.type === DefinitionType.Parameter)) return [];
6779
- const node = resolveOrigin(context, id);
6780
- switch (node?.type) {
6781
- case AST_NODE_TYPES.ArrowFunctionExpression:
6782
- case AST_NODE_TYPES.FunctionDeclaration:
6783
- case AST_NODE_TYPES.FunctionExpression: return setStateCallsByFn.get(node) ?? [];
6784
- case AST_NODE_TYPES.CallExpression: return setStateInHookCallbacks.get(node) ?? setStateInEffectArg.get(node) ?? [];
6785
- }
6786
- return [];
6809
+ const isExemptCall = (call, state) => {
6810
+ if (state.inheritedRefGate || resolver.isRefGatedContext(call, state.refParams)) return true;
6811
+ const argument = call.arguments.at(0);
6812
+ return argument != null && resolver.isArgumentUsingRefValue(argument, state.refParams);
6787
6813
  };
6788
- for (const [, calls] of setStateInEffectSetup) for (const call of calls) {
6789
- if (isExemptSetStateCall(call)) continue;
6790
- violations.push({
6791
- name: call.name,
6792
- node: call
6793
- });
6794
- }
6795
- for (const trackedCall of trackedFnCalls) {
6796
- const unwrappedCallee = Extract.unwrap(trackedCall.callee);
6797
- if (!Check.isIdentifier(unwrappedCallee)) continue;
6798
- if (isRefGatedContext(context, trackedCall)) continue;
6799
- const refParams = getRefDerivedParams(trackedCall, unwrappedCallee);
6800
- for (const setStateCall of getSetStateCalls(unwrappedCallee)) {
6801
- if (isExemptSetStateCall(setStateCall, refParams)) continue;
6802
- violations.push({
6803
- name: getCallName(setStateCall, getText),
6804
- node: setStateCall
6814
+ for (const root of [...facts.effectRoots].sort((a, b) => a.node.range[0] - b.node.range[0])) {
6815
+ const setup = root.setup;
6816
+ const unwrappedSetup = Extract.unwrap(setup);
6817
+ for (const target of resolver.resolveValues(setup)) {
6818
+ if (target.kind === "setter") {
6819
+ if (!resolver.isRefGatedContext(setup)) report(target.node, target, setup);
6820
+ continue;
6821
+ }
6822
+ const reportNode = unwrappedSetup === target.node ? null : setup;
6823
+ enqueue({
6824
+ fn: target.node,
6825
+ inheritedRefGate: false,
6826
+ refParams: /* @__PURE__ */ new Set(),
6827
+ reportNode
6805
6828
  });
6806
6829
  }
6807
6830
  }
6808
- for (const id of facts.setupIdentifiers) for (const setStateCall of getSetStateCalls(id)) {
6809
- if (isExemptSetStateCall(setStateCall)) continue;
6810
- violations.push({
6811
- name: getCallName(setStateCall, getText),
6812
- node: setStateCall
6813
- });
6831
+ for (let index = 0; index < queue.length; index++) {
6832
+ const state = queue[index];
6833
+ if (state == null) continue;
6834
+ const calls = callsByFunction.get(state.fn) ?? [];
6835
+ for (const call of calls) for (const target of resolver.resolveValues(call.callee)) {
6836
+ if (target.kind === "setter") {
6837
+ if (!isExemptCall(call, state)) report(call, target, state.reportNode ?? call);
6838
+ continue;
6839
+ }
6840
+ enqueue({
6841
+ fn: target.node,
6842
+ inheritedRefGate: state.inheritedRefGate || resolver.isRefGatedContext(call, state.refParams),
6843
+ refParams: resolver.getRefDerivedParams(call, target.node, state.refParams),
6844
+ reportNode: state.reportNode ?? call
6845
+ });
6846
+ }
6814
6847
  }
6815
- return violations;
6848
+ return [...violations.values()].sort((a, b) => a.node.range[0] - b.node.range[0] || a.node.range[1] - b.node.range[1]);
6816
6849
  }
6817
6850
  var set_state_in_effect_default = createRule({
6818
6851
  meta: {
@@ -6836,8 +6869,7 @@ function create$5(context) {
6836
6869
  });
6837
6870
  } });
6838
6871
  }
6839
- //#endregion
6840
- //#region src/rules/set-state-in-render/helpers.ts
6872
+ // src/rules/set-state-in-render/helpers.ts
6841
6873
  const isComponentOrHookName = or(core.isFunctionComponentName, core.isHookName);
6842
6874
  function isComponentOrHookLikeFunction(context, node) {
6843
6875
  const id = core.getFunctionId(node);
@@ -6860,8 +6892,7 @@ function isInsideConditional(node, stopAt) {
6860
6892
  }
6861
6893
  return false;
6862
6894
  }
6863
- //#endregion
6864
- //#region src/rules/set-state-in-render/collect.ts
6895
+ // src/rules/set-state-in-render/collect.ts
6865
6896
  function createFactCollector$2(context) {
6866
6897
  const { additionalStateHooks } = getSettingsFromContext(context);
6867
6898
  const facts = {
@@ -6871,7 +6902,7 @@ function createFactCollector$2(context) {
6871
6902
  const functionEntries = [];
6872
6903
  const componentFnStack = [];
6873
6904
  function isUseStateCall(node) {
6874
- return core.isUseStateLikeCall(node, additionalStateHooks);
6905
+ return node.type === AST_NODE_TYPES.CallExpression && core.isUseStateLikeCall(node, additionalStateHooks);
6875
6906
  }
6876
6907
  function getFunctionKind(node) {
6877
6908
  if (isComponentOrHookLikeFunction(context, node)) return "component";
@@ -6927,46 +6958,22 @@ function createFactCollector$2(context) {
6927
6958
  }
6928
6959
  };
6929
6960
  }
6930
- //#endregion
6931
- //#region src/rules/set-state-in-render/origins.ts
6961
+ // src/rules/set-state-in-render/origins.ts
6932
6962
  function createSetStateResolver(context) {
6933
6963
  const { additionalStateHooks } = getSettingsFromContext(context);
6934
6964
  function isUseStateCall(node) {
6935
- return core.isUseStateLikeCall(node, additionalStateHooks);
6965
+ return node.type === AST_NODE_TYPES.CallExpression && core.isUseStateLikeCall(node, additionalStateHooks);
6936
6966
  }
6937
- function isSetStateId(id, at) {
6967
+ function isSetStateId(id) {
6938
6968
  const initNode = resolveOrigin(context, id);
6939
- if (initNode == null) return false;
6940
- if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6941
- if (!isUseStateCall(initNode)) return false;
6969
+ if (initNode?.type !== AST_NODE_TYPES.CallExpression || !isUseStateCall(initNode)) return false;
6942
6970
  const variableNodeParent = initNode.parent;
6943
- if (!hasProperty(variableNodeParent, "id")) return true;
6944
- if (variableNodeParent.id?.type === AST_NODE_TYPES.ObjectPattern) return variableNodeParent.id.properties.some((p) => p.type === AST_NODE_TYPES.Property && p.key.type === AST_NODE_TYPES.Literal && p.key.value === (at ?? 1) && Check.isIdentifier(p.value, id.name));
6945
- if (variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6946
- return variableNodeParent.id.elements.findIndex((e) => e != null && Check.isIdentifier(e, id.name)) === at;
6971
+ if (!hasProperty(variableNodeParent, "id") || variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return false;
6972
+ return variableNodeParent.id.elements.findIndex((e) => e != null && Check.isIdentifier(e, id.name)) === 1;
6947
6973
  }
6948
6974
  function isSetStateCall(node) {
6949
6975
  const callee = Extract.unwrap(node.callee);
6950
- switch (callee.type) {
6951
- case AST_NODE_TYPES.CallExpression: {
6952
- const innerCallee = Extract.unwrap(callee.callee);
6953
- if (innerCallee.type !== AST_NODE_TYPES.MemberExpression) return false;
6954
- if (!hasProperty(innerCallee.object, "name")) return false;
6955
- if (!(Extract.getCalleeName(callee) === "at")) return false;
6956
- const [index] = callee.arguments;
6957
- if (index == null) return false;
6958
- const indexScope = context.sourceCode.getScope(node);
6959
- return getStaticValue(index, indexScope)?.value === 1 && isSetStateId(innerCallee.object);
6960
- }
6961
- case AST_NODE_TYPES.Identifier: return isSetStateId(callee, 1);
6962
- case AST_NODE_TYPES.MemberExpression: {
6963
- if (!hasProperty(callee.object, "name")) return false;
6964
- const property = callee.property;
6965
- const propertyScope = context.sourceCode.getScope(node);
6966
- return getStaticValue(property, propertyScope)?.value === 1 && isSetStateId(callee.object, 1);
6967
- }
6968
- default: return false;
6969
- }
6976
+ return Check.isIdentifier(callee) && isSetStateId(callee);
6970
6977
  }
6971
6978
  return {
6972
6979
  isSetStateCall,
@@ -6974,11 +6981,9 @@ function createSetStateResolver(context) {
6974
6981
  isUseStateCall
6975
6982
  };
6976
6983
  }
6977
- //#endregion
6978
- //#region src/rules/set-state-in-render/effects.ts
6984
+ // src/rules/set-state-in-render/effects.ts
6979
6985
  function inferViolations$1(context, facts) {
6980
6986
  const resolver = createSetStateResolver(context);
6981
- const getText = (n) => context.sourceCode.getText(n);
6982
6987
  const earlyReturnPositions = /* @__PURE__ */ new Map();
6983
6988
  for (const { componentFunction, node } of facts.earlyReturns) getOrInsertComputed(earlyReturnPositions, componentFunction, () => []).push(node.range[0]);
6984
6989
  const violations = [];
@@ -6989,7 +6994,7 @@ function inferViolations$1(context, facts) {
6989
6994
  if (isInsideConditional(node, componentFunction)) continue;
6990
6995
  if (earlyReturnPositions.get(componentFunction)?.some((pos) => pos < node.range[0]) === true) continue;
6991
6996
  violations.push({
6992
- name: getText(Extract.unwrap(node.callee)),
6997
+ name: getText(context, Extract.unwrap(node.callee)),
6993
6998
  node
6994
6999
  });
6995
7000
  }
@@ -7015,8 +7020,7 @@ function create$4(context) {
7015
7020
  });
7016
7021
  } });
7017
7022
  }
7018
- //#endregion
7019
- //#region src/rules/static-components/collect.ts
7023
+ // src/rules/static-components/collect.ts
7020
7024
  function createFactCollector$1() {
7021
7025
  const facts = { componentUsages: [] };
7022
7026
  return {
@@ -7032,8 +7036,7 @@ function createFactCollector$1() {
7032
7036
  } }
7033
7037
  };
7034
7038
  }
7035
- //#endregion
7036
- //#region src/rules/static-components/helpers.ts
7039
+ // src/rules/static-components/helpers.ts
7037
7040
  const KNOWN_DYNAMIC_EXPRESSION_TYPES = /* @__PURE__ */ new Set([
7038
7041
  AST_NODE_TYPES.ArrowFunctionExpression,
7039
7042
  AST_NODE_TYPES.CallExpression,
@@ -7045,8 +7048,7 @@ function createRenderBoundaryChecker(componentNodes) {
7045
7048
  const components = new Set(componentNodes);
7046
7049
  return (node) => Traverse.hasParent(node, (n) => Check.isFunctionOrClass(n) && components.has(n));
7047
7050
  }
7048
- //#endregion
7049
- //#region src/rules/static-components/origins.ts
7051
+ // src/rules/static-components/origins.ts
7050
7052
  function findDynamicCreationSite(context, node, isInsideRender, seen) {
7051
7053
  const expr = Extract.unwrap(node);
7052
7054
  if (KNOWN_DYNAMIC_EXPRESSION_TYPES.has(expr.type)) return expr;
@@ -7109,8 +7111,7 @@ function resolveDynamicComponentOrigin(context, variable, isInsideRender, seen =
7109
7111
  isDynamic: false
7110
7112
  };
7111
7113
  }
7112
- //#endregion
7113
- //#region src/rules/static-components/effects.ts
7114
+ // src/rules/static-components/effects.ts
7114
7115
  function inferCreatedComponents(context, componentUsages, isInsideRender) {
7115
7116
  const effects = [];
7116
7117
  for (const usage of componentUsages) {
@@ -7165,8 +7166,7 @@ function create$3(context) {
7165
7166
  }
7166
7167
  } });
7167
7168
  }
7168
- //#endregion
7169
- //#region src/rules/unsupported-syntax/lib.ts
7169
+ // src/rules/unsupported-syntax/lib.ts
7170
7170
  function isEvalCall(node) {
7171
7171
  const callee = Extract.unwrap(node.callee);
7172
7172
  switch (callee.type) {
@@ -7234,14 +7234,13 @@ function create$2(context) {
7234
7234
  }
7235
7235
  });
7236
7236
  }
7237
- //#endregion
7238
- //#region src/rules/use-memo/helpers.ts
7237
+ // src/rules/use-memo/helpers.ts
7239
7238
  function isResultUsed(node) {
7240
7239
  let parent = node.parent;
7241
7240
  while (Check.isTypeExpression(parent)) parent = parent.parent;
7242
7241
  return parent.type === AST_NODE_TYPES.VariableDeclarator || parent.type === AST_NODE_TYPES.AssignmentExpression || parent.type === AST_NODE_TYPES.AssignmentPattern || parent.type === AST_NODE_TYPES.Property || parent.type === AST_NODE_TYPES.ReturnStatement || parent.type === AST_NODE_TYPES.JSXExpressionContainer || parent.type === AST_NODE_TYPES.CallExpression || parent.type === AST_NODE_TYPES.NewExpression || parent.type === AST_NODE_TYPES.ArrayExpression || parent.type === AST_NODE_TYPES.ConditionalExpression || parent.type === AST_NODE_TYPES.LogicalExpression || parent.type === AST_NODE_TYPES.SequenceExpression || parent.type === AST_NODE_TYPES.SpreadElement || parent.type === AST_NODE_TYPES.TemplateLiteral || parent.type === AST_NODE_TYPES.BinaryExpression || parent.type === AST_NODE_TYPES.UnaryExpression || parent.type === AST_NODE_TYPES.MemberExpression || parent.type === AST_NODE_TYPES.TaggedTemplateExpression || parent.type === AST_NODE_TYPES.ChainExpression || parent.type === AST_NODE_TYPES.ArrowFunctionExpression || parent.type === AST_NODE_TYPES.ForOfStatement || parent.type === AST_NODE_TYPES.ForInStatement;
7243
7242
  }
7244
- function getNestedReturnStatements(node) {
7243
+ function getReturnStatements(node) {
7245
7244
  const statements = [];
7246
7245
  const boundary = Check.isFunction(node) ? node : Traverse.findParent(node, Check.isFunction);
7247
7246
  simpleTraverse(node, { enter(node) {
@@ -7251,8 +7250,7 @@ function getNestedReturnStatements(node) {
7251
7250
  } });
7252
7251
  return statements;
7253
7252
  }
7254
- //#endregion
7255
- //#region src/rules/use-memo/collect.ts
7253
+ // src/rules/use-memo/collect.ts
7256
7254
  function createFactCollector(isUseMemoCall) {
7257
7255
  const facts = { calls: [] };
7258
7256
  function collectWrites(callback) {
@@ -7291,14 +7289,13 @@ function createFactCollector(isUseMemoCall) {
7291
7289
  callbackArg,
7292
7290
  isResultUsed: isResultUsed(node),
7293
7291
  node,
7294
- returnStatements: callbackFunction != null ? getNestedReturnStatements(callbackFunction) : [],
7292
+ returnStatements: callbackFunction != null ? getReturnStatements(callbackFunction) : [],
7295
7293
  writes: callbackFunction != null ? collectWrites(callbackFunction) : []
7296
7294
  });
7297
7295
  } }
7298
7296
  };
7299
7297
  }
7300
- //#endregion
7301
- //#region src/rules/use-memo/origins.ts
7298
+ // src/rules/use-memo/origins.ts
7302
7299
  function isDeclaredInsideCallback(variable, callback) {
7303
7300
  let scope = variable.scope;
7304
7301
  while (scope != null) {
@@ -7313,8 +7310,7 @@ function isOuterVariable(context, target, callback) {
7313
7310
  if (variable == null || variable.defs.length === 0) return true;
7314
7311
  return !isDeclaredInsideCallback(variable, callback);
7315
7312
  }
7316
- //#endregion
7317
- //#region src/rules/use-memo/effects.ts
7313
+ // src/rules/use-memo/effects.ts
7318
7314
  function inferViolations(context, facts) {
7319
7315
  const violations = [];
7320
7316
  for (const fact of facts.calls) {
@@ -7381,8 +7377,7 @@ function create$1(context) {
7381
7377
  });
7382
7378
  } });
7383
7379
  }
7384
- //#endregion
7385
- //#region src/rules/use-state/lib.ts
7380
+ // src/rules/use-state/lib.ts
7386
7381
  const LAZY_INIT_ALLOW_LIST = [
7387
7382
  "Boolean",
7388
7383
  "String",
@@ -7441,7 +7436,7 @@ const EXPRESSION_VISITOR_KEYS = {
7441
7436
  [AST_NODE_TYPES.WhileStatement]: ["test"],
7442
7437
  [AST_NODE_TYPES.YieldExpression]: ["argument"]
7443
7438
  };
7444
- function getNestedExpressionsOfType(type) {
7439
+ function getExpressionsOfType(type) {
7445
7440
  const isNodeOfType = Check.is(type);
7446
7441
  const recurse = (node) => {
7447
7442
  const expressions = [];
@@ -7456,10 +7451,9 @@ function getNestedExpressionsOfType(type) {
7456
7451
  };
7457
7452
  return recurse;
7458
7453
  }
7459
- const getNestedNewExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.NewExpression);
7460
- const getNestedCallExpressions = getNestedExpressionsOfType(AST_NODE_TYPES.CallExpression);
7461
- //#endregion
7462
- //#region src/rules/use-state/use-state.ts
7454
+ const getNewExpressions = getExpressionsOfType(AST_NODE_TYPES.NewExpression);
7455
+ const getCallExpressions = getExpressionsOfType(AST_NODE_TYPES.CallExpression);
7456
+ // src/rules/use-state/use-state.ts
7463
7457
  const RULE_NAME = "use-state";
7464
7458
  const defaultOptions = [{
7465
7459
  enforceAssignment: true,
@@ -7507,7 +7501,7 @@ function create(context) {
7507
7501
  if (enforceLazyInitialization) {
7508
7502
  const [useStateInput] = node.arguments;
7509
7503
  if (useStateInput != null) {
7510
- for (const expr of getNestedNewExpressions(useStateInput)) {
7504
+ for (const expr of getNewExpressions(useStateInput)) {
7511
7505
  if (!hasProperty(expr.callee, "name")) continue;
7512
7506
  if (LAZY_INIT_ALLOW_LIST.includes(expr.callee.name)) continue;
7513
7507
  if (Traverse.hasParent(expr, core.isUseCall(context))) continue;
@@ -7516,7 +7510,7 @@ function create(context) {
7516
7510
  node: expr
7517
7511
  });
7518
7512
  }
7519
- for (const expr of getNestedCallExpressions(useStateInput)) {
7513
+ for (const expr of getCallExpressions(useStateInput)) {
7520
7514
  if (!hasProperty(expr.callee, "name")) continue;
7521
7515
  if (core.isHookName(expr.callee.name)) continue;
7522
7516
  if (LAZY_INIT_ALLOW_LIST.includes(expr.callee.name)) continue;
@@ -7579,8 +7573,7 @@ function create(context) {
7579
7573
  });
7580
7574
  } };
7581
7575
  }
7582
- //#endregion
7583
- //#region src/plugin.ts
7576
+ // src/plugin.ts
7584
7577
  const plugin = {
7585
7578
  meta: {
7586
7579
  name: name$6,
@@ -7642,8 +7635,7 @@ const plugin = {
7642
7635
  "use-state": use_state_default
7643
7636
  }
7644
7637
  };
7645
- //#endregion
7646
- //#region src/configs/recommended.ts
7638
+ // src/configs/recommended.ts
7647
7639
  var recommended_exports = /* @__PURE__ */ __exportAll({
7648
7640
  name: () => name$5,
7649
7641
  plugins: () => plugins$5,
@@ -7692,8 +7684,7 @@ const rules$5 = {
7692
7684
  };
7693
7685
  const plugins$5 = { "react-x": plugin };
7694
7686
  const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
7695
- //#endregion
7696
- //#region src/configs/recommended-typescript.ts
7687
+ // src/configs/recommended-typescript.ts
7697
7688
  var recommended_typescript_exports = /* @__PURE__ */ __exportAll({
7698
7689
  name: () => name$4,
7699
7690
  plugins: () => plugins$4,
@@ -7704,8 +7695,7 @@ const name$4 = "react-x/recommended-typescript";
7704
7695
  const rules$4 = { ...rules$5 };
7705
7696
  const plugins$4 = { ...plugins$5 };
7706
7697
  const settings$4 = { ...settings$5 };
7707
- //#endregion
7708
- //#region src/configs/recommended-type-checked.ts
7698
+ // src/configs/recommended-type-checked.ts
7709
7699
  var recommended_type_checked_exports = /* @__PURE__ */ __exportAll({
7710
7700
  name: () => name$3,
7711
7701
  plugins: () => plugins$3,
@@ -7719,8 +7709,7 @@ const rules$3 = {
7719
7709
  };
7720
7710
  const plugins$3 = { ...plugins$4 };
7721
7711
  const settings$3 = { ...settings$4 };
7722
- //#endregion
7723
- //#region src/configs/strict.ts
7712
+ // src/configs/strict.ts
7724
7713
  var strict_exports = /* @__PURE__ */ __exportAll({
7725
7714
  name: () => name$2,
7726
7715
  plugins: () => plugins$2,
@@ -7737,8 +7726,7 @@ const rules$2 = {
7737
7726
  };
7738
7727
  const plugins$2 = { ...plugins$5 };
7739
7728
  const settings$2 = { ...settings$5 };
7740
- //#endregion
7741
- //#region src/configs/strict-typescript.ts
7729
+ // src/configs/strict-typescript.ts
7742
7730
  var strict_typescript_exports = /* @__PURE__ */ __exportAll({
7743
7731
  name: () => name$1,
7744
7732
  plugins: () => plugins$1,
@@ -7749,8 +7737,7 @@ const name$1 = "react-x/strict-typescript";
7749
7737
  const rules$1 = { ...rules$2 };
7750
7738
  const plugins$1 = { ...plugins$2 };
7751
7739
  const settings$1 = { ...settings$2 };
7752
- //#endregion
7753
- //#region src/configs/strict-type-checked.ts
7740
+ // src/configs/strict-type-checked.ts
7754
7741
  var strict_type_checked_exports = /* @__PURE__ */ __exportAll({
7755
7742
  name: () => name,
7756
7743
  plugins: () => plugins,
@@ -7765,8 +7752,7 @@ const rules = {
7765
7752
  };
7766
7753
  const plugins = { ...plugins$1 };
7767
7754
  const settings = { ...settings$1 };
7768
- //#endregion
7769
- //#region src/index.ts
7755
+ // src/index.ts
7770
7756
  function createConfig(base) {
7771
7757
  return {
7772
7758
  ...base,
@@ -7793,5 +7779,4 @@ const finalPlugin = {
7793
7779
  ["strict-typescript"]: createConfig(strict_typescript_exports)
7794
7780
  }
7795
7781
  };
7796
- //#endregion
7797
7782
  export { finalPlugin as default };