eslint-plugin-react-x 3.0.0-next.2 → 3.0.0-next.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +878 -494
  2. package/package.json +11 -10
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { ESLintUtils } from "@typescript-eslint/utils";
5
5
  import { P, isMatching, match } from "ts-pattern";
6
6
  import ts from "typescript";
7
7
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
8
- import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectType, getVariableDefinitionNode, isAssignmentTargetEqual } from "@eslint-react/var";
8
+ import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectType, getVariableInitializer, isAssignmentTargetEqual } from "@eslint-react/var";
9
9
  import { DefinitionType } from "@typescript-eslint/scope-manager";
10
10
  import { constFalse, constTrue, constVoid, flow, getOrElseUpdate, identity, not, unit } from "@eslint-react/eff";
11
11
  import { compare } from "compare-versions";
@@ -13,6 +13,7 @@ import { getConstrainedTypeAtLocation, isTypeReadonly } from "@typescript-eslint
13
13
  import { isPropertyReadonlyInType, unionConstituents } from "ts-api-utils";
14
14
  import { getStaticValue, isIdentifier, isVariableDeclarator } from "@typescript-eslint/utils/ast-utils";
15
15
  import { getTypeImmutability, isImmutable, isReadonlyDeep, isReadonlyShallow, isUnknown } from "is-immutable-type";
16
+ import { snakeCase } from "string-ts";
16
17
 
17
18
  //#region \0rolldown/runtime.js
18
19
  var __defProp = Object.defineProperty;
@@ -38,15 +39,18 @@ var disable_experimental_exports = /* @__PURE__ */ __exportAll({
38
39
  });
39
40
  const name$8 = "react-x/disable-experimental";
40
41
  const rules$8 = {
42
+ "react-x/exhaustive-deps": "off",
41
43
  "react-x/jsx-key-before-spread": "off",
42
- "react-x/jsx-no-iife": "off",
43
44
  "react-x/no-duplicate-key": "off",
44
45
  "react-x/no-implicit-key": "off",
45
46
  "react-x/no-misused-capture-owner-stack": "off",
46
47
  "react-x/no-unnecessary-use-callback": "off",
47
48
  "react-x/no-unnecessary-use-memo": "off",
48
49
  "react-x/no-unused-props": "off",
49
- "react-x/prefer-read-only-props": "off"
50
+ "react-x/prefer-read-only-props": "off",
51
+ "react-x/refs": "off",
52
+ "react-x/rules-of-hooks": "off",
53
+ "react-x/set-state-in-render": "off"
50
54
  };
51
55
 
52
56
  //#endregion
@@ -66,7 +70,7 @@ const rules$7 = {
66
70
  //#endregion
67
71
  //#region package.json
68
72
  var name$6 = "eslint-plugin-react-x";
69
- var version = "3.0.0-next.2";
73
+ var version = "3.0.0-next.20";
70
74
 
71
75
  //#endregion
72
76
  //#region src/utils/create-rule.ts
@@ -136,7 +140,6 @@ function getFullyQualifiedNameEx(checker, symbol) {
136
140
  let name = symbol.name;
137
141
  let parent = symbol.declarations?.at(0)?.parent;
138
142
  if (parent == null) return checker.getFullyQualifiedName(symbol);
139
- const namespace = parent.getSourceFile().statements.find((n) => ts.isNamespaceExportDeclaration(n));
140
143
  while (parent.kind !== ts.SyntaxKind.SourceFile) {
141
144
  switch (true) {
142
145
  case ts.isInterfaceDeclaration(parent):
@@ -168,11 +171,14 @@ function getFullyQualifiedNameEx(checker, symbol) {
168
171
  case ts.isObjectLiteralExpression(parent):
169
172
  case ts.isIntersectionTypeNode(parent):
170
173
  case ts.isUnionTypeNode(parent): break;
174
+ default: break;
171
175
  }
172
176
  parent = parent.parent;
173
177
  }
174
- if (namespace != null) return `${namespace.name.text}.${name}`;
175
- return name;
178
+ const namespace = parent.getSourceFile().statements.find((n) => ts.isNamespaceExportDeclaration(n))?.name.text;
179
+ if (namespace == null) return name;
180
+ if (name.startsWith(`${namespace}.`)) return name;
181
+ return `${namespace}.${name}`;
176
182
  }
177
183
 
178
184
  //#endregion
@@ -221,7 +227,7 @@ function getTypeVariants(types) {
221
227
 
222
228
  //#endregion
223
229
  //#region src/rules/component-hook-factories.ts
224
- const RULE_NAME$64 = "component-hook-factories";
230
+ const RULE_NAME$66 = "component-hook-factories";
225
231
  var component_hook_factories_default = createRule({
226
232
  meta: {
227
233
  type: "problem",
@@ -232,11 +238,11 @@ var component_hook_factories_default = createRule({
232
238
  },
233
239
  schema: []
234
240
  },
235
- name: RULE_NAME$64,
236
- create: create$64,
241
+ name: RULE_NAME$66,
242
+ create: create$66,
237
243
  defaultOptions: []
238
244
  });
239
- function create$64(context) {
245
+ function create$66(context) {
240
246
  const hint = core.ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.ComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.ComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
241
247
  const fCollector = core.useComponentCollector(context, { hint });
242
248
  const cCollector = core.useComponentCollectorLegacy(context);
@@ -280,7 +286,7 @@ function create$64(context) {
280
286
 
281
287
  //#endregion
282
288
  //#region src/rules/error-boundaries.ts
283
- const RULE_NAME$63 = "error-boundaries";
289
+ const RULE_NAME$65 = "error-boundaries";
284
290
  var error_boundaries_default = createRule({
285
291
  meta: {
286
292
  type: "problem",
@@ -291,11 +297,11 @@ var error_boundaries_default = createRule({
291
297
  },
292
298
  schema: []
293
299
  },
294
- name: RULE_NAME$63,
295
- create: create$63,
300
+ name: RULE_NAME$65,
301
+ create: create$65,
296
302
  defaultOptions: []
297
303
  });
298
- function create$63(context) {
304
+ function create$65(context) {
299
305
  if (!context.sourceCode.text.includes("try")) return {};
300
306
  const { ctx, visitor } = core.useComponentCollector(context);
301
307
  const reported = /* @__PURE__ */ new Set();
@@ -329,7 +335,7 @@ function create$63(context) {
329
335
 
330
336
  //#endregion
331
337
  //#region src/rules/exhaustive-deps.ts
332
- const RULE_NAME$62 = "exhaustive-deps";
338
+ const RULE_NAME$64 = "exhaustive-deps";
333
339
  /**
334
340
  * Built-in hooks that accept dependency arrays.
335
341
  * Maps hook name to the index of the callback argument.
@@ -508,11 +514,11 @@ var exhaustive_deps_default = createRule({
508
514
  properties: { additionalHooks: { type: "string" } }
509
515
  }]
510
516
  },
511
- name: RULE_NAME$62,
512
- create: create$62,
517
+ name: RULE_NAME$64,
518
+ create: create$64,
513
519
  defaultOptions: [{}]
514
520
  });
515
- function create$62(context) {
521
+ function create$64(context) {
516
522
  const additionalHooks = context.options[0]?.additionalHooks;
517
523
  const additionalHooksRegex = additionalHooks != null && additionalHooks.length > 0 ? new RegExp(additionalHooks) : null;
518
524
  /** Collected hook calls for later analysis. */
@@ -692,7 +698,7 @@ function create$62(context) {
692
698
  });
693
699
  }
694
700
  }
695
- return {
701
+ return defineRuleListener({
696
702
  CallExpression(node) {
697
703
  if (!isHookWithDeps(node)) return;
698
704
  const hookName = getHookName$1(node);
@@ -719,12 +725,12 @@ function create$62(context) {
719
725
  "Program:exit"() {
720
726
  for (const hookCall of collectedHookCalls) analyzeHookCall(hookCall);
721
727
  }
722
- };
728
+ });
723
729
  }
724
730
 
725
731
  //#endregion
726
732
  //#region src/rules/jsx-dollar.ts
727
- const RULE_NAME$61 = "jsx-dollar";
733
+ const RULE_NAME$63 = "jsx-dollar";
728
734
  var jsx_dollar_default = createRule({
729
735
  meta: {
730
736
  type: "problem",
@@ -737,11 +743,11 @@ var jsx_dollar_default = createRule({
737
743
  },
738
744
  schema: []
739
745
  },
740
- name: RULE_NAME$61,
741
- create: create$61,
746
+ name: RULE_NAME$63,
747
+ create: create$63,
742
748
  defaultOptions: []
743
749
  });
744
- function create$61(context) {
750
+ function create$63(context) {
745
751
  /**
746
752
  * Visitor function for JSXElement and JSXFragment nodes
747
753
  * @param node The JSXElement or JSXFragment node to be checked
@@ -774,15 +780,15 @@ function create$61(context) {
774
780
  });
775
781
  }
776
782
  };
777
- return {
783
+ return defineRuleListener({
778
784
  JSXElement: visitorFunction,
779
785
  JSXFragment: visitorFunction
780
- };
786
+ });
781
787
  }
782
788
 
783
789
  //#endregion
784
790
  //#region src/rules/jsx-key-before-spread.ts
785
- const RULE_NAME$60 = "jsx-key-before-spread";
791
+ const RULE_NAME$62 = "jsx-key-before-spread";
786
792
  var jsx_key_before_spread_default = createRule({
787
793
  meta: {
788
794
  type: "problem",
@@ -790,17 +796,17 @@ var jsx_key_before_spread_default = createRule({
790
796
  messages: { default: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
791
797
  schema: []
792
798
  },
793
- name: RULE_NAME$60,
794
- create: create$60,
799
+ name: RULE_NAME$62,
800
+ create: create$62,
795
801
  defaultOptions: []
796
802
  });
797
- function create$60(context) {
803
+ function create$62(context) {
798
804
  const { jsx } = {
799
805
  ...core.getJsxConfigFromContext(context),
800
806
  ...core.getJsxConfigFromAnnotation(context)
801
807
  };
802
808
  if (jsx !== core.JsxEmit.ReactJSX && jsx !== core.JsxEmit.ReactJSXDev) return {};
803
- return { JSXOpeningElement(node) {
809
+ return defineRuleListener({ JSXOpeningElement(node) {
804
810
  let firstSpreadPropIndex = null;
805
811
  for (const [index, prop] of node.attributes.entries()) {
806
812
  if (prop.type === AST_NODE_TYPES.JSXSpreadAttribute) {
@@ -813,12 +819,12 @@ function create$60(context) {
813
819
  node: prop
814
820
  });
815
821
  }
816
- } };
822
+ } });
817
823
  }
818
824
 
819
825
  //#endregion
820
826
  //#region src/rules/jsx-no-comment-textnodes.ts
821
- const RULE_NAME$59 = "jsx-no-comment-textnodes";
827
+ const RULE_NAME$61 = "jsx-no-comment-textnodes";
822
828
  var jsx_no_comment_textnodes_default = createRule({
823
829
  meta: {
824
830
  type: "problem",
@@ -826,11 +832,11 @@ var jsx_no_comment_textnodes_default = createRule({
826
832
  messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
827
833
  schema: []
828
834
  },
829
- name: RULE_NAME$59,
830
- create: create$59,
835
+ name: RULE_NAME$61,
836
+ create: create$61,
831
837
  defaultOptions: []
832
838
  });
833
- function create$59(context) {
839
+ function create$61(context) {
834
840
  function hasCommentLike(node) {
835
841
  if (ast.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
836
842
  return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
@@ -843,15 +849,15 @@ function create$59(context) {
843
849
  node
844
850
  });
845
851
  };
846
- return {
852
+ return defineRuleListener({
847
853
  JSXText: visitorFunction,
848
854
  Literal: visitorFunction
849
- };
855
+ });
850
856
  }
851
857
 
852
858
  //#endregion
853
859
  //#region src/rules/jsx-no-duplicate-props.ts
854
- const RULE_NAME$58 = "jsx-no-duplicate-props";
860
+ const RULE_NAME$60 = "jsx-no-duplicate-props";
855
861
  var jsx_no_duplicate_props_default = createRule({
856
862
  meta: {
857
863
  type: "problem",
@@ -859,12 +865,12 @@ var jsx_no_duplicate_props_default = createRule({
859
865
  messages: { default: "This JSX property is assigned multiple times." },
860
866
  schema: []
861
867
  },
862
- name: RULE_NAME$58,
863
- create: create$58,
868
+ name: RULE_NAME$60,
869
+ create: create$60,
864
870
  defaultOptions: []
865
871
  });
866
- function create$58(context) {
867
- return { JSXOpeningElement(node) {
872
+ function create$60(context) {
873
+ return defineRuleListener({ JSXOpeningElement(node) {
868
874
  const props = [];
869
875
  for (const attr of node.attributes) {
870
876
  if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
@@ -879,43 +885,12 @@ function create$58(context) {
879
885
  node: attr
880
886
  });
881
887
  }
882
- } };
883
- }
884
-
885
- //#endregion
886
- //#region src/rules/jsx-no-iife.ts
887
- const RULE_NAME$57 = "jsx-no-iife";
888
- var jsx_no_iife_default = createRule({
889
- meta: {
890
- type: "problem",
891
- docs: { description: "Disallows immediately-invoked function expressions in JSX." },
892
- messages: { default: "Avoid using immediately-invoked function expressions in JSX." },
893
- schema: []
894
- },
895
- name: RULE_NAME$57,
896
- create: create$57,
897
- defaultOptions: []
898
- });
899
- function create$57(context) {
900
- return {
901
- "JSXElement :function"(node) {
902
- if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) context.report({
903
- messageId: "default",
904
- node: node.parent
905
- });
906
- },
907
- "JSXFragment :function"(node) {
908
- if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) context.report({
909
- messageId: "default",
910
- node: node.parent
911
- });
912
- }
913
- };
888
+ } });
914
889
  }
915
890
 
916
891
  //#endregion
917
892
  //#region src/rules/jsx-no-undef.ts
918
- const RULE_NAME$56 = "jsx-no-undef";
893
+ const RULE_NAME$59 = "jsx-no-undef";
919
894
  var jsx_no_undef_default = createRule({
920
895
  meta: {
921
896
  type: "problem",
@@ -923,12 +898,12 @@ var jsx_no_undef_default = createRule({
923
898
  messages: { default: "JSX variable '{{name}}' is not defined." },
924
899
  schema: []
925
900
  },
926
- name: RULE_NAME$56,
927
- create: create$56,
901
+ name: RULE_NAME$59,
902
+ create: create$59,
928
903
  defaultOptions: []
929
904
  });
930
- function create$56(context) {
931
- return { JSXOpeningElement(node) {
905
+ function create$59(context) {
906
+ return defineRuleListener({ JSXOpeningElement(node) {
932
907
  const name = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({
933
908
  type: AST_NODE_TYPES.JSXMemberExpression,
934
909
  object: { type: AST_NODE_TYPES.JSXIdentifier }
@@ -941,14 +916,14 @@ function create$56(context) {
941
916
  node,
942
917
  data: { name }
943
918
  });
944
- } };
919
+ } });
945
920
  }
946
921
 
947
922
  //#endregion
948
923
  //#region src/rules/jsx-shorthand-boolean.ts
949
- const RULE_NAME$55 = "jsx-shorthand-boolean";
950
- const defaultOptions$3 = [1];
951
- const schema$3 = [{
924
+ const RULE_NAME$58 = "jsx-shorthand-boolean";
925
+ const defaultOptions$4 = [1];
926
+ const schema$4 = [{
952
927
  type: "integer",
953
928
  enum: [-1, 1]
954
929
  }];
@@ -958,15 +933,15 @@ var jsx_shorthand_boolean_default = createRule({
958
933
  docs: { description: "Enforces shorthand syntax for boolean props." },
959
934
  fixable: "code",
960
935
  messages: { default: "{{message}}" },
961
- schema: schema$3
936
+ schema: schema$4
962
937
  },
963
- name: RULE_NAME$55,
964
- create: create$55,
965
- defaultOptions: defaultOptions$3
938
+ name: RULE_NAME$58,
939
+ create: create$58,
940
+ defaultOptions: defaultOptions$4
966
941
  });
967
- function create$55(context) {
968
- const policy = context.options[0] ?? defaultOptions$3[0];
969
- return { JSXAttribute(node) {
942
+ function create$58(context) {
943
+ const policy = context.options[0] ?? defaultOptions$4[0];
944
+ return defineRuleListener({ JSXAttribute(node) {
970
945
  const { value } = node;
971
946
  const propName = core.getJsxAttributeName(context, node);
972
947
  switch (true) {
@@ -987,14 +962,14 @@ function create$55(context) {
987
962
  });
988
963
  break;
989
964
  }
990
- } };
965
+ } });
991
966
  }
992
967
 
993
968
  //#endregion
994
969
  //#region src/rules/jsx-shorthand-fragment.ts
995
- const RULE_NAME$54 = "jsx-shorthand-fragment";
996
- const defaultOptions$2 = [1];
997
- const schema$2 = [{
970
+ const RULE_NAME$57 = "jsx-shorthand-fragment";
971
+ const defaultOptions$3 = [1];
972
+ const schema$3 = [{
998
973
  type: "integer",
999
974
  enum: [-1, 1]
1000
975
  }];
@@ -1004,20 +979,20 @@ var jsx_shorthand_fragment_default = createRule({
1004
979
  docs: { description: "Enforces shorthand syntax for fragment elements." },
1005
980
  fixable: "code",
1006
981
  messages: { default: "{{message}}" },
1007
- schema: schema$2
982
+ schema: schema$3
1008
983
  },
1009
- name: RULE_NAME$54,
1010
- create: create$54,
1011
- defaultOptions: defaultOptions$2
984
+ name: RULE_NAME$57,
985
+ create: create$57,
986
+ defaultOptions: defaultOptions$3
1012
987
  });
1013
- function create$54(context) {
1014
- const policy = context.options[0] ?? defaultOptions$2[0];
988
+ function create$57(context) {
989
+ const policy = context.options[0] ?? defaultOptions$3[0];
1015
990
  const jsxConfig = {
1016
991
  ...core.getJsxConfigFromContext(context),
1017
992
  ...core.getJsxConfigFromAnnotation(context)
1018
993
  };
1019
994
  const { jsxFragmentFactory } = jsxConfig;
1020
- return match(policy).with(1, () => ({ JSXElement(node) {
995
+ return match(policy).with(1, () => defineRuleListener({ JSXElement(node) {
1021
996
  if (!core.isJsxFragmentElement(context, node, jsxConfig)) return;
1022
997
  if (node.openingElement.attributes.length > 0) return;
1023
998
  context.report({
@@ -1030,7 +1005,7 @@ function create$54(context) {
1030
1005
  return [fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"), fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")];
1031
1006
  }
1032
1007
  });
1033
- } })).with(-1, () => ({ JSXFragment(node) {
1008
+ } })).with(-1, () => defineRuleListener({ JSXFragment(node) {
1034
1009
  context.report({
1035
1010
  messageId: "default",
1036
1011
  node,
@@ -1045,7 +1020,7 @@ function create$54(context) {
1045
1020
 
1046
1021
  //#endregion
1047
1022
  //#region src/rules/jsx-uses-react.ts
1048
- const RULE_NAME$53 = "jsx-uses-react";
1023
+ const RULE_NAME$56 = "jsx-uses-react";
1049
1024
  var jsx_uses_react_default = createRule({
1050
1025
  meta: {
1051
1026
  type: "problem",
@@ -1053,11 +1028,11 @@ var jsx_uses_react_default = createRule({
1053
1028
  messages: { default: "Marked {{name}} as used." },
1054
1029
  schema: []
1055
1030
  },
1056
- name: RULE_NAME$53,
1057
- create: create$53,
1031
+ name: RULE_NAME$56,
1032
+ create: create$56,
1058
1033
  defaultOptions: []
1059
1034
  });
1060
- function create$53(context) {
1035
+ function create$56(context) {
1061
1036
  const { jsx, jsxFactory, jsxFragmentFactory } = {
1062
1037
  ...core.getJsxConfigFromContext(context),
1063
1038
  ...core.getJsxConfigFromAnnotation(context)
@@ -1071,11 +1046,11 @@ function create$53(context) {
1071
1046
  context.sourceCode.markVariableAsUsed(jsxFragmentFactory, node);
1072
1047
  debugReport(context, node, jsxFragmentFactory);
1073
1048
  }
1074
- return {
1049
+ return defineRuleListener({
1075
1050
  JSXFragment: handleJsxFragment,
1076
1051
  JSXOpeningElement: handleJsxElement,
1077
1052
  JSXOpeningFragment: handleJsxElement
1078
- };
1053
+ });
1079
1054
  }
1080
1055
  function debugReport(context, node, name) {
1081
1056
  if (process.env["ESLINT_REACT_DEBUG"] !== "1") return;
@@ -1088,7 +1063,7 @@ function debugReport(context, node, name) {
1088
1063
 
1089
1064
  //#endregion
1090
1065
  //#region src/rules/jsx-uses-vars.ts
1091
- const RULE_NAME$52 = "jsx-uses-vars";
1066
+ const RULE_NAME$55 = "jsx-uses-vars";
1092
1067
  var jsx_uses_vars_default = createRule({
1093
1068
  meta: {
1094
1069
  type: "problem",
@@ -1096,12 +1071,12 @@ var jsx_uses_vars_default = createRule({
1096
1071
  messages: { default: "An identifier in JSX is marked as used." },
1097
1072
  schema: []
1098
1073
  },
1099
- name: RULE_NAME$52,
1100
- create: create$52,
1074
+ name: RULE_NAME$55,
1075
+ create: create$55,
1101
1076
  defaultOptions: []
1102
1077
  });
1103
- function create$52(context) {
1104
- return { JSXOpeningElement(node) {
1078
+ function create$55(context) {
1079
+ return defineRuleListener({ JSXOpeningElement(node) {
1105
1080
  switch (node.name.type) {
1106
1081
  case AST_NODE_TYPES.JSXIdentifier:
1107
1082
  if (/^[a-z]/u.test(node.name.name)) return;
@@ -1113,12 +1088,12 @@ function create$52(context) {
1113
1088
  break;
1114
1089
  }
1115
1090
  }
1116
- } };
1091
+ } });
1117
1092
  }
1118
1093
 
1119
1094
  //#endregion
1120
1095
  //#region src/rules/no-access-state-in-setstate.ts
1121
- const RULE_NAME$51 = "no-access-state-in-setstate";
1096
+ const RULE_NAME$54 = "no-access-state-in-setstate";
1122
1097
  function isKeyLiteral$2(node, key) {
1123
1098
  return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
1124
1099
  type: AST_NODE_TYPES.TemplateLiteral,
@@ -1132,16 +1107,16 @@ var no_access_state_in_setstate_default = createRule({
1132
1107
  messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
1133
1108
  schema: []
1134
1109
  },
1135
- name: RULE_NAME$51,
1136
- create: create$51,
1110
+ name: RULE_NAME$54,
1111
+ create: create$54,
1137
1112
  defaultOptions: []
1138
1113
  });
1139
- function create$51(context) {
1114
+ function create$54(context) {
1140
1115
  if (!context.sourceCode.text.includes("setState")) return {};
1141
1116
  const classStack = [];
1142
1117
  const methodStack = [];
1143
1118
  const setStateStack = [];
1144
- return {
1119
+ return defineRuleListener({
1145
1120
  CallExpression(node) {
1146
1121
  if (!core.isThisSetState(node)) return;
1147
1122
  setStateStack.push([node, false]);
@@ -1202,12 +1177,12 @@ function create$51(context) {
1202
1177
  node
1203
1178
  });
1204
1179
  }
1205
- };
1180
+ });
1206
1181
  }
1207
1182
 
1208
1183
  //#endregion
1209
1184
  //#region src/rules/no-array-index-key.ts
1210
- const RULE_NAME$50 = "no-array-index-key";
1185
+ const RULE_NAME$53 = "no-array-index-key";
1211
1186
  const REACT_CHILDREN_METHOD = ["forEach", "map"];
1212
1187
  function getIndexParamPosition(methodName) {
1213
1188
  switch (methodName) {
@@ -1266,11 +1241,11 @@ var no_array_index_key_default = createRule({
1266
1241
  messages: { default: "Do not use item index in the array as its key." },
1267
1242
  schema: []
1268
1243
  },
1269
- name: RULE_NAME$50,
1270
- create: create$50,
1244
+ name: RULE_NAME$53,
1245
+ create: create$53,
1271
1246
  defaultOptions: []
1272
1247
  });
1273
- function create$50(context) {
1248
+ function create$53(context) {
1274
1249
  const indexParamNames = [];
1275
1250
  function isArrayIndex(node) {
1276
1251
  return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name) => name != null && name === node.name);
@@ -1309,7 +1284,7 @@ function create$50(context) {
1309
1284
  }
1310
1285
  return [];
1311
1286
  }
1312
- return {
1287
+ return defineRuleListener({
1313
1288
  CallExpression(node) {
1314
1289
  indexParamNames.push(getMapIndexParamName(context, node));
1315
1290
  if (node.arguments.length === 0) return;
@@ -1331,12 +1306,12 @@ function create$50(context) {
1331
1306
  if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
1332
1307
  for (const descriptor of getReportDescriptors(node.value.expression)) report(context)(descriptor);
1333
1308
  }
1334
- };
1309
+ });
1335
1310
  }
1336
1311
 
1337
1312
  //#endregion
1338
1313
  //#region src/rules/no-children-count.ts
1339
- const RULE_NAME$49 = "no-children-count";
1314
+ const RULE_NAME$52 = "no-children-count";
1340
1315
  var no_children_count_default = createRule({
1341
1316
  meta: {
1342
1317
  type: "problem",
@@ -1344,22 +1319,22 @@ var no_children_count_default = createRule({
1344
1319
  messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
1345
1320
  schema: []
1346
1321
  },
1347
- name: RULE_NAME$49,
1348
- create: create$49,
1322
+ name: RULE_NAME$52,
1323
+ create: create$52,
1349
1324
  defaultOptions: []
1350
1325
  });
1351
- function create$49(context) {
1352
- return { MemberExpression(node) {
1326
+ function create$52(context) {
1327
+ return defineRuleListener({ MemberExpression(node) {
1353
1328
  if (core.isChildrenCount(context, node)) context.report({
1354
1329
  messageId: "default",
1355
1330
  node: node.property
1356
1331
  });
1357
- } };
1332
+ } });
1358
1333
  }
1359
1334
 
1360
1335
  //#endregion
1361
1336
  //#region src/rules/no-children-for-each.ts
1362
- const RULE_NAME$48 = "no-children-for-each";
1337
+ const RULE_NAME$51 = "no-children-for-each";
1363
1338
  var no_children_for_each_default = createRule({
1364
1339
  meta: {
1365
1340
  type: "problem",
@@ -1367,22 +1342,22 @@ var no_children_for_each_default = createRule({
1367
1342
  messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
1368
1343
  schema: []
1369
1344
  },
1370
- name: RULE_NAME$48,
1371
- create: create$48,
1345
+ name: RULE_NAME$51,
1346
+ create: create$51,
1372
1347
  defaultOptions: []
1373
1348
  });
1374
- function create$48(context) {
1375
- return { MemberExpression(node) {
1349
+ function create$51(context) {
1350
+ return defineRuleListener({ MemberExpression(node) {
1376
1351
  if (core.isChildrenForEach(context, node)) context.report({
1377
1352
  messageId: "default",
1378
1353
  node: node.property
1379
1354
  });
1380
- } };
1355
+ } });
1381
1356
  }
1382
1357
 
1383
1358
  //#endregion
1384
1359
  //#region src/rules/no-children-map.ts
1385
- const RULE_NAME$47 = "no-children-map";
1360
+ const RULE_NAME$50 = "no-children-map";
1386
1361
  var no_children_map_default = createRule({
1387
1362
  meta: {
1388
1363
  type: "problem",
@@ -1390,22 +1365,22 @@ var no_children_map_default = createRule({
1390
1365
  messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
1391
1366
  schema: []
1392
1367
  },
1393
- name: RULE_NAME$47,
1394
- create: create$47,
1368
+ name: RULE_NAME$50,
1369
+ create: create$50,
1395
1370
  defaultOptions: []
1396
1371
  });
1397
- function create$47(context) {
1398
- return { MemberExpression(node) {
1372
+ function create$50(context) {
1373
+ return defineRuleListener({ MemberExpression(node) {
1399
1374
  if (core.isChildrenMap(context, node)) context.report({
1400
1375
  messageId: "default",
1401
1376
  node: node.property
1402
1377
  });
1403
- } };
1378
+ } });
1404
1379
  }
1405
1380
 
1406
1381
  //#endregion
1407
1382
  //#region src/rules/no-children-only.ts
1408
- const RULE_NAME$46 = "no-children-only";
1383
+ const RULE_NAME$49 = "no-children-only";
1409
1384
  var no_children_only_default = createRule({
1410
1385
  meta: {
1411
1386
  type: "problem",
@@ -1413,22 +1388,22 @@ var no_children_only_default = createRule({
1413
1388
  messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
1414
1389
  schema: []
1415
1390
  },
1416
- name: RULE_NAME$46,
1417
- create: create$46,
1391
+ name: RULE_NAME$49,
1392
+ create: create$49,
1418
1393
  defaultOptions: []
1419
1394
  });
1420
- function create$46(context) {
1421
- return { MemberExpression(node) {
1395
+ function create$49(context) {
1396
+ return defineRuleListener({ MemberExpression(node) {
1422
1397
  if (core.isChildrenOnly(context, node)) context.report({
1423
1398
  messageId: "default",
1424
1399
  node: node.property
1425
1400
  });
1426
- } };
1401
+ } });
1427
1402
  }
1428
1403
 
1429
1404
  //#endregion
1430
1405
  //#region src/rules/no-children-prop.ts
1431
- const RULE_NAME$45 = "no-children-prop";
1406
+ const RULE_NAME$48 = "no-children-prop";
1432
1407
  var no_children_prop_default = createRule({
1433
1408
  meta: {
1434
1409
  type: "problem",
@@ -1436,23 +1411,23 @@ var no_children_prop_default = createRule({
1436
1411
  messages: { default: "Do not pass 'children' as props." },
1437
1412
  schema: []
1438
1413
  },
1439
- name: RULE_NAME$45,
1440
- create: create$45,
1414
+ name: RULE_NAME$48,
1415
+ create: create$48,
1441
1416
  defaultOptions: []
1442
1417
  });
1443
- function create$45(context) {
1444
- return { JSXElement(node) {
1418
+ function create$48(context) {
1419
+ return defineRuleListener({ JSXElement(node) {
1445
1420
  const childrenProp = core.getJsxAttribute(context, node)("children");
1446
1421
  if (childrenProp != null) context.report({
1447
1422
  messageId: "default",
1448
1423
  node: childrenProp
1449
1424
  });
1450
- } };
1425
+ } });
1451
1426
  }
1452
1427
 
1453
1428
  //#endregion
1454
1429
  //#region src/rules/no-children-to-array.ts
1455
- const RULE_NAME$44 = "no-children-to-array";
1430
+ const RULE_NAME$47 = "no-children-to-array";
1456
1431
  var no_children_to_array_default = createRule({
1457
1432
  meta: {
1458
1433
  type: "problem",
@@ -1460,22 +1435,22 @@ var no_children_to_array_default = createRule({
1460
1435
  messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
1461
1436
  schema: []
1462
1437
  },
1463
- name: RULE_NAME$44,
1464
- create: create$44,
1438
+ name: RULE_NAME$47,
1439
+ create: create$47,
1465
1440
  defaultOptions: []
1466
1441
  });
1467
- function create$44(context) {
1468
- return { MemberExpression(node) {
1442
+ function create$47(context) {
1443
+ return defineRuleListener({ MemberExpression(node) {
1469
1444
  if (core.isChildrenToArray(context, node)) context.report({
1470
1445
  messageId: "default",
1471
1446
  node: node.property
1472
1447
  });
1473
- } };
1448
+ } });
1474
1449
  }
1475
1450
 
1476
1451
  //#endregion
1477
1452
  //#region src/rules/no-class-component.ts
1478
- const RULE_NAME$43 = "no-class-component";
1453
+ const RULE_NAME$46 = "no-class-component";
1479
1454
  var no_class_component_default = createRule({
1480
1455
  meta: {
1481
1456
  type: "problem",
@@ -1483,11 +1458,11 @@ var no_class_component_default = createRule({
1483
1458
  messages: { default: "Avoid using class components. Use function components instead." },
1484
1459
  schema: []
1485
1460
  },
1486
- name: RULE_NAME$43,
1487
- create: create$43,
1461
+ name: RULE_NAME$46,
1462
+ create: create$46,
1488
1463
  defaultOptions: []
1489
1464
  });
1490
- function create$43(context) {
1465
+ function create$46(context) {
1491
1466
  if (!context.sourceCode.text.includes("Component")) return {};
1492
1467
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
1493
1468
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -1504,7 +1479,7 @@ function create$43(context) {
1504
1479
 
1505
1480
  //#endregion
1506
1481
  //#region src/rules/no-clone-element.ts
1507
- const RULE_NAME$42 = "no-clone-element";
1482
+ const RULE_NAME$45 = "no-clone-element";
1508
1483
  var no_clone_element_default = createRule({
1509
1484
  meta: {
1510
1485
  type: "problem",
@@ -1512,22 +1487,22 @@ var no_clone_element_default = createRule({
1512
1487
  messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
1513
1488
  schema: []
1514
1489
  },
1515
- name: RULE_NAME$42,
1516
- create: create$42,
1490
+ name: RULE_NAME$45,
1491
+ create: create$45,
1517
1492
  defaultOptions: []
1518
1493
  });
1519
- function create$42(context) {
1520
- return { CallExpression(node) {
1494
+ function create$45(context) {
1495
+ return defineRuleListener({ CallExpression(node) {
1521
1496
  if (core.isCloneElementCall(context, node)) context.report({
1522
1497
  messageId: "default",
1523
1498
  node
1524
1499
  });
1525
- } };
1500
+ } });
1526
1501
  }
1527
1502
 
1528
1503
  //#endregion
1529
1504
  //#region src/rules/no-component-will-mount.ts
1530
- const RULE_NAME$41 = "no-component-will-mount";
1505
+ const RULE_NAME$44 = "no-component-will-mount";
1531
1506
  var no_component_will_mount_default = createRule({
1532
1507
  meta: {
1533
1508
  type: "problem",
@@ -1536,11 +1511,11 @@ var no_component_will_mount_default = createRule({
1536
1511
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
1537
1512
  schema: []
1538
1513
  },
1539
- name: RULE_NAME$41,
1540
- create: create$41,
1514
+ name: RULE_NAME$44,
1515
+ create: create$44,
1541
1516
  defaultOptions: []
1542
1517
  });
1543
- function create$41(context) {
1518
+ function create$44(context) {
1544
1519
  if (!context.sourceCode.text.includes("componentWillMount")) return {};
1545
1520
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
1546
1521
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -1560,7 +1535,7 @@ function create$41(context) {
1560
1535
 
1561
1536
  //#endregion
1562
1537
  //#region src/rules/no-component-will-receive-props.ts
1563
- const RULE_NAME$40 = "no-component-will-receive-props";
1538
+ const RULE_NAME$43 = "no-component-will-receive-props";
1564
1539
  var no_component_will_receive_props_default = createRule({
1565
1540
  meta: {
1566
1541
  type: "problem",
@@ -1569,11 +1544,11 @@ var no_component_will_receive_props_default = createRule({
1569
1544
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
1570
1545
  schema: []
1571
1546
  },
1572
- name: RULE_NAME$40,
1573
- create: create$40,
1547
+ name: RULE_NAME$43,
1548
+ create: create$43,
1574
1549
  defaultOptions: []
1575
1550
  });
1576
- function create$40(context) {
1551
+ function create$43(context) {
1577
1552
  if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
1578
1553
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
1579
1554
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -1593,7 +1568,7 @@ function create$40(context) {
1593
1568
 
1594
1569
  //#endregion
1595
1570
  //#region src/rules/no-component-will-update.ts
1596
- const RULE_NAME$39 = "no-component-will-update";
1571
+ const RULE_NAME$42 = "no-component-will-update";
1597
1572
  var no_component_will_update_default = createRule({
1598
1573
  meta: {
1599
1574
  type: "problem",
@@ -1602,11 +1577,11 @@ var no_component_will_update_default = createRule({
1602
1577
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
1603
1578
  schema: []
1604
1579
  },
1605
- name: RULE_NAME$39,
1606
- create: create$39,
1580
+ name: RULE_NAME$42,
1581
+ create: create$42,
1607
1582
  defaultOptions: []
1608
1583
  });
1609
- function create$39(context) {
1584
+ function create$42(context) {
1610
1585
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
1611
1586
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
1612
1587
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -1626,7 +1601,7 @@ function create$39(context) {
1626
1601
 
1627
1602
  //#endregion
1628
1603
  //#region src/rules/no-context-provider.ts
1629
- const RULE_NAME$38 = "no-context-provider";
1604
+ const RULE_NAME$41 = "no-context-provider";
1630
1605
  var no_context_provider_default = createRule({
1631
1606
  meta: {
1632
1607
  type: "problem",
@@ -1635,15 +1610,15 @@ var no_context_provider_default = createRule({
1635
1610
  messages: { default: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'." },
1636
1611
  schema: []
1637
1612
  },
1638
- name: RULE_NAME$38,
1639
- create: create$38,
1613
+ name: RULE_NAME$41,
1614
+ create: create$41,
1640
1615
  defaultOptions: []
1641
1616
  });
1642
- function create$38(context) {
1617
+ function create$41(context) {
1643
1618
  if (!context.sourceCode.text.includes("Provider")) return {};
1644
1619
  const { version } = getSettingsFromContext(context);
1645
1620
  if (compare(version, "19.0.0", "<")) return {};
1646
- return { JSXElement(node) {
1621
+ return defineRuleListener({ JSXElement(node) {
1647
1622
  const parts = core.getJsxElementType(context, node).split(".");
1648
1623
  const selfName = parts.pop();
1649
1624
  const contextFullName = parts.join(".");
@@ -1661,12 +1636,12 @@ function create$38(context) {
1661
1636
  return [fixer.replaceText(openingElement.name, contextFullName), fixer.replaceText(closingElement.name, contextFullName)];
1662
1637
  }
1663
1638
  });
1664
- } };
1639
+ } });
1665
1640
  }
1666
1641
 
1667
1642
  //#endregion
1668
1643
  //#region src/rules/no-create-ref.ts
1669
- const RULE_NAME$37 = "no-create-ref";
1644
+ const RULE_NAME$40 = "no-create-ref";
1670
1645
  var no_create_ref_default = createRule({
1671
1646
  meta: {
1672
1647
  type: "problem",
@@ -1674,22 +1649,22 @@ var no_create_ref_default = createRule({
1674
1649
  messages: { default: "[Deprecated] Use 'useRef' instead." },
1675
1650
  schema: []
1676
1651
  },
1677
- name: RULE_NAME$37,
1678
- create: create$37,
1652
+ name: RULE_NAME$40,
1653
+ create: create$40,
1679
1654
  defaultOptions: []
1680
1655
  });
1681
- function create$37(context) {
1682
- return { CallExpression(node) {
1656
+ function create$40(context) {
1657
+ return defineRuleListener({ CallExpression(node) {
1683
1658
  if (core.isCreateRefCall(context, node) && ast.findParentNode(node, core.isClassComponent) == null) context.report({
1684
1659
  messageId: "default",
1685
1660
  node
1686
1661
  });
1687
- } };
1662
+ } });
1688
1663
  }
1689
1664
 
1690
1665
  //#endregion
1691
1666
  //#region src/rules/no-direct-mutation-state.ts
1692
- const RULE_NAME$36 = "no-direct-mutation-state";
1667
+ const RULE_NAME$39 = "no-direct-mutation-state";
1693
1668
  function isConstructorFunction(node) {
1694
1669
  return ast.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && ast.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
1695
1670
  }
@@ -1700,12 +1675,12 @@ var no_direct_mutation_state_default = createRule({
1700
1675
  messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
1701
1676
  schema: []
1702
1677
  },
1703
- name: RULE_NAME$36,
1704
- create: create$36,
1678
+ name: RULE_NAME$39,
1679
+ create: create$39,
1705
1680
  defaultOptions: []
1706
1681
  });
1707
- function create$36(context) {
1708
- return { AssignmentExpression(node) {
1682
+ function create$39(context) {
1683
+ return defineRuleListener({ AssignmentExpression(node) {
1709
1684
  if (!core.isAssignmentToThisState(node)) return;
1710
1685
  const parentClass = ast.findParentNode(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
1711
1686
  if (parentClass == null) return;
@@ -1713,12 +1688,12 @@ function create$36(context) {
1713
1688
  messageId: "default",
1714
1689
  node
1715
1690
  });
1716
- } };
1691
+ } });
1717
1692
  }
1718
1693
 
1719
1694
  //#endregion
1720
1695
  //#region src/rules/no-duplicate-key.ts
1721
- const RULE_NAME$35 = "no-duplicate-key";
1696
+ const RULE_NAME$38 = "no-duplicate-key";
1722
1697
  var no_duplicate_key_default = createRule({
1723
1698
  meta: {
1724
1699
  type: "problem",
@@ -1726,11 +1701,11 @@ var no_duplicate_key_default = createRule({
1726
1701
  messages: { default: "The 'key' prop must be unique to its sibling elements." },
1727
1702
  schema: []
1728
1703
  },
1729
- name: RULE_NAME$35,
1730
- create: create$35,
1704
+ name: RULE_NAME$38,
1705
+ create: create$38,
1731
1706
  defaultOptions: []
1732
1707
  });
1733
- function create$35(context) {
1708
+ function create$38(context) {
1734
1709
  if (!context.sourceCode.text.includes("key=")) return {};
1735
1710
  const keyedEntries = /* @__PURE__ */ new Map();
1736
1711
  function isKeyValueEqual(a, b) {
@@ -1739,7 +1714,7 @@ function create$35(context) {
1739
1714
  if (aValue == null || bValue == null) return false;
1740
1715
  return ast.isNodeEqual(aValue, bValue);
1741
1716
  }
1742
- return {
1717
+ return defineRuleListener({
1743
1718
  "JSXAttribute[name.name='key']"(node) {
1744
1719
  const jsxElement = node.parent.parent;
1745
1720
  switch (jsxElement.parent.type) {
@@ -1780,12 +1755,12 @@ function create$35(context) {
1780
1755
  });
1781
1756
  }
1782
1757
  }
1783
- };
1758
+ });
1784
1759
  }
1785
1760
 
1786
1761
  //#endregion
1787
1762
  //#region src/rules/no-forward-ref.ts
1788
- const RULE_NAME$34 = "no-forward-ref";
1763
+ const RULE_NAME$37 = "no-forward-ref";
1789
1764
  var no_forward_ref_default = createRule({
1790
1765
  meta: {
1791
1766
  type: "problem",
@@ -1794,15 +1769,15 @@ var no_forward_ref_default = createRule({
1794
1769
  messages: { default: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead." },
1795
1770
  schema: []
1796
1771
  },
1797
- name: RULE_NAME$34,
1798
- create: create$34,
1772
+ name: RULE_NAME$37,
1773
+ create: create$37,
1799
1774
  defaultOptions: []
1800
1775
  });
1801
- function create$34(context) {
1776
+ function create$37(context) {
1802
1777
  if (!context.sourceCode.text.includes("forwardRef")) return {};
1803
1778
  const { version } = getSettingsFromContext(context);
1804
1779
  if (compare(version, "19.0.0", "<")) return {};
1805
- return { CallExpression(node) {
1780
+ return defineRuleListener({ CallExpression(node) {
1806
1781
  if (!core.isForwardRefCall(context, node)) return;
1807
1782
  const id = ast.getFunctionId(node);
1808
1783
  const fix = canFix(context, node) ? getFix(context, node) : null;
@@ -1811,7 +1786,7 @@ function create$34(context) {
1811
1786
  node: id ?? node,
1812
1787
  fix
1813
1788
  });
1814
- } };
1789
+ } });
1815
1790
  }
1816
1791
  /**
1817
1792
  * Determine whether the given CallExpression can be safely auto-fixed by replacing
@@ -1893,7 +1868,7 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
1893
1868
 
1894
1869
  //#endregion
1895
1870
  //#region src/rules/no-implicit-key.ts
1896
- const RULE_NAME$33 = "no-implicit-key";
1871
+ const RULE_NAME$36 = "no-implicit-key";
1897
1872
  var no_implicit_key_default = createRule({
1898
1873
  meta: {
1899
1874
  type: "problem",
@@ -1901,14 +1876,14 @@ var no_implicit_key_default = createRule({
1901
1876
  messages: { default: "This spread attribute implicitly passes the 'key' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'key' prop, use 'key={value}'." },
1902
1877
  schema: []
1903
1878
  },
1904
- name: RULE_NAME$33,
1905
- create: create$33,
1879
+ name: RULE_NAME$36,
1880
+ create: create$36,
1906
1881
  defaultOptions: []
1907
1882
  });
1908
- function create$33(context) {
1883
+ function create$36(context) {
1909
1884
  const services = ESLintUtils.getParserServices(context, false);
1910
1885
  const checker = services.program.getTypeChecker();
1911
- return { JSXSpreadAttribute(node) {
1886
+ return defineRuleListener({ JSXSpreadAttribute(node) {
1912
1887
  for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
1913
1888
  const key = type.getProperty("key");
1914
1889
  if (key == null) continue;
@@ -1918,12 +1893,12 @@ function create$33(context) {
1918
1893
  node
1919
1894
  });
1920
1895
  }
1921
- } };
1896
+ } });
1922
1897
  }
1923
1898
 
1924
1899
  //#endregion
1925
1900
  //#region src/rules/no-leaked-conditional-rendering.ts
1926
- const RULE_NAME$32 = "no-leaked-conditional-rendering";
1901
+ const RULE_NAME$35 = "no-leaked-conditional-rendering";
1927
1902
  var no_leaked_conditional_rendering_default = createRule({
1928
1903
  meta: {
1929
1904
  type: "problem",
@@ -1931,11 +1906,11 @@ var no_leaked_conditional_rendering_default = createRule({
1931
1906
  messages: { default: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
1932
1907
  schema: []
1933
1908
  },
1934
- name: RULE_NAME$32,
1935
- create: create$32,
1909
+ name: RULE_NAME$35,
1910
+ create: create$35,
1936
1911
  defaultOptions: []
1937
1912
  });
1938
- function create$32(context) {
1913
+ function create$35(context) {
1939
1914
  if (!context.sourceCode.text.includes("&&")) return {};
1940
1915
  const { version } = getSettingsFromContext(context);
1941
1916
  const allowedVariants = [
@@ -1987,12 +1962,12 @@ function create$32(context) {
1987
1962
  return match(variableDefNode).with({ init: P.select({ type: P.not(AST_NODE_TYPES.VariableDeclaration) }) }, getReportDescriptor).otherwise(() => unit);
1988
1963
  }).otherwise(() => unit);
1989
1964
  }
1990
- return { JSXExpressionContainer: flow(getReportDescriptor, report(context)) };
1965
+ return defineRuleListener({ JSXExpressionContainer: flow(getReportDescriptor, report(context)) });
1991
1966
  }
1992
1967
 
1993
1968
  //#endregion
1994
1969
  //#region src/rules/no-missing-component-display-name.ts
1995
- const RULE_NAME$31 = "no-missing-component-display-name";
1970
+ const RULE_NAME$34 = "no-missing-component-display-name";
1996
1971
  var no_missing_component_display_name_default = createRule({
1997
1972
  meta: {
1998
1973
  type: "problem",
@@ -2000,11 +1975,11 @@ var no_missing_component_display_name_default = createRule({
2000
1975
  messages: { default: "Add missing 'displayName' for component." },
2001
1976
  schema: []
2002
1977
  },
2003
- name: RULE_NAME$31,
2004
- create: create$31,
1978
+ name: RULE_NAME$34,
1979
+ create: create$34,
2005
1980
  defaultOptions: []
2006
1981
  });
2007
- function create$31(context) {
1982
+ function create$34(context) {
2008
1983
  if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
2009
1984
  const { ctx, visitor } = core.useComponentCollector(context, {
2010
1985
  collectDisplayName: true,
@@ -2026,7 +2001,7 @@ function create$31(context) {
2026
2001
 
2027
2002
  //#endregion
2028
2003
  //#region src/rules/no-missing-context-display-name.ts
2029
- const RULE_NAME$30 = "no-missing-context-display-name";
2004
+ const RULE_NAME$33 = "no-missing-context-display-name";
2030
2005
  var no_missing_context_display_name_default = createRule({
2031
2006
  meta: {
2032
2007
  type: "problem",
@@ -2035,15 +2010,15 @@ var no_missing_context_display_name_default = createRule({
2035
2010
  messages: { default: "Add missing 'displayName' for context." },
2036
2011
  schema: []
2037
2012
  },
2038
- name: RULE_NAME$30,
2039
- create: create$30,
2013
+ name: RULE_NAME$33,
2014
+ create: create$33,
2040
2015
  defaultOptions: []
2041
2016
  });
2042
- function create$30(context) {
2017
+ function create$33(context) {
2043
2018
  if (!context.sourceCode.text.includes("createContext")) return {};
2044
2019
  const createCalls = [];
2045
2020
  const displayNameAssignments = [];
2046
- return {
2021
+ return defineRuleListener({
2047
2022
  [ast.SEL_DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
2048
2023
  displayNameAssignments.push(node);
2049
2024
  },
@@ -2086,12 +2061,12 @@ function create$30(context) {
2086
2061
  });
2087
2062
  }
2088
2063
  }
2089
- };
2064
+ });
2090
2065
  }
2091
2066
 
2092
2067
  //#endregion
2093
2068
  //#region src/rules/no-missing-key.ts
2094
- const RULE_NAME$29 = "no-missing-key";
2069
+ const RULE_NAME$32 = "no-missing-key";
2095
2070
  var no_missing_key_default = createRule({
2096
2071
  meta: {
2097
2072
  type: "problem",
@@ -2102,11 +2077,11 @@ var no_missing_key_default = createRule({
2102
2077
  },
2103
2078
  schema: []
2104
2079
  },
2105
- name: RULE_NAME$29,
2106
- create: create$29,
2080
+ name: RULE_NAME$32,
2081
+ create: create$32,
2107
2082
  defaultOptions: []
2108
2083
  });
2109
- function create$29(ctx) {
2084
+ function create$32(ctx) {
2110
2085
  let inChildrenToArray = false;
2111
2086
  function check(node) {
2112
2087
  if (node.type === AST_NODE_TYPES.JSXElement) return core.getJsxAttribute(ctx, node)("key") == null ? {
@@ -2131,7 +2106,7 @@ function create$29(ctx) {
2131
2106
  function checkBlock(node) {
2132
2107
  return ast.getNestedReturnStatements(node).filter((stmt) => stmt.argument != null).map((stmt) => check(stmt.argument)).filter((d) => d != null);
2133
2108
  }
2134
- return {
2109
+ return defineRuleListener({
2135
2110
  ArrayExpression(node) {
2136
2111
  if (inChildrenToArray) return;
2137
2112
  const elements = node.elements.filter(ast.is(AST_NODE_TYPES.JSXElement));
@@ -2165,12 +2140,12 @@ function create$29(ctx) {
2165
2140
  node
2166
2141
  });
2167
2142
  }
2168
- };
2143
+ });
2169
2144
  }
2170
2145
 
2171
2146
  //#endregion
2172
2147
  //#region src/rules/no-misused-capture-owner-stack.ts
2173
- const RULE_NAME$28 = "no-misused-capture-owner-stack";
2148
+ const RULE_NAME$31 = "no-misused-capture-owner-stack";
2174
2149
  var no_misused_capture_owner_stack_default = createRule({
2175
2150
  meta: {
2176
2151
  type: "problem",
@@ -2181,14 +2156,14 @@ var no_misused_capture_owner_stack_default = createRule({
2181
2156
  },
2182
2157
  schema: []
2183
2158
  },
2184
- name: RULE_NAME$28,
2185
- create: create$28,
2159
+ name: RULE_NAME$31,
2160
+ create: create$31,
2186
2161
  defaultOptions: []
2187
2162
  });
2188
- function create$28(context) {
2163
+ function create$31(context) {
2189
2164
  if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
2190
2165
  const { importSource } = getSettingsFromContext(context);
2191
- return {
2166
+ return defineRuleListener({
2192
2167
  CallExpression(node) {
2193
2168
  if (!core.isCaptureOwnerStackCall(context, node)) return;
2194
2169
  if (ast.findParentNode(node, isDevelopmentOnlyCheck) == null) context.report({
@@ -2207,7 +2182,7 @@ function create$28(context) {
2207
2182
  });
2208
2183
  }
2209
2184
  }
2210
- };
2185
+ });
2211
2186
  }
2212
2187
  function isDevelopmentOnlyCheck(node) {
2213
2188
  if (node.type !== AST_NODE_TYPES.IfStatement) return false;
@@ -2216,7 +2191,7 @@ function isDevelopmentOnlyCheck(node) {
2216
2191
 
2217
2192
  //#endregion
2218
2193
  //#region src/rules/no-nested-component-definitions.ts
2219
- const RULE_NAME$27 = "no-nested-component-definitions";
2194
+ const RULE_NAME$30 = "no-nested-component-definitions";
2220
2195
  var no_nested_component_definitions_default = createRule({
2221
2196
  meta: {
2222
2197
  type: "problem",
@@ -2224,11 +2199,11 @@ var no_nested_component_definitions_default = createRule({
2224
2199
  messages: { default: "Do not nest component definitions inside other components or props. {{suggestion}}" },
2225
2200
  schema: []
2226
2201
  },
2227
- name: RULE_NAME$27,
2228
- create: create$27,
2202
+ name: RULE_NAME$30,
2203
+ create: create$30,
2229
2204
  defaultOptions: []
2230
2205
  });
2231
- function create$27(context) {
2206
+ function create$30(context) {
2232
2207
  const hint = core.ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.ComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.ComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
2233
2208
  const fCollector = core.useComponentCollector(context, { hint });
2234
2209
  const cCollector = core.useComponentCollectorLegacy(context);
@@ -2333,7 +2308,7 @@ function isInsideCreateElementProps(context, node) {
2333
2308
 
2334
2309
  //#endregion
2335
2310
  //#region src/rules/no-nested-lazy-component-declarations.ts
2336
- const RULE_NAME$26 = "no-nested-lazy-component-declarations";
2311
+ const RULE_NAME$29 = "no-nested-lazy-component-declarations";
2337
2312
  var no_nested_lazy_component_declarations_default = createRule({
2338
2313
  meta: {
2339
2314
  type: "problem",
@@ -2341,11 +2316,11 @@ var no_nested_lazy_component_declarations_default = createRule({
2341
2316
  messages: { default: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
2342
2317
  schema: []
2343
2318
  },
2344
- name: RULE_NAME$26,
2345
- create: create$26,
2319
+ name: RULE_NAME$29,
2320
+ create: create$29,
2346
2321
  defaultOptions: []
2347
2322
  });
2348
- function create$26(context) {
2323
+ function create$29(context) {
2349
2324
  const hint = core.ComponentDetectionHint.None;
2350
2325
  const collector = core.useComponentCollector(context, { hint });
2351
2326
  const collectorLegacy = core.useComponentCollectorLegacy(context);
@@ -2374,7 +2349,7 @@ function create$26(context) {
2374
2349
 
2375
2350
  //#endregion
2376
2351
  //#region src/rules/no-redundant-should-component-update.ts
2377
- const RULE_NAME$25 = "no-redundant-should-component-update";
2352
+ const RULE_NAME$28 = "no-redundant-should-component-update";
2378
2353
  function isShouldComponentUpdate(node) {
2379
2354
  return ast.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
2380
2355
  }
@@ -2385,11 +2360,11 @@ var no_redundant_should_component_update_default = createRule({
2385
2360
  messages: { default: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'." },
2386
2361
  schema: []
2387
2362
  },
2388
- name: RULE_NAME$25,
2389
- create: create$25,
2363
+ name: RULE_NAME$28,
2364
+ create: create$28,
2390
2365
  defaultOptions: []
2391
2366
  });
2392
- function create$25(context) {
2367
+ function create$28(context) {
2393
2368
  if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
2394
2369
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2395
2370
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2407,7 +2382,7 @@ function create$25(context) {
2407
2382
 
2408
2383
  //#endregion
2409
2384
  //#region src/rules/no-set-state-in-component-did-mount.ts
2410
- const RULE_NAME$24 = "no-set-state-in-component-did-mount";
2385
+ const RULE_NAME$27 = "no-set-state-in-component-did-mount";
2411
2386
  var no_set_state_in_component_did_mount_default = createRule({
2412
2387
  meta: {
2413
2388
  type: "problem",
@@ -2415,13 +2390,13 @@ var no_set_state_in_component_did_mount_default = createRule({
2415
2390
  messages: { default: "Do not call `this.setState` in `componentDidMount` outside functions such as callbacks." },
2416
2391
  schema: []
2417
2392
  },
2418
- name: RULE_NAME$24,
2419
- create: create$24,
2393
+ name: RULE_NAME$27,
2394
+ create: create$27,
2420
2395
  defaultOptions: []
2421
2396
  });
2422
- function create$24(context) {
2397
+ function create$27(context) {
2423
2398
  if (!context.sourceCode.text.includes("componentDidMount")) return {};
2424
- return { CallExpression(node) {
2399
+ return defineRuleListener({ CallExpression(node) {
2425
2400
  if (!core.isThisSetState(node)) return;
2426
2401
  const enclosingClassNode = ast.findParentNode(node, core.isClassComponent);
2427
2402
  const enclosingMethodNode = ast.findParentNode(node, (n) => n === enclosingClassNode || core.isComponentDidMount(n));
@@ -2432,12 +2407,12 @@ function create$24(context) {
2432
2407
  messageId: "default",
2433
2408
  node
2434
2409
  });
2435
- } };
2410
+ } });
2436
2411
  }
2437
2412
 
2438
2413
  //#endregion
2439
2414
  //#region src/rules/no-set-state-in-component-did-update.ts
2440
- const RULE_NAME$23 = "no-set-state-in-component-did-update";
2415
+ const RULE_NAME$26 = "no-set-state-in-component-did-update";
2441
2416
  var no_set_state_in_component_did_update_default = createRule({
2442
2417
  meta: {
2443
2418
  type: "problem",
@@ -2445,13 +2420,13 @@ var no_set_state_in_component_did_update_default = createRule({
2445
2420
  messages: { default: "Do not call `this.setState` in `componentDidUpdate` outside functions such as callbacks." },
2446
2421
  schema: []
2447
2422
  },
2448
- name: RULE_NAME$23,
2449
- create: create$23,
2423
+ name: RULE_NAME$26,
2424
+ create: create$26,
2450
2425
  defaultOptions: []
2451
2426
  });
2452
- function create$23(context) {
2427
+ function create$26(context) {
2453
2428
  if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
2454
- return { CallExpression(node) {
2429
+ return defineRuleListener({ CallExpression(node) {
2455
2430
  if (!core.isThisSetState(node)) return;
2456
2431
  const enclosingClassNode = ast.findParentNode(node, core.isClassComponent);
2457
2432
  const enclosingMethodNode = ast.findParentNode(node, (n) => n === enclosingClassNode || core.isComponentDidUpdate(n));
@@ -2462,12 +2437,12 @@ function create$23(context) {
2462
2437
  messageId: "default",
2463
2438
  node
2464
2439
  });
2465
- } };
2440
+ } });
2466
2441
  }
2467
2442
 
2468
2443
  //#endregion
2469
2444
  //#region src/rules/no-set-state-in-component-will-update.ts
2470
- const RULE_NAME$22 = "no-set-state-in-component-will-update";
2445
+ const RULE_NAME$25 = "no-set-state-in-component-will-update";
2471
2446
  var no_set_state_in_component_will_update_default = createRule({
2472
2447
  meta: {
2473
2448
  type: "problem",
@@ -2475,13 +2450,13 @@ var no_set_state_in_component_will_update_default = createRule({
2475
2450
  messages: { default: "Do not call `this.setState` in `componentWillUpdate` outside functions such as callbacks." },
2476
2451
  schema: []
2477
2452
  },
2478
- name: RULE_NAME$22,
2479
- create: create$22,
2453
+ name: RULE_NAME$25,
2454
+ create: create$25,
2480
2455
  defaultOptions: []
2481
2456
  });
2482
- function create$22(context) {
2457
+ function create$25(context) {
2483
2458
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
2484
- return { CallExpression(node) {
2459
+ return defineRuleListener({ CallExpression(node) {
2485
2460
  if (!core.isThisSetState(node)) return;
2486
2461
  const enclosingClassNode = ast.findParentNode(node, core.isClassComponent);
2487
2462
  const enclosingMethodNode = ast.findParentNode(node, (n) => n === enclosingClassNode || core.isComponentWillUpdate(n));
@@ -2492,12 +2467,12 @@ function create$22(context) {
2492
2467
  messageId: "default",
2493
2468
  node
2494
2469
  });
2495
- } };
2470
+ } });
2496
2471
  }
2497
2472
 
2498
2473
  //#endregion
2499
2474
  //#region src/rules/no-unnecessary-use-callback.ts
2500
- const RULE_NAME$21 = "no-unnecessary-use-callback";
2475
+ const RULE_NAME$24 = "no-unnecessary-use-callback";
2501
2476
  var no_unnecessary_use_callback_default = createRule({
2502
2477
  meta: {
2503
2478
  type: "problem",
@@ -2508,13 +2483,13 @@ var no_unnecessary_use_callback_default = createRule({
2508
2483
  },
2509
2484
  schema: []
2510
2485
  },
2511
- name: RULE_NAME$21,
2512
- create: create$21,
2486
+ name: RULE_NAME$24,
2487
+ create: create$24,
2513
2488
  defaultOptions: []
2514
2489
  });
2515
- function create$21(context) {
2490
+ function create$24(context) {
2516
2491
  if (!context.sourceCode.text.includes("useCallback")) return {};
2517
- return { VariableDeclarator(node) {
2492
+ return defineRuleListener({ VariableDeclarator(node) {
2518
2493
  const { id, init } = node;
2519
2494
  if (id.type !== AST_NODE_TYPES.Identifier || init?.type !== AST_NODE_TYPES.CallExpression || !core.isUseCallbackCall(init)) return;
2520
2495
  const [cbk, ...rest] = context.sourceCode.getDeclaredVariables(node);
@@ -2526,7 +2501,7 @@ function create$21(context) {
2526
2501
  const [arg0, arg1] = init.arguments;
2527
2502
  if (arg0 == null || arg1 == null) return;
2528
2503
  if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
2529
- const variableNode = getVariableDefinitionNode(findVariable(n.name, scope), 0);
2504
+ const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
2530
2505
  if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
2531
2506
  return variableNode.elements.length === 0;
2532
2507
  }).otherwise(() => false)) {
@@ -2537,7 +2512,7 @@ function create$21(context) {
2537
2512
  if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
2538
2513
  return n;
2539
2514
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
2540
- const variableNode = getVariableDefinitionNode(findVariable(n.name, scope), 0);
2515
+ const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
2541
2516
  if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
2542
2517
  return variableNode;
2543
2518
  }).otherwise(() => null);
@@ -2550,7 +2525,7 @@ function create$21(context) {
2550
2525
  return;
2551
2526
  }
2552
2527
  report(context)(checkForUsageInsideUseEffectReport);
2553
- } };
2528
+ } });
2554
2529
  }
2555
2530
  function checkForUsageInsideUseEffect$1(sourceCode, node) {
2556
2531
  if (!/use\w*Effect/u.test(sourceCode.text)) return;
@@ -2574,7 +2549,7 @@ function checkForUsageInsideUseEffect$1(sourceCode, node) {
2574
2549
 
2575
2550
  //#endregion
2576
2551
  //#region src/rules/no-unnecessary-use-memo.ts
2577
- const RULE_NAME$20 = "no-unnecessary-use-memo";
2552
+ const RULE_NAME$23 = "no-unnecessary-use-memo";
2578
2553
  var no_unnecessary_use_memo_default = createRule({
2579
2554
  meta: {
2580
2555
  type: "problem",
@@ -2585,13 +2560,13 @@ var no_unnecessary_use_memo_default = createRule({
2585
2560
  },
2586
2561
  schema: []
2587
2562
  },
2588
- name: RULE_NAME$20,
2589
- create: create$20,
2563
+ name: RULE_NAME$23,
2564
+ create: create$23,
2590
2565
  defaultOptions: []
2591
2566
  });
2592
- function create$20(context) {
2567
+ function create$23(context) {
2593
2568
  if (!context.sourceCode.text.includes("useMemo")) return {};
2594
- return { VariableDeclarator(node) {
2569
+ return defineRuleListener({ VariableDeclarator(node) {
2595
2570
  const { id, init } = node;
2596
2571
  if (id.type !== AST_NODE_TYPES.Identifier || init?.type !== AST_NODE_TYPES.CallExpression || !core.isUseMemoCall(init)) return;
2597
2572
  const [mem, ...rest] = context.sourceCode.getDeclaredVariables(node);
@@ -2607,7 +2582,7 @@ function create$20(context) {
2607
2582
  return;
2608
2583
  }
2609
2584
  if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
2610
- const variableNode = getVariableDefinitionNode(findVariable(n.name, scope), 0);
2585
+ const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
2611
2586
  if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
2612
2587
  return variableNode.elements.length === 0;
2613
2588
  }).otherwise(() => false)) {
@@ -2618,7 +2593,7 @@ function create$20(context) {
2618
2593
  if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
2619
2594
  return n;
2620
2595
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
2621
- const variableNode = getVariableDefinitionNode(findVariable(n.name, scope), 0);
2596
+ const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
2622
2597
  if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
2623
2598
  return variableNode;
2624
2599
  }).otherwise(() => null);
@@ -2631,7 +2606,7 @@ function create$20(context) {
2631
2606
  return;
2632
2607
  }
2633
2608
  report(context)(checkForUsageInsideUseEffectReport);
2634
- } };
2609
+ } });
2635
2610
  }
2636
2611
  function checkForUsageInsideUseEffect(sourceCode, node) {
2637
2612
  if (!/use\w*Effect/u.test(sourceCode.text)) return;
@@ -2655,7 +2630,7 @@ function checkForUsageInsideUseEffect(sourceCode, node) {
2655
2630
 
2656
2631
  //#endregion
2657
2632
  //#region src/rules/no-unnecessary-use-prefix.ts
2658
- const RULE_NAME$19 = "no-unnecessary-use-prefix";
2633
+ const RULE_NAME$22 = "no-unnecessary-use-prefix";
2659
2634
  const WELL_KNOWN_HOOKS = ["useMDXComponents"];
2660
2635
  function containsUseComments(context, node) {
2661
2636
  return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
@@ -2667,11 +2642,11 @@ var no_unnecessary_use_prefix_default = createRule({
2667
2642
  messages: { default: "If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix." },
2668
2643
  schema: []
2669
2644
  },
2670
- name: RULE_NAME$19,
2671
- create: create$19,
2645
+ name: RULE_NAME$22,
2646
+ create: create$22,
2672
2647
  defaultOptions: []
2673
2648
  });
2674
- function create$19(context) {
2649
+ function create$22(context) {
2675
2650
  const { ctx, visitor } = core.useHookCollector(context);
2676
2651
  return defineRuleListener(visitor, { "Program:exit"(program) {
2677
2652
  for (const { id, name, node, hookCalls } of ctx.getAllHooks(program)) {
@@ -2691,7 +2666,7 @@ function create$19(context) {
2691
2666
 
2692
2667
  //#endregion
2693
2668
  //#region src/rules/no-unsafe-component-will-mount.ts
2694
- const RULE_NAME$18 = "no-unsafe-component-will-mount";
2669
+ const RULE_NAME$21 = "no-unsafe-component-will-mount";
2695
2670
  var no_unsafe_component_will_mount_default = createRule({
2696
2671
  meta: {
2697
2672
  type: "problem",
@@ -2699,11 +2674,11 @@ var no_unsafe_component_will_mount_default = createRule({
2699
2674
  messages: { default: "Do not use 'UNSAFE_componentWillMount'." },
2700
2675
  schema: []
2701
2676
  },
2702
- name: RULE_NAME$18,
2703
- create: create$18,
2677
+ name: RULE_NAME$21,
2678
+ create: create$21,
2704
2679
  defaultOptions: []
2705
2680
  });
2706
- function create$18(context) {
2681
+ function create$21(context) {
2707
2682
  if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
2708
2683
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2709
2684
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2719,7 +2694,7 @@ function create$18(context) {
2719
2694
 
2720
2695
  //#endregion
2721
2696
  //#region src/rules/no-unsafe-component-will-receive-props.ts
2722
- const RULE_NAME$17 = "no-unsafe-component-will-receive-props";
2697
+ const RULE_NAME$20 = "no-unsafe-component-will-receive-props";
2723
2698
  var no_unsafe_component_will_receive_props_default = createRule({
2724
2699
  meta: {
2725
2700
  type: "problem",
@@ -2727,11 +2702,11 @@ var no_unsafe_component_will_receive_props_default = createRule({
2727
2702
  messages: { default: "Do not use 'UNSAFE_componentWillReceiveProps'." },
2728
2703
  schema: []
2729
2704
  },
2730
- name: RULE_NAME$17,
2731
- create: create$17,
2705
+ name: RULE_NAME$20,
2706
+ create: create$20,
2732
2707
  defaultOptions: []
2733
2708
  });
2734
- function create$17(context) {
2709
+ function create$20(context) {
2735
2710
  if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
2736
2711
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2737
2712
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2747,7 +2722,7 @@ function create$17(context) {
2747
2722
 
2748
2723
  //#endregion
2749
2724
  //#region src/rules/no-unsafe-component-will-update.ts
2750
- const RULE_NAME$16 = "no-unsafe-component-will-update";
2725
+ const RULE_NAME$19 = "no-unsafe-component-will-update";
2751
2726
  var no_unsafe_component_will_update_default = createRule({
2752
2727
  meta: {
2753
2728
  type: "problem",
@@ -2755,11 +2730,11 @@ var no_unsafe_component_will_update_default = createRule({
2755
2730
  messages: { default: "Do not use 'UNSAFE_componentWillUpdate'." },
2756
2731
  schema: []
2757
2732
  },
2758
- name: RULE_NAME$16,
2759
- create: create$16,
2733
+ name: RULE_NAME$19,
2734
+ create: create$19,
2760
2735
  defaultOptions: []
2761
2736
  });
2762
- function create$16(context) {
2737
+ function create$19(context) {
2763
2738
  if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
2764
2739
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2765
2740
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2775,7 +2750,7 @@ function create$16(context) {
2775
2750
 
2776
2751
  //#endregion
2777
2752
  //#region src/rules/no-unstable-context-value.ts
2778
- const RULE_NAME$15 = "no-unstable-context-value";
2753
+ const RULE_NAME$18 = "no-unstable-context-value";
2779
2754
  var no_unstable_context_value_default = createRule({
2780
2755
  meta: {
2781
2756
  type: "problem",
@@ -2783,13 +2758,14 @@ var no_unstable_context_value_default = createRule({
2783
2758
  messages: { unstableContextValue: "A/an '{{kind}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}" },
2784
2759
  schema: []
2785
2760
  },
2786
- name: RULE_NAME$15,
2787
- create: create$15,
2761
+ name: RULE_NAME$18,
2762
+ create: create$18,
2788
2763
  defaultOptions: []
2789
2764
  });
2790
- function create$15(context) {
2791
- const { isCompilerEnabled, version } = getSettingsFromContext(context);
2792
- if (isCompilerEnabled && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2765
+ function create$18(context) {
2766
+ const { compilationMode, version } = getSettingsFromContext(context);
2767
+ if (compilationMode === "infer" || compilationMode === "all") return {};
2768
+ if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2793
2769
  const isReact18OrBelow = compare(version, "19.0.0", "<");
2794
2770
  const { ctx, visitor } = core.useComponentCollector(context);
2795
2771
  const constructions = /* @__PURE__ */ new WeakMap();
@@ -2800,7 +2776,7 @@ function create$15(context) {
2800
2776
  if (!isContextName(selfName, isReact18OrBelow)) return;
2801
2777
  const functionEntry = ctx.getCurrentEntry();
2802
2778
  if (functionEntry == null) return;
2803
- if (isCompilerEnabled && ast.isDirectiveInFunction(functionEntry.node, "use memo")) return;
2779
+ if (compilationMode === "annotation" && ast.isDirectiveInFunction(functionEntry.node, "use memo")) return;
2804
2780
  const attribute = node.attributes.find((attribute) => attribute.type === AST_NODE_TYPES.JSXAttribute && attribute.name.name === "value");
2805
2781
  if (attribute == null || !("value" in attribute)) return;
2806
2782
  const value = attribute.value;
@@ -2812,18 +2788,20 @@ function create$15(context) {
2812
2788
  getOrElseUpdate(constructions, functionEntry.node, () => []).push(construction);
2813
2789
  },
2814
2790
  "Program:exit"(program) {
2815
- for (const { node: component, directives } of ctx.getAllComponents(program)) for (const construction of constructions.get(component) ?? []) {
2816
- if (directives.some((d) => d.directive === "use memo")) return;
2817
- const { kind, node: constructionNode } = construction;
2818
- const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
2819
- context.report({
2820
- messageId: "unstableContextValue",
2821
- node: constructionNode,
2822
- data: {
2823
- kind: ast.getHumanReadableKind(constructionNode),
2824
- suggestion
2825
- }
2826
- });
2791
+ for (const { node: component, directives } of ctx.getAllComponents(program)) {
2792
+ if (compilationMode === "annotation" && directives.some((d) => d.directive === "use memo")) continue;
2793
+ for (const construction of constructions.get(component) ?? []) {
2794
+ const { kind, node: constructionNode } = construction;
2795
+ const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
2796
+ context.report({
2797
+ messageId: "unstableContextValue",
2798
+ node: constructionNode,
2799
+ data: {
2800
+ kind: ast.getHumanReadableKind(constructionNode),
2801
+ suggestion
2802
+ }
2803
+ });
2804
+ }
2827
2805
  }
2828
2806
  }
2829
2807
  });
@@ -2836,9 +2814,9 @@ function isContextName(name, isReact18OrBelow) {
2836
2814
 
2837
2815
  //#endregion
2838
2816
  //#region src/rules/no-unstable-default-props.ts
2839
- const RULE_NAME$14 = "no-unstable-default-props";
2840
- const defaultOptions$1 = [{ safeDefaultProps: [] }];
2841
- const schema$1 = [{
2817
+ const RULE_NAME$17 = "no-unstable-default-props";
2818
+ const defaultOptions$2 = [{ safeDefaultProps: [] }];
2819
+ const schema$2 = [{
2842
2820
  type: "object",
2843
2821
  additionalProperties: false,
2844
2822
  properties: { safeDefaultProps: {
@@ -2851,11 +2829,11 @@ var no_unstable_default_props_default = createRule({
2851
2829
  type: "problem",
2852
2830
  docs: { description: "Prevents using referential-type values as default props in object destructuring." },
2853
2831
  messages: { default: "A/an '{{kind}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{kind}}'." },
2854
- schema: schema$1
2832
+ schema: schema$2
2855
2833
  },
2856
- name: RULE_NAME$14,
2857
- create: create$14,
2858
- defaultOptions: defaultOptions$1
2834
+ name: RULE_NAME$17,
2835
+ create: create$17,
2836
+ defaultOptions: defaultOptions$2
2859
2837
  });
2860
2838
  function extractIdentifier(node) {
2861
2839
  if (node.type === AST_NODE_TYPES.NewExpression && node.callee.type === AST_NODE_TYPES.Identifier) return node.callee.name;
@@ -2865,9 +2843,10 @@ function extractIdentifier(node) {
2865
2843
  }
2866
2844
  return null;
2867
2845
  }
2868
- function create$14(context, [options]) {
2869
- const { isCompilerEnabled } = getSettingsFromContext(context);
2870
- if (isCompilerEnabled && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2846
+ function create$17(context, [options]) {
2847
+ const { compilationMode } = getSettingsFromContext(context);
2848
+ if (compilationMode === "infer" || compilationMode === "all") return {};
2849
+ if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2871
2850
  const { ctx, visitor } = core.useComponentCollector(context);
2872
2851
  const declarators = /* @__PURE__ */ new WeakMap();
2873
2852
  const { safeDefaultProps = [] } = options;
@@ -2910,7 +2889,7 @@ function create$14(context, [options]) {
2910
2889
 
2911
2890
  //#endregion
2912
2891
  //#region src/rules/no-unused-class-component-members.ts
2913
- const RULE_NAME$13 = "no-unused-class-component-members";
2892
+ const RULE_NAME$16 = "no-unused-class-component-members";
2914
2893
  const LIFECYCLE_METHODS = new Set([
2915
2894
  "componentDidCatch",
2916
2895
  "componentDidMount",
@@ -2941,11 +2920,11 @@ var no_unused_class_component_members_default = createRule({
2941
2920
  messages: { default: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
2942
2921
  schema: []
2943
2922
  },
2944
- name: RULE_NAME$13,
2945
- create: create$13,
2923
+ name: RULE_NAME$16,
2924
+ create: create$16,
2946
2925
  defaultOptions: []
2947
2926
  });
2948
- function create$13(context) {
2927
+ function create$16(context) {
2949
2928
  const classStack = [];
2950
2929
  const methodStack = [];
2951
2930
  const propertyDefs = /* @__PURE__ */ new WeakMap();
@@ -2987,7 +2966,7 @@ function create$13(context) {
2987
2966
  function methodExit() {
2988
2967
  methodStack.pop();
2989
2968
  }
2990
- return {
2969
+ return defineRuleListener({
2991
2970
  ClassDeclaration: classEnter,
2992
2971
  "ClassDeclaration:exit": classExit,
2993
2972
  ClassExpression: classEnter,
@@ -3021,12 +3000,12 @@ function create$13(context) {
3021
3000
  }
3022
3001
  }
3023
3002
  }
3024
- };
3003
+ });
3025
3004
  }
3026
3005
 
3027
3006
  //#endregion
3028
3007
  //#region src/rules/no-unused-props.ts
3029
- const RULE_NAME$12 = "no-unused-props";
3008
+ const RULE_NAME$15 = "no-unused-props";
3030
3009
  var no_unused_props_default = createRule({
3031
3010
  meta: {
3032
3011
  type: "problem",
@@ -3034,15 +3013,15 @@ var no_unused_props_default = createRule({
3034
3013
  messages: { default: "Prop `{{name}}` is declared but never used" },
3035
3014
  schema: []
3036
3015
  },
3037
- name: RULE_NAME$12,
3038
- create: create$12,
3016
+ name: RULE_NAME$15,
3017
+ create: create$15,
3039
3018
  defaultOptions: []
3040
3019
  });
3041
- function create$12(context) {
3020
+ function create$15(context) {
3042
3021
  const services = ESLintUtils.getParserServices(context, false);
3022
+ const checker = services.program.getTypeChecker();
3043
3023
  const { ctx, visitor } = core.useComponentCollector(context);
3044
3024
  return defineRuleListener(visitor, { "Program:exit"(program) {
3045
- const checker = services.program.getTypeChecker();
3046
3025
  const totalDeclaredProps = /* @__PURE__ */ new Set();
3047
3026
  const totalUsedProps = /* @__PURE__ */ new Set();
3048
3027
  for (const component of ctx.getAllComponents(program)) {
@@ -3117,7 +3096,9 @@ function collectUsedPropKeysOfReference(context, usedPropKeys, identifier, ref)
3117
3096
  function getKeyOfExpression(expr) {
3118
3097
  switch (expr.type) {
3119
3098
  case AST_NODE_TYPES.Identifier: return expr.name;
3120
- case AST_NODE_TYPES.Literal: if (typeof expr.value === "string") return expr.value;
3099
+ case AST_NODE_TYPES.Literal:
3100
+ if (typeof expr.value === "string") return expr.value;
3101
+ break;
3121
3102
  }
3122
3103
  return null;
3123
3104
  }
@@ -3136,7 +3117,7 @@ function reportUnusedProp(context, services, prop) {
3136
3117
 
3137
3118
  //#endregion
3138
3119
  //#region src/rules/no-unused-state.ts
3139
- const RULE_NAME$11 = "no-unused-state";
3120
+ const RULE_NAME$14 = "no-unused-state";
3140
3121
  function isKeyLiteral(node, key) {
3141
3122
  return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
3142
3123
  type: AST_NODE_TYPES.TemplateLiteral,
@@ -3150,11 +3131,11 @@ var no_unused_state_default = createRule({
3150
3131
  messages: { default: "Unused class component state in '{{className}}'" },
3151
3132
  schema: []
3152
3133
  },
3153
- name: RULE_NAME$11,
3154
- create: create$11,
3134
+ name: RULE_NAME$14,
3135
+ create: create$14,
3155
3136
  defaultOptions: []
3156
3137
  });
3157
- function create$11(context) {
3138
+ function create$14(context) {
3158
3139
  const classStack = [];
3159
3140
  const methodStack = [];
3160
3141
  const constructorStack = [];
@@ -3202,7 +3183,7 @@ function create$11(context) {
3202
3183
  function constructorExit() {
3203
3184
  constructorStack.pop();
3204
3185
  }
3205
- return {
3186
+ return defineRuleListener({
3206
3187
  AssignmentExpression(node) {
3207
3188
  if (!core.isAssignmentToThisState(node)) return;
3208
3189
  const currentClass = classStack.at(-1);
@@ -3258,12 +3239,12 @@ function create$11(context) {
3258
3239
  isUsed: true
3259
3240
  });
3260
3241
  }
3261
- };
3242
+ });
3262
3243
  }
3263
3244
 
3264
3245
  //#endregion
3265
3246
  //#region src/rules/no-use-context.ts
3266
- const RULE_NAME$10 = "no-use-context";
3247
+ const RULE_NAME$13 = "no-use-context";
3267
3248
  var no_use_context_default = createRule({
3268
3249
  meta: {
3269
3250
  type: "problem",
@@ -3272,16 +3253,16 @@ var no_use_context_default = createRule({
3272
3253
  messages: { default: "In React 19, 'use' is preferred over 'useContext' because it is more flexible." },
3273
3254
  schema: []
3274
3255
  },
3275
- name: RULE_NAME$10,
3276
- create: create$10,
3256
+ name: RULE_NAME$13,
3257
+ create: create$13,
3277
3258
  defaultOptions: []
3278
3259
  });
3279
- function create$10(context) {
3260
+ function create$13(context) {
3280
3261
  if (!context.sourceCode.text.includes("useContext")) return {};
3281
3262
  const settings = getSettingsFromContext(context);
3282
3263
  if (compare(settings.version, "19.0.0", "<")) return {};
3283
3264
  const hookCalls = /* @__PURE__ */ new Set();
3284
- return {
3265
+ return defineRuleListener({
3285
3266
  CallExpression(node) {
3286
3267
  if (!core.isHookCall(node)) return;
3287
3268
  hookCalls.add(node);
@@ -3328,7 +3309,7 @@ function create$10(context) {
3328
3309
  });
3329
3310
  }
3330
3311
  }
3331
- };
3312
+ });
3332
3313
  }
3333
3314
  function getCorrelativeTokens(context, node) {
3334
3315
  const tokenBefore = context.sourceCode.getTokenBefore(node);
@@ -3341,7 +3322,7 @@ function getCorrelativeTokens(context, node) {
3341
3322
 
3342
3323
  //#endregion
3343
3324
  //#region src/rules/no-useless-forward-ref.ts
3344
- const RULE_NAME$9 = "no-useless-forward-ref";
3325
+ const RULE_NAME$12 = "no-useless-forward-ref";
3345
3326
  var no_useless_forward_ref_default = createRule({
3346
3327
  meta: {
3347
3328
  type: "problem",
@@ -3349,12 +3330,12 @@ var no_useless_forward_ref_default = createRule({
3349
3330
  messages: { default: "A 'forwardRef' is used with this component but no 'ref' parameter is set." },
3350
3331
  schema: []
3351
3332
  },
3352
- name: RULE_NAME$9,
3353
- create: create$9,
3333
+ name: RULE_NAME$12,
3334
+ create: create$12,
3354
3335
  defaultOptions: []
3355
3336
  });
3356
- function create$9(context) {
3357
- return { CallExpression(node) {
3337
+ function create$12(context) {
3338
+ return defineRuleListener({ CallExpression(node) {
3358
3339
  if (!core.isForwardRefCall(context, node)) return;
3359
3340
  const [component] = node.arguments;
3360
3341
  if (component == null || !ast.isFunction(component)) return;
@@ -3363,17 +3344,17 @@ function create$9(context) {
3363
3344
  messageId: "default",
3364
3345
  node: node.callee
3365
3346
  });
3366
- } };
3347
+ } });
3367
3348
  }
3368
3349
 
3369
3350
  //#endregion
3370
3351
  //#region src/rules/no-useless-fragment.ts
3371
- const RULE_NAME$8 = "no-useless-fragment";
3372
- const defaultOptions = [{
3352
+ const RULE_NAME$11 = "no-useless-fragment";
3353
+ const defaultOptions$1 = [{
3373
3354
  allowEmptyFragment: false,
3374
3355
  allowExpressions: true
3375
3356
  }];
3376
- const schema = [{
3357
+ const schema$1 = [{
3377
3358
  type: "object",
3378
3359
  additionalProperties: false,
3379
3360
  properties: {
@@ -3390,17 +3371,17 @@ const schema = [{
3390
3371
  var no_useless_fragment_default = createRule({
3391
3372
  meta: {
3392
3373
  type: "problem",
3393
- defaultOptions: [...defaultOptions],
3374
+ defaultOptions: [...defaultOptions$1],
3394
3375
  docs: { description: "Disallows useless fragment elements." },
3395
3376
  fixable: "code",
3396
3377
  messages: { default: "A fragment {{reason}} is useless." },
3397
- schema
3378
+ schema: schema$1
3398
3379
  },
3399
- name: RULE_NAME$8,
3400
- create: create$8,
3401
- defaultOptions
3380
+ name: RULE_NAME$11,
3381
+ create: create$11,
3382
+ defaultOptions: defaultOptions$1
3402
3383
  });
3403
- function create$8(context, [option]) {
3384
+ function create$11(context, [option]) {
3404
3385
  const { allowEmptyFragment = false, allowExpressions = true } = option;
3405
3386
  const jsxConfig = {
3406
3387
  ...core.getJsxConfigFromContext(context),
@@ -3473,7 +3454,7 @@ function create$8(context, [option]) {
3473
3454
  if (node.children.length === 0) return false;
3474
3455
  return !node.children.some((child) => core.isJsxText(child) && !isWhiteSpace(child) || ast.is(AST_NODE_TYPES.JSXExpressionContainer)(child));
3475
3456
  }
3476
- return {
3457
+ return defineRuleListener({
3477
3458
  JSXElement(node) {
3478
3459
  if (!core.isJsxFragmentElement(context, node, jsxConfig)) return;
3479
3460
  checkNode(context, node);
@@ -3481,7 +3462,7 @@ function create$8(context, [option]) {
3481
3462
  JSXFragment(node) {
3482
3463
  checkNode(context, node);
3483
3464
  }
3484
- };
3465
+ });
3485
3466
  }
3486
3467
  /**
3487
3468
  * Check if a Literal or JSXText node is whitespace
@@ -3508,7 +3489,7 @@ function trimLikeReact(text) {
3508
3489
 
3509
3490
  //#endregion
3510
3491
  //#region src/rules/prefer-destructuring-assignment.ts
3511
- const RULE_NAME$7 = "prefer-destructuring-assignment";
3492
+ const RULE_NAME$10 = "prefer-destructuring-assignment";
3512
3493
  var prefer_destructuring_assignment_default = createRule({
3513
3494
  meta: {
3514
3495
  type: "problem",
@@ -3516,11 +3497,11 @@ var prefer_destructuring_assignment_default = createRule({
3516
3497
  messages: { default: "Use destructuring assignment for component props." },
3517
3498
  schema: []
3518
3499
  },
3519
- name: RULE_NAME$7,
3520
- create: create$7,
3500
+ name: RULE_NAME$10,
3501
+ create: create$10,
3521
3502
  defaultOptions: []
3522
3503
  });
3523
- function create$7(context) {
3504
+ function create$10(context) {
3524
3505
  const { ctx, visitor } = core.useComponentCollector(context);
3525
3506
  return defineRuleListener(visitor, { "Program:exit"(program) {
3526
3507
  for (const component of ctx.getAllComponents(program)) {
@@ -3544,7 +3525,7 @@ function create$7(context) {
3544
3525
 
3545
3526
  //#endregion
3546
3527
  //#region src/rules/prefer-namespace-import.ts
3547
- const RULE_NAME$6 = "prefer-namespace-import";
3528
+ const RULE_NAME$9 = "prefer-namespace-import";
3548
3529
  var prefer_namespace_import_default = createRule({
3549
3530
  meta: {
3550
3531
  type: "problem",
@@ -3553,13 +3534,13 @@ var prefer_namespace_import_default = createRule({
3553
3534
  messages: { default: "Prefer importing React as 'import * as React from \"{{importSource}}\"';" },
3554
3535
  schema: []
3555
3536
  },
3556
- name: RULE_NAME$6,
3557
- create: create$6,
3537
+ name: RULE_NAME$9,
3538
+ create: create$9,
3558
3539
  defaultOptions: []
3559
3540
  });
3560
- function create$6(context) {
3541
+ function create$9(context) {
3561
3542
  const { importSource } = getSettingsFromContext(context);
3562
- return { [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
3543
+ return defineRuleListener({ [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
3563
3544
  const hasOtherSpecifiers = node.parent.specifiers.length > 1;
3564
3545
  context.report({
3565
3546
  messageId: "default",
@@ -3576,12 +3557,12 @@ function create$6(context) {
3576
3557
  return fixer.replaceText(node.parent, [`${importStringPrefix} * as ${node.local.name} from ${importSourceQuoted}${semi}`, `${importStringPrefix} ${specifiers} from ${importSourceQuoted}${semi}`].join("\n"));
3577
3558
  }
3578
3559
  });
3579
- } };
3560
+ } });
3580
3561
  }
3581
3562
 
3582
3563
  //#endregion
3583
3564
  //#region src/rules/prefer-read-only-props.ts
3584
- const RULE_NAME$5 = "prefer-read-only-props";
3565
+ const RULE_NAME$8 = "prefer-read-only-props";
3585
3566
  var prefer_read_only_props_default = createRule({
3586
3567
  meta: {
3587
3568
  type: "problem",
@@ -3589,11 +3570,11 @@ var prefer_read_only_props_default = createRule({
3589
3570
  messages: { default: "A function component's props should be read-only." },
3590
3571
  schema: []
3591
3572
  },
3592
- name: RULE_NAME$5,
3593
- create: create$5,
3573
+ name: RULE_NAME$8,
3574
+ create: create$8,
3594
3575
  defaultOptions: []
3595
3576
  });
3596
- function create$5(context) {
3577
+ function create$8(context) {
3597
3578
  const services = ESLintUtils.getParserServices(context, false);
3598
3579
  const checker = services.program.getTypeChecker();
3599
3580
  const { ctx, visitor } = core.useComponentCollector(context);
@@ -3632,55 +3613,9 @@ function isClassOrInterfaceReadonlyLoose(checker, type) {
3632
3613
  });
3633
3614
  }
3634
3615
 
3635
- //#endregion
3636
- //#region src/rules/prefer-use-state-lazy-initialization.ts
3637
- const RULE_NAME$4 = "prefer-use-state-lazy-initialization";
3638
- const ALLOW_LIST = [
3639
- "Boolean",
3640
- "String",
3641
- "Number"
3642
- ];
3643
- var prefer_use_state_lazy_initialization_default = createRule({
3644
- meta: {
3645
- type: "problem",
3646
- docs: { description: "Enforces wrapping function calls made inside 'useState' in an 'initializer function'." },
3647
- messages: { default: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'." },
3648
- schema: []
3649
- },
3650
- name: RULE_NAME$4,
3651
- create: create$4,
3652
- defaultOptions: []
3653
- });
3654
- function create$4(context) {
3655
- return { CallExpression(node) {
3656
- if (!core.isUseStateCall(node)) return;
3657
- const [useStateInput] = node.arguments;
3658
- if (useStateInput == null) return;
3659
- for (const expr of ast.getNestedNewExpressions(useStateInput)) {
3660
- if (!("name" in expr.callee)) continue;
3661
- if (ALLOW_LIST.includes(expr.callee.name)) continue;
3662
- if (ast.findParentNode(expr, core.isUseCall) != null) continue;
3663
- context.report({
3664
- messageId: "default",
3665
- node: expr
3666
- });
3667
- }
3668
- for (const expr of ast.getNestedCallExpressions(useStateInput)) {
3669
- if (!("name" in expr.callee)) continue;
3670
- if (core.isHookName(expr.callee.name)) continue;
3671
- if (ALLOW_LIST.includes(expr.callee.name)) continue;
3672
- if (ast.findParentNode(expr, core.isUseCall) != null) continue;
3673
- context.report({
3674
- messageId: "default",
3675
- node: expr
3676
- });
3677
- }
3678
- } };
3679
- }
3680
-
3681
3616
  //#endregion
3682
3617
  //#region src/rules/purity.ts
3683
- const RULE_NAME$3 = "purity";
3618
+ const RULE_NAME$7 = "purity";
3684
3619
  function isImpureMemberCall(node) {
3685
3620
  if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return false;
3686
3621
  const { object, property } = node.callee;
@@ -3712,11 +3647,11 @@ var purity_default = createRule({
3712
3647
  messages: { default: "Do not call '{{name}}' during render. Components and hooks must be pure. Move this call into an event handler, effect, or state initializer." },
3713
3648
  schema: []
3714
3649
  },
3715
- name: RULE_NAME$3,
3716
- create: create$3,
3650
+ name: RULE_NAME$7,
3651
+ create: create$7,
3717
3652
  defaultOptions: []
3718
3653
  });
3719
- function create$3(context) {
3654
+ function create$7(context) {
3720
3655
  const hCollector = core.useHookCollector(context);
3721
3656
  const cCollector = core.useComponentCollector(context);
3722
3657
  const cExprs = [];
@@ -3762,9 +3697,188 @@ function create$3(context) {
3762
3697
  });
3763
3698
  }
3764
3699
 
3700
+ //#endregion
3701
+ //#region src/rules/refs.ts
3702
+ const RULE_NAME$6 = "refs";
3703
+ function isWriteAccess(node) {
3704
+ const { parent } = node;
3705
+ if (parent.type === AST_NODE_TYPES.AssignmentExpression && parent.left === node) return true;
3706
+ if (parent.type === AST_NODE_TYPES.UpdateExpression && parent.argument === node) return true;
3707
+ return false;
3708
+ }
3709
+ function isInsideNestedFunction(node, boundary) {
3710
+ let current = node.parent;
3711
+ while (current != null && current !== boundary) {
3712
+ if (ast.isFunction(current)) return true;
3713
+ current = current.parent;
3714
+ }
3715
+ return false;
3716
+ }
3717
+ /**
3718
+ * Check if a ref.current access is part of a lazy initialization pattern.
3719
+ *
3720
+ * Standard:
3721
+ * if (ref.current === null) { ref.current = value; }
3722
+ *
3723
+ * Inverted (with early return):
3724
+ * if (ref.current !== null) { return ...; }
3725
+ * ref.current = computeValue();
3726
+ * @param node The MemberExpression node for ref.current
3727
+ * @param isWrite Whether this access is a write (assignment/update) or a read
3728
+ * @returns true if this access is part of a lazy initialization pattern and should be allowed during render
3729
+ */
3730
+ function isPartOfLazyInitialization(node, isWrite) {
3731
+ if (node.object.type !== AST_NODE_TYPES.Identifier) return false;
3732
+ const refName = node.object.name;
3733
+ if (isInNullCheckTest(node)) return true;
3734
+ if (findEnclosingRefNullCheckIf(node, refName) != null) return true;
3735
+ if (isWrite && isWriteAfterNullCheckIf(node, refName)) return true;
3736
+ return false;
3737
+ }
3738
+ function isNullCheckOperator(operator) {
3739
+ return operator === "===" || operator === "==" || operator === "!==" || operator === "!=";
3740
+ }
3741
+ /**
3742
+ * Check if a test expression is a null check on `ref.current` for a given ref name.
3743
+ * @param test The test expression to check
3744
+ * @param refName The name of the ref variable (e.g. "myRef") to check against
3745
+ * @returns true if the test is of the form `ref.current === null` or `null === ref.current`
3746
+ */
3747
+ function isRefCurrentNullCheck(test, refName) {
3748
+ if (test.type !== AST_NODE_TYPES.BinaryExpression) return false;
3749
+ if (!isNullCheckOperator(test.operator)) return false;
3750
+ const { left, right } = test;
3751
+ const isRefSide = (side) => side.type === AST_NODE_TYPES.MemberExpression && side.object.type === AST_NODE_TYPES.Identifier && side.object.name === refName && side.property.type === AST_NODE_TYPES.Identifier && side.property.name === "current";
3752
+ const isNullSide = (side) => side.type === AST_NODE_TYPES.Literal && side.value == null;
3753
+ return isRefSide(left) && isNullSide(right) || isRefSide(right) && isNullSide(left);
3754
+ }
3755
+ /**
3756
+ * Check if the node is the operand of a `ref.current === null` test inside an IfStatement.
3757
+ * @param node The MemberExpression node for ref.current
3758
+ * @returns true if the node is part of a null check test in an if statement
3759
+ */
3760
+ function isInNullCheckTest(node) {
3761
+ const { parent } = node;
3762
+ if (parent.type !== AST_NODE_TYPES.BinaryExpression) return false;
3763
+ if (!isNullCheckOperator(parent.operator)) return false;
3764
+ const otherSide = parent.left === node ? parent.right : parent.left;
3765
+ if (otherSide.type !== AST_NODE_TYPES.Literal || otherSide.value != null) return false;
3766
+ return parent.parent.type === AST_NODE_TYPES.IfStatement && parent.parent.test === parent;
3767
+ }
3768
+ /**
3769
+ * Walk up from the node to find a containing IfStatement whose test is a null-check
3770
+ * on `ref.current` with the given ref name.
3771
+ * @param node The MemberExpression node for ref.current
3772
+ * @param refName The name of the ref variable (e.g. "myRef") to check against
3773
+ * @returns the enclosing IfStatement node if found, or null if not found
3774
+ */
3775
+ function findEnclosingRefNullCheckIf(node, refName) {
3776
+ let current = node.parent;
3777
+ while (current != null) {
3778
+ if (current.type === AST_NODE_TYPES.IfStatement) return isRefCurrentNullCheck(current.test, refName) ? current : null;
3779
+ switch (current.type) {
3780
+ case AST_NODE_TYPES.ExpressionStatement:
3781
+ case AST_NODE_TYPES.BlockStatement:
3782
+ case AST_NODE_TYPES.ReturnStatement:
3783
+ case AST_NODE_TYPES.JSXExpressionContainer:
3784
+ case AST_NODE_TYPES.JSXElement:
3785
+ case AST_NODE_TYPES.JSXOpeningElement:
3786
+ case AST_NODE_TYPES.JSXClosingElement:
3787
+ case AST_NODE_TYPES.AssignmentExpression:
3788
+ case AST_NODE_TYPES.VariableDeclaration:
3789
+ case AST_NODE_TYPES.VariableDeclarator:
3790
+ case AST_NODE_TYPES.MemberExpression:
3791
+ case AST_NODE_TYPES.ChainExpression:
3792
+ case AST_NODE_TYPES.CallExpression: break;
3793
+ default: return null;
3794
+ }
3795
+ current = current.parent;
3796
+ }
3797
+ return null;
3798
+ }
3799
+ /**
3800
+ * Check if a write to `ref.current` comes after a sibling if-statement that null-checks
3801
+ * the same ref (inverted lazy init with early return pattern):
3802
+ *
3803
+ * if (ref.current !== null) { return ...; }
3804
+ * ref.current = value; // ← this write
3805
+ * @param node The MemberExpression node for ref.current being written to
3806
+ * @param refName The name of the ref variable (e.g. "myRef") to check against
3807
+ * @returns true if there is a preceding sibling if-statement that null-checks the same ref
3808
+ */
3809
+ function isWriteAfterNullCheckIf(node, refName) {
3810
+ let stmt = node;
3811
+ while (stmt.parent != null && stmt.parent.type !== AST_NODE_TYPES.BlockStatement) stmt = stmt.parent;
3812
+ if (stmt.parent?.type !== AST_NODE_TYPES.BlockStatement) return false;
3813
+ const block = stmt.parent;
3814
+ const stmtIdx = block.body.indexOf(stmt);
3815
+ if (stmtIdx < 0) return false;
3816
+ for (let i = stmtIdx - 1; i >= 0; i--) {
3817
+ const sibling = block.body[i];
3818
+ if (sibling == null) continue;
3819
+ if (sibling.type === AST_NODE_TYPES.IfStatement && isRefCurrentNullCheck(sibling.test, refName)) return true;
3820
+ }
3821
+ return false;
3822
+ }
3823
+ var refs_default = createRule({
3824
+ meta: {
3825
+ type: "problem",
3826
+ docs: { description: "Validates correct usage of refs by checking that 'ref.current' is not read or written during render." },
3827
+ messages: {
3828
+ readDuringRender: "Do not read 'ref.current' during render. Refs are not available during rendering and their values may be stale or inconsistent. Move this read into an effect or event handler.",
3829
+ writeDuringRender: "Do not write to 'ref.current' during render. Refs should only be mutated in effects or event handlers. Move this write into an effect or event handler."
3830
+ },
3831
+ schema: []
3832
+ },
3833
+ name: RULE_NAME$6,
3834
+ create: create$6,
3835
+ defaultOptions: []
3836
+ });
3837
+ function create$6(context) {
3838
+ const hCollector = core.useHookCollector(context);
3839
+ const cCollector = core.useComponentCollector(context);
3840
+ const refAccesses = [];
3841
+ const jsxRefIdentifiers = /* @__PURE__ */ new Set();
3842
+ function isRefIdentifier(node) {
3843
+ if (node.type !== AST_NODE_TYPES.Identifier) return false;
3844
+ if (core.isRefLikeName(node.name)) return true;
3845
+ if (jsxRefIdentifiers.has(node.name)) return true;
3846
+ return core.isInitializedFromRef(node.name, context.sourceCode.getScope(node));
3847
+ }
3848
+ return defineRuleListener(hCollector.visitor, cCollector.visitor, {
3849
+ JSXAttribute(node) {
3850
+ if (node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name === "ref" && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && node.value.expression.type === AST_NODE_TYPES.Identifier) jsxRefIdentifiers.add(node.value.expression.name);
3851
+ },
3852
+ MemberExpression(node) {
3853
+ if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== "current") return;
3854
+ refAccesses.push({
3855
+ node,
3856
+ isWrite: isWriteAccess(node)
3857
+ });
3858
+ },
3859
+ "Program:exit"(program) {
3860
+ const components = cCollector.ctx.getAllComponents(program);
3861
+ const hooks = hCollector.ctx.getAllHooks(program);
3862
+ const componentAndHookFns = new Set([...components.map((c) => c.node), ...hooks.map((h) => h.node)]);
3863
+ const isComponentOrHookFn = (n) => ast.isFunction(n) && componentAndHookFns.has(n);
3864
+ for (const { node, isWrite } of refAccesses) {
3865
+ if (!isRefIdentifier(node.object)) continue;
3866
+ const boundary = ast.findParentNode(node, isComponentOrHookFn);
3867
+ if (boundary == null) continue;
3868
+ if (isInsideNestedFunction(node, boundary)) continue;
3869
+ if (isPartOfLazyInitialization(node, isWrite)) continue;
3870
+ context.report({
3871
+ messageId: isWrite ? "writeDuringRender" : "readDuringRender",
3872
+ node
3873
+ });
3874
+ }
3875
+ }
3876
+ });
3877
+ }
3878
+
3765
3879
  //#endregion
3766
3880
  //#region src/rules/rules-of-hooks.ts
3767
- const RULE_NAME$2 = "rules-of-hooks";
3881
+ const RULE_NAME$5 = "rules-of-hooks";
3768
3882
  var rules_of_hooks_default = createRule({
3769
3883
  meta: {
3770
3884
  type: "problem",
@@ -3782,8 +3896,8 @@ var rules_of_hooks_default = createRule({
3782
3896
  },
3783
3897
  schema: []
3784
3898
  },
3785
- name: RULE_NAME$2,
3786
- create: create$2,
3899
+ name: RULE_NAME$5,
3900
+ create: create$5,
3787
3901
  defaultOptions: []
3788
3902
  });
3789
3903
  function getHookName(node) {
@@ -3818,7 +3932,7 @@ function isLoopNode(node) {
3818
3932
  function isTryCatchNode(node) {
3819
3933
  return node.type === AST_NODE_TYPES.TryStatement;
3820
3934
  }
3821
- function create$2(context) {
3935
+ function create$5(context) {
3822
3936
  const functionStack = [];
3823
3937
  function findEnclosingComponentOrHook() {
3824
3938
  for (let i = functionStack.length - 1; i >= 0; i--) {
@@ -3934,7 +4048,7 @@ function create$2(context) {
3934
4048
  return;
3935
4049
  }
3936
4050
  }
3937
- return {
4051
+ return defineRuleListener({
3938
4052
  ":function"(node) {
3939
4053
  const kind = getFunctionEntryKind(node);
3940
4054
  functionStack.push({
@@ -3966,24 +4080,24 @@ function create$2(context) {
3966
4080
  const idx = body.indexOf(stmt);
3967
4081
  if (idx !== -1 && idx < body.length - 1) entry.hasEarlyReturn = true;
3968
4082
  }
3969
- };
4083
+ });
3970
4084
  }
3971
4085
 
3972
4086
  //#endregion
3973
4087
  //#region src/rules/set-state-in-effect.ts
3974
- const RULE_NAME$1 = "set-state-in-effect";
4088
+ const RULE_NAME$4 = "set-state-in-effect";
3975
4089
  var set_state_in_effect_default = createRule({
3976
4090
  meta: {
3977
4091
  type: "problem",
3978
- docs: { description: "Validates against calling ['setState'](https://react.dev/reference/react/useState#setstate) synchronously in an effect, which can lead to re-renders that degrade performance." },
4092
+ docs: { description: "Validates against setting state synchronously in an effect, which can lead to re-renders that degrade performance." },
3979
4093
  messages: { default: "Do not call the 'set' function '{{name}}' of 'useState' synchronously in an effect. This can lead to unnecessary re-renders and performance issues." },
3980
4094
  schema: []
3981
4095
  },
3982
- name: RULE_NAME$1,
3983
- create: create$1,
4096
+ name: RULE_NAME$4,
4097
+ create: create$4,
3984
4098
  defaultOptions: []
3985
4099
  });
3986
- function create$1(context) {
4100
+ function create$4(context) {
3987
4101
  if (!/use\w*Effect/u.test(context.sourceCode.text)) return {};
3988
4102
  const { additionalStateHooks } = getSettingsFromContext(context);
3989
4103
  const functionEntries = [];
@@ -4028,7 +4142,7 @@ function create$1(context) {
4028
4142
  }
4029
4143
  }
4030
4144
  function isIdFromUseStateCall(topLevelId, at) {
4031
- const variableNode = getVariableDefinitionNode(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
4145
+ const variableNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
4032
4146
  if (variableNode == null) return false;
4033
4147
  if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
4034
4148
  if (!isUseStateCall(variableNode)) return false;
@@ -4056,7 +4170,18 @@ function create$1(context) {
4056
4170
  default: return false;
4057
4171
  }
4058
4172
  }
4059
- return {
4173
+ function isHookDecl(node) {
4174
+ if (node.type !== AST_NODE_TYPES.VariableDeclarator) return false;
4175
+ if (node.id.type !== AST_NODE_TYPES.Identifier) return false;
4176
+ const init = node.init;
4177
+ if (init == null || init.type !== AST_NODE_TYPES.CallExpression) return false;
4178
+ switch (init.callee.type) {
4179
+ case AST_NODE_TYPES.Identifier: return core.isHookName(init.callee.name);
4180
+ case AST_NODE_TYPES.MemberExpression: return init.callee.property.type === AST_NODE_TYPES.Identifier && core.isHookName(init.callee.property.name);
4181
+ default: return false;
4182
+ }
4183
+ }
4184
+ return defineRuleListener({
4060
4185
  ":function"(node) {
4061
4186
  const kind = getFunctionKind(node);
4062
4187
  functionEntries.push({
@@ -4079,15 +4204,31 @@ function create$1(context) {
4079
4204
  case entry.kind === "deferred":
4080
4205
  case entry.node.async: break;
4081
4206
  case entry.node === setupFunction:
4082
- case entry.kind === "immediate" && ast.findParentNode(entry.node, ast.isFunction) === setupFunction:
4207
+ case entry.kind === "immediate" && ast.findParentNode(entry.node, ast.isFunction) === setupFunction: {
4208
+ const args0 = node.arguments.at(0);
4209
+ if (args0 == null) return;
4210
+ function isArgumentUsingRefValue(context, node) {
4211
+ const isUsingRefValue = (n) => {
4212
+ switch (n.type) {
4213
+ case AST_NODE_TYPES.Identifier: return core.isInitializedFromRef(n.name, context.sourceCode.getScope(n));
4214
+ case AST_NODE_TYPES.MemberExpression: return isUsingRefValue(n.object);
4215
+ case AST_NODE_TYPES.CallExpression: return isUsingRefValue(n.callee) || ast.getNestedIdentifiers(n).some(isUsingRefValue);
4216
+ default: return false;
4217
+ }
4218
+ };
4219
+ if (isUsingRefValue(node)) return true;
4220
+ return ast.isFunction(node) && context.sourceCode.getScope(node.body).references.some((r) => isUsingRefValue(r.identifier));
4221
+ }
4222
+ if (isArgumentUsingRefValue(context, args0)) return;
4083
4223
  context.report({
4084
4224
  messageId: "default",
4085
4225
  node,
4086
4226
  data: { name: context.sourceCode.getText(node.callee) }
4087
4227
  });
4088
4228
  return;
4229
+ }
4089
4230
  default: {
4090
- const init = ast.findParentNode(node, isVariableDeclaratorFromHookCall)?.init;
4231
+ const init = ast.findParentNode(node, isHookDecl)?.init;
4091
4232
  if (init == null) getOrElseUpdate(setStateCallsByFn, entry.node, () => []).push(node);
4092
4233
  else getOrElseUpdate(setStateInHookCallbacks, init, () => []).push(node);
4093
4234
  }
@@ -4108,14 +4249,14 @@ function create$1(context) {
4108
4249
  const parent = node.parent.parent;
4109
4250
  if (parent.type !== AST_NODE_TYPES.CallExpression) break;
4110
4251
  if (!core.isUseMemoCall(parent)) break;
4111
- const init = ast.findParentNode(parent, isVariableDeclaratorFromHookCall)?.init;
4252
+ const init = ast.findParentNode(parent, isHookDecl)?.init;
4112
4253
  if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
4113
4254
  break;
4114
4255
  }
4115
4256
  case AST_NODE_TYPES.CallExpression:
4116
4257
  if (node !== node.parent.arguments.at(0)) break;
4117
4258
  if (core.isUseCallbackCall(node.parent)) {
4118
- const init = ast.findParentNode(node.parent, isVariableDeclaratorFromHookCall)?.init;
4259
+ const init = ast.findParentNode(node.parent, isHookDecl)?.init;
4119
4260
  if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
4120
4261
  break;
4121
4262
  }
@@ -4124,7 +4265,7 @@ function create$1(context) {
4124
4265
  },
4125
4266
  "Program:exit"() {
4126
4267
  const getSetStateCalls = (id, initialScope) => {
4127
- const node = getVariableDefinitionNode(findVariable(id, initialScope), 0);
4268
+ const node = getVariableInitializer(findVariable(id, initialScope), 0);
4128
4269
  switch (node?.type) {
4129
4270
  case AST_NODE_TYPES.ArrowFunctionExpression:
4130
4271
  case AST_NODE_TYPES.FunctionDeclaration:
@@ -4157,25 +4298,12 @@ function create$1(context) {
4157
4298
  });
4158
4299
  }
4159
4300
  }
4160
- };
4161
- }
4162
- function isInitFromHookCall(init) {
4163
- if (init?.type !== AST_NODE_TYPES.CallExpression) return false;
4164
- switch (init.callee.type) {
4165
- case AST_NODE_TYPES.Identifier: return core.isHookName(init.callee.name);
4166
- case AST_NODE_TYPES.MemberExpression: return init.callee.property.type === AST_NODE_TYPES.Identifier && core.isHookName(init.callee.property.name);
4167
- default: return false;
4168
- }
4169
- }
4170
- function isVariableDeclaratorFromHookCall(node) {
4171
- if (node.type !== AST_NODE_TYPES.VariableDeclarator) return false;
4172
- if (node.id.type !== AST_NODE_TYPES.Identifier) return false;
4173
- return isInitFromHookCall(node.init);
4301
+ });
4174
4302
  }
4175
4303
 
4176
4304
  //#endregion
4177
4305
  //#region src/rules/set-state-in-render.ts
4178
- const RULE_NAME = "set-state-in-render";
4306
+ const RULE_NAME$3 = "set-state-in-render";
4179
4307
  var set_state_in_render_default = createRule({
4180
4308
  meta: {
4181
4309
  type: "problem",
@@ -4183,11 +4311,11 @@ var set_state_in_render_default = createRule({
4183
4311
  messages: { default: "Do not call the 'set' function '{{name}}' unconditionally during render. This will trigger an infinite render loop." },
4184
4312
  schema: []
4185
4313
  },
4186
- name: RULE_NAME,
4187
- create,
4314
+ name: RULE_NAME$3,
4315
+ create: create$3,
4188
4316
  defaultOptions: []
4189
4317
  });
4190
- function create(context) {
4318
+ function create$3(context) {
4191
4319
  const { additionalStateHooks } = getSettingsFromContext(context);
4192
4320
  const functionEntries = [];
4193
4321
  const componentFnRef = { current: null };
@@ -4196,7 +4324,7 @@ function create(context) {
4196
4324
  return core.isUseStateLikeCall(node, additionalStateHooks);
4197
4325
  }
4198
4326
  function isIdFromUseStateCall(topLevelId, at) {
4199
- const variableNode = getVariableDefinitionNode(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
4327
+ const variableNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
4200
4328
  if (variableNode == null) return false;
4201
4329
  if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
4202
4330
  if (!isUseStateCall(variableNode)) return false;
@@ -4247,20 +4375,20 @@ function create(context) {
4247
4375
  }
4248
4376
  return false;
4249
4377
  }
4250
- function isComponentLikeFunction(node) {
4378
+ function isComponentOrHookLikeFunction(node) {
4251
4379
  const id = ast.getFunctionId(node);
4252
4380
  if (id == null) return false;
4253
- if (id.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.name);
4254
- if (id.type === AST_NODE_TYPES.MemberExpression && id.property.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.property.name);
4381
+ if (id.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.name) || core.isHookName(id.name);
4382
+ if (id.type === AST_NODE_TYPES.MemberExpression && id.property.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.property.name) || core.isHookName(id.property.name);
4255
4383
  return false;
4256
4384
  }
4257
4385
  function getFunctionKind(node) {
4258
- if (isComponentLikeFunction(node)) return "component";
4386
+ if (isComponentOrHookLikeFunction(node)) return "component";
4259
4387
  const parent = ast.findParentNode(node, not(ast.isTypeExpression)) ?? node.parent;
4260
4388
  if (parent.type === AST_NODE_TYPES.CallExpression && parent.callee !== node) return "callback";
4261
4389
  return "other";
4262
4390
  }
4263
- return {
4391
+ return defineRuleListener({
4264
4392
  ":function"(node) {
4265
4393
  const kind = getFunctionKind(node);
4266
4394
  functionEntries.push({
@@ -4307,7 +4435,260 @@ function create(context) {
4307
4435
  const idx = body.indexOf(stmt);
4308
4436
  if (idx !== -1 && idx < body.length - 1) componentHasEarlyReturn.current = true;
4309
4437
  }
4310
- };
4438
+ });
4439
+ }
4440
+
4441
+ //#endregion
4442
+ //#region src/rules/unsupported-syntax.ts
4443
+ const RULE_NAME$2 = "unsupported-syntax";
4444
+ var unsupported_syntax_default = createRule({
4445
+ meta: {
4446
+ type: "problem",
4447
+ docs: { description: "Validates against syntax that React Compiler does not support." },
4448
+ messages: {
4449
+ eval: "Do not use 'eval' inside components or hooks. 'eval' cannot be statically analyzed and is not supported by React Compiler.",
4450
+ iife: "Do not use immediately-invoked function expressions in JSX. IIFEs will not be optimized by React Compiler.",
4451
+ with: "Do not use 'with' statements inside components or hooks. 'with' changes scope dynamically and is not supported by React Compiler."
4452
+ },
4453
+ schema: []
4454
+ },
4455
+ name: RULE_NAME$2,
4456
+ create: create$2,
4457
+ defaultOptions: []
4458
+ });
4459
+ function isEvalCall(node) {
4460
+ return node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "eval";
4461
+ }
4462
+ function isIifeCall(node) {
4463
+ return node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
4464
+ }
4465
+ function create$2(context) {
4466
+ const hCollector = core.useHookCollector(context);
4467
+ const cCollector = core.useComponentCollector(context);
4468
+ const evalCalls = [];
4469
+ const withStmts = [];
4470
+ return defineRuleListener(hCollector.visitor, cCollector.visitor, {
4471
+ CallExpression(node) {
4472
+ if (!isEvalCall(node)) return;
4473
+ const func = ast.findParentNode(node, ast.isFunction);
4474
+ if (func == null) return;
4475
+ evalCalls.push({
4476
+ node,
4477
+ func
4478
+ });
4479
+ },
4480
+ "JSXElement :function"(node) {
4481
+ if (isIifeCall(node)) context.report({
4482
+ messageId: "iife",
4483
+ node: node.parent
4484
+ });
4485
+ },
4486
+ "JSXFragment :function"(node) {
4487
+ if (isIifeCall(node)) context.report({
4488
+ messageId: "iife",
4489
+ node: node.parent
4490
+ });
4491
+ },
4492
+ "Program:exit"(node) {
4493
+ const components = cCollector.ctx.getAllComponents(node);
4494
+ const hooks = hCollector.ctx.getAllHooks(node);
4495
+ const funcs = [...components, ...hooks];
4496
+ for (const { node, func } of evalCalls) {
4497
+ if (!funcs.some((f) => f.node === func)) continue;
4498
+ context.report({
4499
+ messageId: "eval",
4500
+ node
4501
+ });
4502
+ }
4503
+ for (const { node, func } of withStmts) {
4504
+ if (!funcs.some((f) => f.node === func)) continue;
4505
+ context.report({
4506
+ messageId: "with",
4507
+ node
4508
+ });
4509
+ }
4510
+ },
4511
+ WithStatement(node) {
4512
+ const func = ast.findParentNode(node, ast.isFunction);
4513
+ if (func == null) return;
4514
+ withStmts.push({
4515
+ node,
4516
+ func
4517
+ });
4518
+ }
4519
+ });
4520
+ }
4521
+
4522
+ //#endregion
4523
+ //#region src/rules/use-memo.ts
4524
+ const RULE_NAME$1 = "use-memo";
4525
+ var use_memo_default = createRule({
4526
+ meta: {
4527
+ type: "problem",
4528
+ docs: { description: "Validates that 'useMemo' is called with a callback that returns a value." },
4529
+ messages: {
4530
+ missingReturnValue: "The callback passed to 'useMemo' must return a value. Without a return value, 'useMemo' always returns 'undefined', which defeats its purpose.",
4531
+ notAssignedToVariable: "The return value of 'useMemo' must be assigned to a variable. Calling 'useMemo' without capturing its return value is likely a mistake — use 'useEffect' for side effects instead."
4532
+ },
4533
+ schema: []
4534
+ },
4535
+ name: RULE_NAME$1,
4536
+ create: create$1,
4537
+ defaultOptions: []
4538
+ });
4539
+ function create$1(context) {
4540
+ if (!context.sourceCode.text.includes("useMemo")) return {};
4541
+ return defineRuleListener({ CallExpression(node) {
4542
+ if (!core.isUseMemoCall(node)) return;
4543
+ const parent = node.parent;
4544
+ if (!(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)) {
4545
+ context.report({
4546
+ messageId: "notAssignedToVariable",
4547
+ node
4548
+ });
4549
+ return;
4550
+ }
4551
+ const [callbackArg] = node.arguments;
4552
+ if (callbackArg == null) return;
4553
+ if (!ast.isFunction(callbackArg)) return;
4554
+ if (callbackArg.type === AST_NODE_TYPES.ArrowFunctionExpression && callbackArg.body.type !== AST_NODE_TYPES.BlockStatement) return;
4555
+ if (callbackArg.body.type !== AST_NODE_TYPES.BlockStatement) return;
4556
+ const returnStatements = ast.getNestedReturnStatements(callbackArg);
4557
+ if (returnStatements.length === 0) {
4558
+ context.report({
4559
+ messageId: "missingReturnValue",
4560
+ node: callbackArg
4561
+ });
4562
+ return;
4563
+ }
4564
+ if (!returnStatements.some((stmt) => stmt.argument != null)) context.report({
4565
+ messageId: "missingReturnValue",
4566
+ node: callbackArg
4567
+ });
4568
+ } });
4569
+ }
4570
+
4571
+ //#endregion
4572
+ //#region src/rules/use-state.ts
4573
+ const RULE_NAME = "use-state";
4574
+ const defaultOptions = [{
4575
+ enforceAssignment: true,
4576
+ enforceLazyInitialization: true,
4577
+ enforceSetterName: true
4578
+ }];
4579
+ const schema = [{
4580
+ type: "object",
4581
+ additionalProperties: false,
4582
+ properties: {
4583
+ enforceAssignment: {
4584
+ type: "boolean",
4585
+ default: true
4586
+ },
4587
+ enforceLazyInitialization: {
4588
+ type: "boolean",
4589
+ default: true
4590
+ },
4591
+ enforceSetterName: {
4592
+ type: "boolean",
4593
+ default: true
4594
+ }
4595
+ }
4596
+ }];
4597
+ const LAZY_INIT_ALLOW_LIST = [
4598
+ "Boolean",
4599
+ "String",
4600
+ "Number"
4601
+ ];
4602
+ var use_state_default = createRule({
4603
+ meta: {
4604
+ type: "suggestion",
4605
+ docs: { description: "Enforces correct usage of 'useState', including destructuring, symmetric naming of the value and setter, and wrapping expensive initializers in a lazy initializer function." },
4606
+ messages: {
4607
+ invalidAssignment: "useState should be destructured into a value and setter pair, e.g., const [state, setState] = useState(...).",
4608
+ invalidInitialization: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'.",
4609
+ invalidSetterName: "The setter should be named 'set' followed by the capitalized state variable name, e.g., 'setState' for 'state'."
4610
+ },
4611
+ schema
4612
+ },
4613
+ name: RULE_NAME,
4614
+ create,
4615
+ defaultOptions
4616
+ });
4617
+ function create(context) {
4618
+ if (!context.sourceCode.text.includes("useState")) return {};
4619
+ const { enforceAssignment = true, enforceLazyInitialization = true, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
4620
+ return defineRuleListener({ CallExpression(node) {
4621
+ if (!core.isUseStateCall(node)) return;
4622
+ if (enforceLazyInitialization) {
4623
+ const [useStateInput] = node.arguments;
4624
+ if (useStateInput != null) {
4625
+ for (const expr of ast.getNestedNewExpressions(useStateInput)) {
4626
+ if (!("name" in expr.callee)) continue;
4627
+ if (LAZY_INIT_ALLOW_LIST.includes(expr.callee.name)) continue;
4628
+ if (ast.findParentNode(expr, core.isUseCall) != null) continue;
4629
+ context.report({
4630
+ messageId: "invalidInitialization",
4631
+ node: expr
4632
+ });
4633
+ }
4634
+ for (const expr of ast.getNestedCallExpressions(useStateInput)) {
4635
+ if (!("name" in expr.callee)) continue;
4636
+ if (core.isHookName(expr.callee.name)) continue;
4637
+ if (LAZY_INIT_ALLOW_LIST.includes(expr.callee.name)) continue;
4638
+ if (ast.findParentNode(expr, core.isUseCall) != null) continue;
4639
+ context.report({
4640
+ messageId: "invalidInitialization",
4641
+ node: expr
4642
+ });
4643
+ }
4644
+ }
4645
+ }
4646
+ if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) {
4647
+ if (!enforceAssignment) return;
4648
+ context.report({
4649
+ messageId: "invalidAssignment",
4650
+ node
4651
+ });
4652
+ return;
4653
+ }
4654
+ const id = findEnclosingAssignmentTarget(node);
4655
+ if (id?.type !== AST_NODE_TYPES.ArrayPattern) {
4656
+ if (!enforceAssignment) return;
4657
+ context.report({
4658
+ messageId: "invalidAssignment",
4659
+ node: id ?? node
4660
+ });
4661
+ return;
4662
+ }
4663
+ const [value, setter] = id.elements;
4664
+ if (value == null) {
4665
+ if (!enforceAssignment) return;
4666
+ context.report({
4667
+ messageId: "invalidAssignment",
4668
+ node: id
4669
+ });
4670
+ return;
4671
+ }
4672
+ if (setter == null || !enforceSetterName) return;
4673
+ if (value.type !== AST_NODE_TYPES.Identifier) {
4674
+ context.report({
4675
+ messageId: "invalidAssignment",
4676
+ node: value
4677
+ });
4678
+ return;
4679
+ }
4680
+ if (setter.type !== AST_NODE_TYPES.Identifier || !setter.name.startsWith("set")) {
4681
+ context.report({
4682
+ messageId: "invalidSetterName",
4683
+ node: setter
4684
+ });
4685
+ return;
4686
+ }
4687
+ if (snakeCase(setter.name) !== `set_${snakeCase(value.name)}`) context.report({
4688
+ messageId: "invalidSetterName",
4689
+ node: setter
4690
+ });
4691
+ } });
4311
4692
  }
4312
4693
 
4313
4694
  //#endregion
@@ -4325,7 +4706,6 @@ const plugin = {
4325
4706
  "jsx-key-before-spread": jsx_key_before_spread_default,
4326
4707
  "jsx-no-comment-textnodes": jsx_no_comment_textnodes_default,
4327
4708
  "jsx-no-duplicate-props": jsx_no_duplicate_props_default,
4328
- "jsx-no-iife": jsx_no_iife_default,
4329
4709
  "jsx-no-undef": jsx_no_undef_default,
4330
4710
  "jsx-shorthand-boolean": jsx_shorthand_boolean_default,
4331
4711
  "jsx-shorthand-fragment": jsx_shorthand_fragment_default,
@@ -4354,6 +4734,7 @@ const plugin = {
4354
4734
  "no-missing-component-display-name": no_missing_component_display_name_default,
4355
4735
  "no-missing-context-display-name": no_missing_context_display_name_default,
4356
4736
  "no-missing-key": no_missing_key_default,
4737
+ "use-memo": use_memo_default,
4357
4738
  "no-misused-capture-owner-stack": no_misused_capture_owner_stack_default,
4358
4739
  "no-nested-component-definitions": no_nested_component_definitions_default,
4359
4740
  "no-nested-lazy-component-declarations": no_nested_lazy_component_declarations_default,
@@ -4378,11 +4759,13 @@ const plugin = {
4378
4759
  "prefer-destructuring-assignment": prefer_destructuring_assignment_default,
4379
4760
  "prefer-namespace-import": prefer_namespace_import_default,
4380
4761
  "prefer-read-only-props": prefer_read_only_props_default,
4381
- "prefer-use-state-lazy-initialization": prefer_use_state_lazy_initialization_default,
4382
4762
  purity: purity_default,
4763
+ refs: refs_default,
4383
4764
  "rules-of-hooks": rules_of_hooks_default,
4384
4765
  "set-state-in-effect": set_state_in_effect_default,
4385
- "set-state-in-render": set_state_in_render_default
4766
+ "set-state-in-render": set_state_in_render_default,
4767
+ "unsupported-syntax": unsupported_syntax_default,
4768
+ "use-state": use_state_default
4386
4769
  }
4387
4770
  };
4388
4771
 
@@ -4420,6 +4803,8 @@ const rules$6 = {
4420
4803
  "react-x/no-direct-mutation-state": "error",
4421
4804
  "react-x/no-forward-ref": "warn",
4422
4805
  "react-x/no-missing-key": "error",
4806
+ "react-x/use-memo": "error",
4807
+ "react-x/use-state": "warn",
4423
4808
  "react-x/no-nested-component-definitions": "error",
4424
4809
  "react-x/no-nested-lazy-component-declarations": "error",
4425
4810
  "react-x/no-redundant-should-component-update": "error",
@@ -4432,11 +4817,11 @@ const rules$6 = {
4432
4817
  "react-x/no-unsafe-component-will-update": "warn",
4433
4818
  "react-x/no-use-context": "warn",
4434
4819
  "react-x/no-useless-forward-ref": "warn",
4435
- "react-x/prefer-use-state-lazy-initialization": "warn",
4436
4820
  "react-x/purity": "warn",
4437
4821
  "react-x/rules-of-hooks": "error",
4438
4822
  "react-x/set-state-in-effect": "warn",
4439
- "react-x/set-state-in-render": "error"
4823
+ "react-x/set-state-in-render": "error",
4824
+ "react-x/unsupported-syntax": "error"
4440
4825
  };
4441
4826
  const plugins$5 = { "react-x": plugin };
4442
4827
  const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
@@ -4497,7 +4882,6 @@ var strict_exports = /* @__PURE__ */ __exportAll({
4497
4882
  const name$2 = "react-x/strict";
4498
4883
  const rules$2 = {
4499
4884
  ...rules$6,
4500
- "react-x/jsx-no-iife": "error",
4501
4885
  "react-x/no-children-prop": "error",
4502
4886
  "react-x/no-class-component": "error",
4503
4887
  "react-x/no-misused-capture-owner-stack": "error",