eslint-plugin-react-x 2.5.7 → 2.5.8

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 +231 -193
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { AST_NODE_TYPES } from "@typescript-eslint/types";
3
3
  import { ESLintUtils } from "@typescript-eslint/utils";
4
4
  import { P, isMatching, match } from "ts-pattern";
5
5
  import ts from "typescript";
6
- import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findParentJsxAttribute, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInstanceIdEqual, isJsxFragmentElement, isJsxHostElement, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseEffectLikeCall, isUseMemoCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
6
+ import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findEnclosingAssignmentTarget, findParentJsxAttribute, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInstanceIdEqual, isJsxFragmentElement, isJsxHostElement, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseEffectLikeCall, isUseMemoCall, isUseRefCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
7
7
  import * as AST from "@eslint-react/ast";
8
8
  import { findVariable, getChildScopes, getObjectType, getVariableDefinitionNode } from "@eslint-react/var";
9
9
  import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
@@ -34,7 +34,7 @@ var __exportAll = (all, symbols) => {
34
34
  //#endregion
35
35
  //#region package.json
36
36
  var name$6 = "eslint-plugin-react-x";
37
- var version = "2.5.7";
37
+ var version = "2.5.8";
38
38
 
39
39
  //#endregion
40
40
  //#region src/utils/create-rule.ts
@@ -138,7 +138,7 @@ function getTypeVariants(types) {
138
138
 
139
139
  //#endregion
140
140
  //#region src/rules/jsx-dollar.ts
141
- const RULE_NAME$62 = "jsx-dollar";
141
+ const RULE_NAME$63 = "jsx-dollar";
142
142
  var jsx_dollar_default = createRule({
143
143
  meta: {
144
144
  type: "problem",
@@ -151,11 +151,11 @@ var jsx_dollar_default = createRule({
151
151
  },
152
152
  schema: []
153
153
  },
154
- name: RULE_NAME$62,
155
- create: create$62,
154
+ name: RULE_NAME$63,
155
+ create: create$63,
156
156
  defaultOptions: []
157
157
  });
158
- function create$62(context) {
158
+ function create$63(context) {
159
159
  /**
160
160
  * Visitor function for JSXElement and JSXFragment nodes
161
161
  * @param node The JSXElement or JSXFragment node to be checked
@@ -196,7 +196,7 @@ function create$62(context) {
196
196
 
197
197
  //#endregion
198
198
  //#region src/rules/jsx-key-before-spread.ts
199
- const RULE_NAME$61 = "jsx-key-before-spread";
199
+ const RULE_NAME$62 = "jsx-key-before-spread";
200
200
  var jsx_key_before_spread_default = createRule({
201
201
  meta: {
202
202
  type: "problem",
@@ -204,11 +204,11 @@ var jsx_key_before_spread_default = createRule({
204
204
  messages: { jsxKeyBeforeSpread: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
205
205
  schema: []
206
206
  },
207
- name: RULE_NAME$61,
208
- create: create$61,
207
+ name: RULE_NAME$62,
208
+ create: create$62,
209
209
  defaultOptions: []
210
210
  });
211
- function create$61(context) {
211
+ function create$62(context) {
212
212
  const { jsx } = {
213
213
  ...getJsxConfigFromContext(context),
214
214
  ...getJsxConfigFromAnnotation(context)
@@ -232,7 +232,7 @@ function create$61(context) {
232
232
 
233
233
  //#endregion
234
234
  //#region src/rules/jsx-no-comment-textnodes.ts
235
- const RULE_NAME$60 = "jsx-no-comment-textnodes";
235
+ const RULE_NAME$61 = "jsx-no-comment-textnodes";
236
236
  var jsx_no_comment_textnodes_default = createRule({
237
237
  meta: {
238
238
  type: "problem",
@@ -240,11 +240,11 @@ var jsx_no_comment_textnodes_default = createRule({
240
240
  messages: { jsxNoCommentTextnodes: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
241
241
  schema: []
242
242
  },
243
- name: RULE_NAME$60,
244
- create: create$60,
243
+ name: RULE_NAME$61,
244
+ create: create$61,
245
245
  defaultOptions: []
246
246
  });
247
- function create$60(context) {
247
+ function create$61(context) {
248
248
  function hasCommentLike(node) {
249
249
  if (AST.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
250
250
  return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
@@ -265,7 +265,7 @@ function create$60(context) {
265
265
 
266
266
  //#endregion
267
267
  //#region src/rules/jsx-no-duplicate-props.ts
268
- const RULE_NAME$59 = "jsx-no-duplicate-props";
268
+ const RULE_NAME$60 = "jsx-no-duplicate-props";
269
269
  var jsx_no_duplicate_props_default = createRule({
270
270
  meta: {
271
271
  type: "problem",
@@ -273,11 +273,11 @@ var jsx_no_duplicate_props_default = createRule({
273
273
  messages: { jsxNoDuplicateProps: "This JSX property is assigned multiple times." },
274
274
  schema: []
275
275
  },
276
- name: RULE_NAME$59,
277
- create: create$59,
276
+ name: RULE_NAME$60,
277
+ create: create$60,
278
278
  defaultOptions: []
279
279
  });
280
- function create$59(context) {
280
+ function create$60(context) {
281
281
  return { JSXOpeningElement(node) {
282
282
  const props = [];
283
283
  for (const attr of node.attributes) {
@@ -298,7 +298,7 @@ function create$59(context) {
298
298
 
299
299
  //#endregion
300
300
  //#region src/rules/jsx-no-iife.ts
301
- const RULE_NAME$58 = "jsx-no-iife";
301
+ const RULE_NAME$59 = "jsx-no-iife";
302
302
  var jsx_no_iife_default = createRule({
303
303
  meta: {
304
304
  type: "problem",
@@ -306,11 +306,11 @@ var jsx_no_iife_default = createRule({
306
306
  messages: { jsxNoIife: "Avoid using IIFE in JSX." },
307
307
  schema: []
308
308
  },
309
- name: RULE_NAME$58,
310
- create: create$58,
309
+ name: RULE_NAME$59,
310
+ create: create$59,
311
311
  defaultOptions: []
312
312
  });
313
- function create$58(context) {
313
+ function create$59(context) {
314
314
  return {
315
315
  "JSXElement :function"(node) {
316
316
  if (node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node) context.report({
@@ -329,7 +329,7 @@ function create$58(context) {
329
329
 
330
330
  //#endregion
331
331
  //#region src/rules/jsx-no-undef.ts
332
- const RULE_NAME$57 = "jsx-no-undef";
332
+ const RULE_NAME$58 = "jsx-no-undef";
333
333
  var jsx_no_undef_default = createRule({
334
334
  meta: {
335
335
  type: "problem",
@@ -337,11 +337,11 @@ var jsx_no_undef_default = createRule({
337
337
  messages: { jsxNoUndef: "JSX variable '{{name}}' is not defined." },
338
338
  schema: []
339
339
  },
340
- name: RULE_NAME$57,
341
- create: create$57,
340
+ name: RULE_NAME$58,
341
+ create: create$58,
342
342
  defaultOptions: []
343
343
  });
344
- function create$57(context) {
344
+ function create$58(context) {
345
345
  return { JSXOpeningElement(node) {
346
346
  const name$7 = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({
347
347
  type: AST_NODE_TYPES.JSXMemberExpression,
@@ -360,7 +360,7 @@ function create$57(context) {
360
360
 
361
361
  //#endregion
362
362
  //#region src/rules/jsx-shorthand-boolean.ts
363
- const RULE_NAME$56 = "jsx-shorthand-boolean";
363
+ const RULE_NAME$57 = "jsx-shorthand-boolean";
364
364
  const defaultOptions$4 = [1];
365
365
  const schema$3 = [{
366
366
  type: "integer",
@@ -374,11 +374,11 @@ var jsx_shorthand_boolean_default = createRule({
374
374
  messages: { jsxShorthandBoolean: "{{message}}" },
375
375
  schema: schema$3
376
376
  },
377
- name: RULE_NAME$56,
378
- create: create$56,
377
+ name: RULE_NAME$57,
378
+ create: create$57,
379
379
  defaultOptions: defaultOptions$4
380
380
  });
381
- function create$56(context) {
381
+ function create$57(context) {
382
382
  const policy = context.options[0] ?? defaultOptions$4[0];
383
383
  return { JSXAttribute(node) {
384
384
  const { value } = node;
@@ -406,7 +406,7 @@ function create$56(context) {
406
406
 
407
407
  //#endregion
408
408
  //#region src/rules/jsx-shorthand-fragment.ts
409
- const RULE_NAME$55 = "jsx-shorthand-fragment";
409
+ const RULE_NAME$56 = "jsx-shorthand-fragment";
410
410
  const defaultOptions$3 = [1];
411
411
  const schema$2 = [{
412
412
  type: "integer",
@@ -420,11 +420,11 @@ var jsx_shorthand_fragment_default = createRule({
420
420
  messages: { jsxShorthandFragment: "{{message}}" },
421
421
  schema: schema$2
422
422
  },
423
- name: RULE_NAME$55,
424
- create: create$55,
423
+ name: RULE_NAME$56,
424
+ create: create$56,
425
425
  defaultOptions: defaultOptions$3
426
426
  });
427
- function create$55(context) {
427
+ function create$56(context) {
428
428
  const policy = context.options[0] ?? defaultOptions$3[0];
429
429
  const jsxConfig = {
430
430
  ...getJsxConfigFromContext(context),
@@ -459,7 +459,7 @@ function create$55(context) {
459
459
 
460
460
  //#endregion
461
461
  //#region src/rules/jsx-uses-react.ts
462
- const RULE_NAME$54 = "jsx-uses-react";
462
+ const RULE_NAME$55 = "jsx-uses-react";
463
463
  var jsx_uses_react_default = createRule({
464
464
  meta: {
465
465
  type: "problem",
@@ -467,11 +467,11 @@ var jsx_uses_react_default = createRule({
467
467
  messages: { jsxUsesReact: "Marked {{name}} as used." },
468
468
  schema: []
469
469
  },
470
- name: RULE_NAME$54,
471
- create: create$54,
470
+ name: RULE_NAME$55,
471
+ create: create$55,
472
472
  defaultOptions: []
473
473
  });
474
- function create$54(context) {
474
+ function create$55(context) {
475
475
  const { jsx, jsxFactory, jsxFragmentFactory } = {
476
476
  ...getJsxConfigFromContext(context),
477
477
  ...getJsxConfigFromAnnotation(context)
@@ -502,7 +502,7 @@ function debugReport(context, node, name$7) {
502
502
 
503
503
  //#endregion
504
504
  //#region src/rules/jsx-uses-vars.ts
505
- const RULE_NAME$53 = "jsx-uses-vars";
505
+ const RULE_NAME$54 = "jsx-uses-vars";
506
506
  var jsx_uses_vars_default = createRule({
507
507
  meta: {
508
508
  type: "problem",
@@ -510,11 +510,11 @@ var jsx_uses_vars_default = createRule({
510
510
  messages: { jsxUsesVars: "An identifier in JSX is marked as used." },
511
511
  schema: []
512
512
  },
513
- name: RULE_NAME$53,
514
- create: create$53,
513
+ name: RULE_NAME$54,
514
+ create: create$54,
515
515
  defaultOptions: []
516
516
  });
517
- function create$53(context) {
517
+ function create$54(context) {
518
518
  return { JSXOpeningElement(node) {
519
519
  switch (node.name.type) {
520
520
  case AST_NODE_TYPES.JSXIdentifier:
@@ -532,7 +532,7 @@ function create$53(context) {
532
532
 
533
533
  //#endregion
534
534
  //#region src/rules/no-access-state-in-setstate.ts
535
- const RULE_NAME$52 = "no-access-state-in-setstate";
535
+ const RULE_NAME$53 = "no-access-state-in-setstate";
536
536
  function isKeyLiteral$2(node, key) {
537
537
  return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
538
538
  type: AST_NODE_TYPES.TemplateLiteral,
@@ -546,11 +546,11 @@ var no_access_state_in_setstate_default = createRule({
546
546
  messages: { noAccessStateInSetstate: "Do not access 'this.state' within 'setState'. Use the update function instead." },
547
547
  schema: []
548
548
  },
549
- name: RULE_NAME$52,
550
- create: create$52,
549
+ name: RULE_NAME$53,
550
+ create: create$53,
551
551
  defaultOptions: []
552
552
  });
553
- function create$52(context) {
553
+ function create$53(context) {
554
554
  if (!context.sourceCode.text.includes("setState")) return {};
555
555
  const classStack = [];
556
556
  const methodStack = [];
@@ -621,7 +621,7 @@ function create$52(context) {
621
621
 
622
622
  //#endregion
623
623
  //#region src/rules/no-array-index-key.ts
624
- const RULE_NAME$51 = "no-array-index-key";
624
+ const RULE_NAME$52 = "no-array-index-key";
625
625
  const REACT_CHILDREN_METHOD = ["forEach", "map"];
626
626
  function isReactChildrenMethod(name$7) {
627
627
  return REACT_CHILDREN_METHOD.includes(name$7);
@@ -663,11 +663,11 @@ var no_array_index_key_default = createRule({
663
663
  messages: { noArrayIndexKey: "Do not use item index in the array as its key." },
664
664
  schema: []
665
665
  },
666
- name: RULE_NAME$51,
667
- create: create$51,
666
+ name: RULE_NAME$52,
667
+ create: create$52,
668
668
  defaultOptions: []
669
669
  });
670
- function create$51(context) {
670
+ function create$52(context) {
671
671
  const indexParamNames = [];
672
672
  function isArrayIndex(node) {
673
673
  return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name$7) => name$7 != null && name$7 === node.name);
@@ -733,7 +733,7 @@ function create$51(context) {
733
733
 
734
734
  //#endregion
735
735
  //#region src/rules/no-children-count.ts
736
- const RULE_NAME$50 = "no-children-count";
736
+ const RULE_NAME$51 = "no-children-count";
737
737
  var no_children_count_default = createRule({
738
738
  meta: {
739
739
  type: "problem",
@@ -741,11 +741,11 @@ var no_children_count_default = createRule({
741
741
  messages: { noChildrenCount: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
742
742
  schema: []
743
743
  },
744
- name: RULE_NAME$50,
745
- create: create$50,
744
+ name: RULE_NAME$51,
745
+ create: create$51,
746
746
  defaultOptions: []
747
747
  });
748
- function create$50(context) {
748
+ function create$51(context) {
749
749
  return { MemberExpression(node) {
750
750
  if (isChildrenCount(context, node)) context.report({
751
751
  messageId: "noChildrenCount",
@@ -756,7 +756,7 @@ function create$50(context) {
756
756
 
757
757
  //#endregion
758
758
  //#region src/rules/no-children-for-each.ts
759
- const RULE_NAME$49 = "no-children-for-each";
759
+ const RULE_NAME$50 = "no-children-for-each";
760
760
  var no_children_for_each_default = createRule({
761
761
  meta: {
762
762
  type: "problem",
@@ -764,11 +764,11 @@ var no_children_for_each_default = createRule({
764
764
  messages: { noChildrenForEach: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
765
765
  schema: []
766
766
  },
767
- name: RULE_NAME$49,
768
- create: create$49,
767
+ name: RULE_NAME$50,
768
+ create: create$50,
769
769
  defaultOptions: []
770
770
  });
771
- function create$49(context) {
771
+ function create$50(context) {
772
772
  return { MemberExpression(node) {
773
773
  if (isChildrenForEach(context, node)) context.report({
774
774
  messageId: "noChildrenForEach",
@@ -779,7 +779,7 @@ function create$49(context) {
779
779
 
780
780
  //#endregion
781
781
  //#region src/rules/no-children-map.ts
782
- const RULE_NAME$48 = "no-children-map";
782
+ const RULE_NAME$49 = "no-children-map";
783
783
  var no_children_map_default = createRule({
784
784
  meta: {
785
785
  type: "problem",
@@ -787,11 +787,11 @@ var no_children_map_default = createRule({
787
787
  messages: { noChildrenMap: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
788
788
  schema: []
789
789
  },
790
- name: RULE_NAME$48,
791
- create: create$48,
790
+ name: RULE_NAME$49,
791
+ create: create$49,
792
792
  defaultOptions: []
793
793
  });
794
- function create$48(context) {
794
+ function create$49(context) {
795
795
  return { MemberExpression(node) {
796
796
  if (isChildrenMap(context, node)) context.report({
797
797
  messageId: "noChildrenMap",
@@ -802,7 +802,7 @@ function create$48(context) {
802
802
 
803
803
  //#endregion
804
804
  //#region src/rules/no-children-only.ts
805
- const RULE_NAME$47 = "no-children-only";
805
+ const RULE_NAME$48 = "no-children-only";
806
806
  var no_children_only_default = createRule({
807
807
  meta: {
808
808
  type: "problem",
@@ -810,11 +810,11 @@ var no_children_only_default = createRule({
810
810
  messages: { noChildrenOnly: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
811
811
  schema: []
812
812
  },
813
- name: RULE_NAME$47,
814
- create: create$47,
813
+ name: RULE_NAME$48,
814
+ create: create$48,
815
815
  defaultOptions: []
816
816
  });
817
- function create$47(context) {
817
+ function create$48(context) {
818
818
  return { MemberExpression(node) {
819
819
  if (isChildrenOnly(context, node)) context.report({
820
820
  messageId: "noChildrenOnly",
@@ -825,7 +825,7 @@ function create$47(context) {
825
825
 
826
826
  //#endregion
827
827
  //#region src/rules/no-children-prop.ts
828
- const RULE_NAME$46 = "no-children-prop";
828
+ const RULE_NAME$47 = "no-children-prop";
829
829
  var no_children_prop_default = createRule({
830
830
  meta: {
831
831
  type: "problem",
@@ -833,11 +833,11 @@ var no_children_prop_default = createRule({
833
833
  messages: { noChildrenProp: "Do not pass 'children' as props." },
834
834
  schema: []
835
835
  },
836
- name: RULE_NAME$46,
837
- create: create$46,
836
+ name: RULE_NAME$47,
837
+ create: create$47,
838
838
  defaultOptions: []
839
839
  });
840
- function create$46(context) {
840
+ function create$47(context) {
841
841
  return { JSXElement(node) {
842
842
  const childrenProp = getJsxAttribute(context, node)("children");
843
843
  if (childrenProp != null) context.report({
@@ -849,7 +849,7 @@ function create$46(context) {
849
849
 
850
850
  //#endregion
851
851
  //#region src/rules/no-children-to-array.ts
852
- const RULE_NAME$45 = "no-children-to-array";
852
+ const RULE_NAME$46 = "no-children-to-array";
853
853
  var no_children_to_array_default = createRule({
854
854
  meta: {
855
855
  type: "problem",
@@ -857,11 +857,11 @@ var no_children_to_array_default = createRule({
857
857
  messages: { noChildrenToArray: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
858
858
  schema: []
859
859
  },
860
- name: RULE_NAME$45,
861
- create: create$45,
860
+ name: RULE_NAME$46,
861
+ create: create$46,
862
862
  defaultOptions: []
863
863
  });
864
- function create$45(context) {
864
+ function create$46(context) {
865
865
  return { MemberExpression(node) {
866
866
  if (isChildrenToArray(context, node)) context.report({
867
867
  messageId: "noChildrenToArray",
@@ -872,7 +872,7 @@ function create$45(context) {
872
872
 
873
873
  //#endregion
874
874
  //#region src/rules/no-class-component.ts
875
- const RULE_NAME$44 = "no-class-component";
875
+ const RULE_NAME$45 = "no-class-component";
876
876
  var no_class_component_default = createRule({
877
877
  meta: {
878
878
  type: "problem",
@@ -880,11 +880,11 @@ var no_class_component_default = createRule({
880
880
  messages: { noClassComponent: "Avoid using class components. Use function components instead." },
881
881
  schema: []
882
882
  },
883
- name: RULE_NAME$44,
884
- create: create$44,
883
+ name: RULE_NAME$45,
884
+ create: create$45,
885
885
  defaultOptions: []
886
886
  });
887
- function create$44(context) {
887
+ function create$45(context) {
888
888
  if (!context.sourceCode.text.includes("Component")) return {};
889
889
  const { ctx, listeners } = useComponentCollectorLegacy();
890
890
  return {
@@ -904,7 +904,7 @@ function create$44(context) {
904
904
 
905
905
  //#endregion
906
906
  //#region src/rules/no-clone-element.ts
907
- const RULE_NAME$43 = "no-clone-element";
907
+ const RULE_NAME$44 = "no-clone-element";
908
908
  var no_clone_element_default = createRule({
909
909
  meta: {
910
910
  type: "problem",
@@ -912,11 +912,11 @@ var no_clone_element_default = createRule({
912
912
  messages: { noCloneElement: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
913
913
  schema: []
914
914
  },
915
- name: RULE_NAME$43,
916
- create: create$43,
915
+ name: RULE_NAME$44,
916
+ create: create$44,
917
917
  defaultOptions: []
918
918
  });
919
- function create$43(context) {
919
+ function create$44(context) {
920
920
  return { CallExpression(node) {
921
921
  if (isCloneElementCall(context, node)) context.report({
922
922
  messageId: "noCloneElement",
@@ -927,7 +927,7 @@ function create$43(context) {
927
927
 
928
928
  //#endregion
929
929
  //#region src/rules/no-component-will-mount.ts
930
- const RULE_NAME$42 = "no-component-will-mount";
930
+ const RULE_NAME$43 = "no-component-will-mount";
931
931
  var no_component_will_mount_default = createRule({
932
932
  meta: {
933
933
  type: "problem",
@@ -936,11 +936,11 @@ var no_component_will_mount_default = createRule({
936
936
  messages: { noComponentWillMount: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
937
937
  schema: []
938
938
  },
939
- name: RULE_NAME$42,
940
- create: create$42,
939
+ name: RULE_NAME$43,
940
+ create: create$43,
941
941
  defaultOptions: []
942
942
  });
943
- function create$42(context) {
943
+ function create$43(context) {
944
944
  if (!context.sourceCode.text.includes("componentWillMount")) return {};
945
945
  const { ctx, listeners } = useComponentCollectorLegacy();
946
946
  return {
@@ -963,7 +963,7 @@ function create$42(context) {
963
963
 
964
964
  //#endregion
965
965
  //#region src/rules/no-component-will-receive-props.ts
966
- const RULE_NAME$41 = "no-component-will-receive-props";
966
+ const RULE_NAME$42 = "no-component-will-receive-props";
967
967
  var no_component_will_receive_props_default = createRule({
968
968
  meta: {
969
969
  type: "problem",
@@ -972,11 +972,11 @@ var no_component_will_receive_props_default = createRule({
972
972
  messages: { noComponentWillReceiveProps: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
973
973
  schema: []
974
974
  },
975
- name: RULE_NAME$41,
976
- create: create$41,
975
+ name: RULE_NAME$42,
976
+ create: create$42,
977
977
  defaultOptions: []
978
978
  });
979
- function create$41(context) {
979
+ function create$42(context) {
980
980
  if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
981
981
  const { ctx, listeners } = useComponentCollectorLegacy();
982
982
  return {
@@ -999,7 +999,7 @@ function create$41(context) {
999
999
 
1000
1000
  //#endregion
1001
1001
  //#region src/rules/no-component-will-update.ts
1002
- const RULE_NAME$40 = "no-component-will-update";
1002
+ const RULE_NAME$41 = "no-component-will-update";
1003
1003
  var no_component_will_update_default = createRule({
1004
1004
  meta: {
1005
1005
  type: "problem",
@@ -1008,11 +1008,11 @@ var no_component_will_update_default = createRule({
1008
1008
  messages: { noComponentWillUpdate: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
1009
1009
  schema: []
1010
1010
  },
1011
- name: RULE_NAME$40,
1012
- create: create$40,
1011
+ name: RULE_NAME$41,
1012
+ create: create$41,
1013
1013
  defaultOptions: []
1014
1014
  });
1015
- function create$40(context) {
1015
+ function create$41(context) {
1016
1016
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
1017
1017
  const { ctx, listeners } = useComponentCollectorLegacy();
1018
1018
  return {
@@ -1035,7 +1035,7 @@ function create$40(context) {
1035
1035
 
1036
1036
  //#endregion
1037
1037
  //#region src/rules/no-context-provider.ts
1038
- const RULE_NAME$39 = "no-context-provider";
1038
+ const RULE_NAME$40 = "no-context-provider";
1039
1039
  var no_context_provider_default = createRule({
1040
1040
  meta: {
1041
1041
  type: "problem",
@@ -1044,11 +1044,11 @@ var no_context_provider_default = createRule({
1044
1044
  messages: { noContextProvider: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'." },
1045
1045
  schema: []
1046
1046
  },
1047
- name: RULE_NAME$39,
1048
- create: create$39,
1047
+ name: RULE_NAME$40,
1048
+ create: create$40,
1049
1049
  defaultOptions: []
1050
1050
  });
1051
- function create$39(context) {
1051
+ function create$40(context) {
1052
1052
  if (!context.sourceCode.text.includes("Provider")) return {};
1053
1053
  const { version: version$1 } = getSettingsFromContext(context);
1054
1054
  if (compare(version$1, "19.0.0", "<")) return {};
@@ -1075,7 +1075,7 @@ function create$39(context) {
1075
1075
 
1076
1076
  //#endregion
1077
1077
  //#region src/rules/no-create-ref.ts
1078
- const RULE_NAME$38 = "no-create-ref";
1078
+ const RULE_NAME$39 = "no-create-ref";
1079
1079
  var no_create_ref_default = createRule({
1080
1080
  meta: {
1081
1081
  type: "problem",
@@ -1083,11 +1083,11 @@ var no_create_ref_default = createRule({
1083
1083
  messages: { noCreateRef: "[Deprecated] Use 'useRef' instead." },
1084
1084
  schema: []
1085
1085
  },
1086
- name: RULE_NAME$38,
1087
- create: create$38,
1086
+ name: RULE_NAME$39,
1087
+ create: create$39,
1088
1088
  defaultOptions: []
1089
1089
  });
1090
- function create$38(context) {
1090
+ function create$39(context) {
1091
1091
  return { CallExpression(node) {
1092
1092
  if (isCreateRefCall(context, node) && AST.findParentNode(node, isClassComponent) == null) context.report({
1093
1093
  messageId: "noCreateRef",
@@ -1098,7 +1098,7 @@ function create$38(context) {
1098
1098
 
1099
1099
  //#endregion
1100
1100
  //#region src/rules/no-default-props.ts
1101
- const RULE_NAME$37 = "no-default-props";
1101
+ const RULE_NAME$38 = "no-default-props";
1102
1102
  var no_default_props_default = createRule({
1103
1103
  meta: {
1104
1104
  type: "problem",
@@ -1106,11 +1106,11 @@ var no_default_props_default = createRule({
1106
1106
  messages: { noDefaultProps: "[Deprecated] Use ES6 default parameters instead." },
1107
1107
  schema: []
1108
1108
  },
1109
- name: RULE_NAME$37,
1110
- create: create$37,
1109
+ name: RULE_NAME$38,
1110
+ create: create$38,
1111
1111
  defaultOptions: []
1112
1112
  });
1113
- function create$37(context) {
1113
+ function create$38(context) {
1114
1114
  if (!context.sourceCode.text.includes("defaultProps")) return {};
1115
1115
  return { AssignmentExpression(node) {
1116
1116
  if (node.operator !== "=" || node.left.type !== AST_NODE_TYPES.MemberExpression) return;
@@ -1130,7 +1130,7 @@ function create$37(context) {
1130
1130
 
1131
1131
  //#endregion
1132
1132
  //#region src/rules/no-direct-mutation-state.ts
1133
- const RULE_NAME$36 = "no-direct-mutation-state";
1133
+ const RULE_NAME$37 = "no-direct-mutation-state";
1134
1134
  function isConstructorFunction(node) {
1135
1135
  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";
1136
1136
  }
@@ -1141,11 +1141,11 @@ var no_direct_mutation_state_default = createRule({
1141
1141
  messages: { noDirectMutationState: "Do not mutate state directly. Use 'setState()' instead." },
1142
1142
  schema: []
1143
1143
  },
1144
- name: RULE_NAME$36,
1145
- create: create$36,
1144
+ name: RULE_NAME$37,
1145
+ create: create$37,
1146
1146
  defaultOptions: []
1147
1147
  });
1148
- function create$36(context) {
1148
+ function create$37(context) {
1149
1149
  return { AssignmentExpression(node) {
1150
1150
  if (!isAssignmentToThisState(node)) return;
1151
1151
  const parentClass = AST.findParentNode(node, AST.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
@@ -1159,7 +1159,7 @@ function create$36(context) {
1159
1159
 
1160
1160
  //#endregion
1161
1161
  //#region src/rules/no-duplicate-key.ts
1162
- const RULE_NAME$35 = "no-duplicate-key";
1162
+ const RULE_NAME$36 = "no-duplicate-key";
1163
1163
  var no_duplicate_key_default = createRule({
1164
1164
  meta: {
1165
1165
  type: "problem",
@@ -1167,11 +1167,11 @@ var no_duplicate_key_default = createRule({
1167
1167
  messages: { noDuplicateKey: "A key must be unique. '{{value}}' is duplicated." },
1168
1168
  schema: []
1169
1169
  },
1170
- name: RULE_NAME$35,
1171
- create: create$35,
1170
+ name: RULE_NAME$36,
1171
+ create: create$36,
1172
1172
  defaultOptions: []
1173
1173
  });
1174
- function create$35(context) {
1174
+ function create$36(context) {
1175
1175
  if (!context.sourceCode.text.includes("key=")) return {};
1176
1176
  const keyedEntries = /* @__PURE__ */ new Map();
1177
1177
  function isKeyValueEqual(a, b) {
@@ -1226,7 +1226,7 @@ function create$35(context) {
1226
1226
 
1227
1227
  //#endregion
1228
1228
  //#region src/rules/no-forward-ref.ts
1229
- const RULE_NAME$34 = "no-forward-ref";
1229
+ const RULE_NAME$35 = "no-forward-ref";
1230
1230
  var no_forward_ref_default = createRule({
1231
1231
  meta: {
1232
1232
  type: "problem",
@@ -1235,11 +1235,11 @@ var no_forward_ref_default = createRule({
1235
1235
  messages: { noForwardRef: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead." },
1236
1236
  schema: []
1237
1237
  },
1238
- name: RULE_NAME$34,
1239
- create: create$34,
1238
+ name: RULE_NAME$35,
1239
+ create: create$35,
1240
1240
  defaultOptions: []
1241
1241
  });
1242
- function create$34(context) {
1242
+ function create$35(context) {
1243
1243
  if (!context.sourceCode.text.includes("forwardRef")) return {};
1244
1244
  const { version: version$1 } = getSettingsFromContext(context);
1245
1245
  if (compare(version$1, "19.0.0", "<")) return {};
@@ -1334,7 +1334,7 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
1334
1334
 
1335
1335
  //#endregion
1336
1336
  //#region src/rules/no-implicit-key.ts
1337
- const RULE_NAME$33 = "no-implicit-key";
1337
+ const RULE_NAME$34 = "no-implicit-key";
1338
1338
  var no_implicit_key_default = createRule({
1339
1339
  meta: {
1340
1340
  type: "problem",
@@ -1342,11 +1342,11 @@ var no_implicit_key_default = createRule({
1342
1342
  messages: { noImplicitKey: "Do not use implicit 'key' props." },
1343
1343
  schema: []
1344
1344
  },
1345
- name: RULE_NAME$33,
1346
- create: create$33,
1345
+ name: RULE_NAME$34,
1346
+ create: create$34,
1347
1347
  defaultOptions: []
1348
1348
  });
1349
- function create$33(context) {
1349
+ function create$34(context) {
1350
1350
  return { JSXOpeningElement(node) {
1351
1351
  const keyProp = getJsxAttribute(context, node.parent)("key");
1352
1352
  const isKeyPropOnElement = node.attributes.some((n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key");
@@ -1359,7 +1359,7 @@ function create$33(context) {
1359
1359
 
1360
1360
  //#endregion
1361
1361
  //#region src/rules/no-leaked-conditional-rendering.ts
1362
- const RULE_NAME$32 = "no-leaked-conditional-rendering";
1362
+ const RULE_NAME$33 = "no-leaked-conditional-rendering";
1363
1363
  var no_leaked_conditional_rendering_default = createRule({
1364
1364
  meta: {
1365
1365
  type: "problem",
@@ -1367,11 +1367,11 @@ var no_leaked_conditional_rendering_default = createRule({
1367
1367
  messages: { noLeakedConditionalRendering: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
1368
1368
  schema: []
1369
1369
  },
1370
- name: RULE_NAME$32,
1371
- create: create$32,
1370
+ name: RULE_NAME$33,
1371
+ create: create$33,
1372
1372
  defaultOptions: []
1373
1373
  });
1374
- function create$32(context) {
1374
+ function create$33(context) {
1375
1375
  if (!context.sourceCode.text.includes("&&")) return {};
1376
1376
  const { version: version$1 } = getSettingsFromContext(context);
1377
1377
  const allowedVariants = [
@@ -1427,7 +1427,7 @@ function create$32(context) {
1427
1427
 
1428
1428
  //#endregion
1429
1429
  //#region src/rules/no-missing-component-display-name.ts
1430
- const RULE_NAME$31 = "no-missing-component-display-name";
1430
+ const RULE_NAME$32 = "no-missing-component-display-name";
1431
1431
  var no_missing_component_display_name_default = createRule({
1432
1432
  meta: {
1433
1433
  type: "problem",
@@ -1435,11 +1435,11 @@ var no_missing_component_display_name_default = createRule({
1435
1435
  messages: { noMissingComponentDisplayName: "Add missing 'displayName' for component." },
1436
1436
  schema: []
1437
1437
  },
1438
- name: RULE_NAME$31,
1439
- create: create$31,
1438
+ name: RULE_NAME$32,
1439
+ create: create$32,
1440
1440
  defaultOptions: []
1441
1441
  });
1442
- function create$31(context) {
1442
+ function create$32(context) {
1443
1443
  if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
1444
1444
  const { ctx, listeners } = useComponentCollector(context, {
1445
1445
  collectDisplayName: true,
@@ -1465,7 +1465,7 @@ function create$31(context) {
1465
1465
 
1466
1466
  //#endregion
1467
1467
  //#region src/rules/no-missing-context-display-name.ts
1468
- const RULE_NAME$30 = "no-missing-context-display-name";
1468
+ const RULE_NAME$31 = "no-missing-context-display-name";
1469
1469
  var no_missing_context_display_name_default = createRule({
1470
1470
  meta: {
1471
1471
  type: "problem",
@@ -1474,11 +1474,11 @@ var no_missing_context_display_name_default = createRule({
1474
1474
  messages: { noMissingContextDisplayName: "Add missing 'displayName' for context." },
1475
1475
  schema: []
1476
1476
  },
1477
- name: RULE_NAME$30,
1478
- create: create$30,
1477
+ name: RULE_NAME$31,
1478
+ create: create$31,
1479
1479
  defaultOptions: []
1480
1480
  });
1481
- function create$30(context) {
1481
+ function create$31(context) {
1482
1482
  if (!context.sourceCode.text.includes("createContext")) return {};
1483
1483
  const createCalls = [];
1484
1484
  const displayNameAssignments = [];
@@ -1492,7 +1492,7 @@ function create$30(context) {
1492
1492
  },
1493
1493
  "Program:exit"() {
1494
1494
  for (const call of createCalls) {
1495
- const id = getInstanceId(call);
1495
+ const id = findEnclosingAssignmentTarget(call);
1496
1496
  if (id == null) {
1497
1497
  context.report({
1498
1498
  messageId: "noMissingContextDisplayName",
@@ -1530,7 +1530,7 @@ function create$30(context) {
1530
1530
 
1531
1531
  //#endregion
1532
1532
  //#region src/rules/no-missing-key.ts
1533
- const RULE_NAME$29 = "no-missing-key";
1533
+ const RULE_NAME$30 = "no-missing-key";
1534
1534
  var no_missing_key_default = createRule({
1535
1535
  meta: {
1536
1536
  type: "problem",
@@ -1541,11 +1541,11 @@ var no_missing_key_default = createRule({
1541
1541
  },
1542
1542
  schema: []
1543
1543
  },
1544
- name: RULE_NAME$29,
1545
- create: create$29,
1544
+ name: RULE_NAME$30,
1545
+ create: create$30,
1546
1546
  defaultOptions: []
1547
1547
  });
1548
- function create$29(context) {
1548
+ function create$30(context) {
1549
1549
  const state = { isWithinChildrenToArray: false };
1550
1550
  function checkIteratorElement(node) {
1551
1551
  switch (node.type) {
@@ -1623,7 +1623,7 @@ function create$29(context) {
1623
1623
 
1624
1624
  //#endregion
1625
1625
  //#region src/rules/no-misused-capture-owner-stack.ts
1626
- const RULE_NAME$28 = "no-misused-capture-owner-stack";
1626
+ const RULE_NAME$29 = "no-misused-capture-owner-stack";
1627
1627
  var no_misused_capture_owner_stack_default = createRule({
1628
1628
  meta: {
1629
1629
  type: "problem",
@@ -1634,11 +1634,11 @@ var no_misused_capture_owner_stack_default = createRule({
1634
1634
  },
1635
1635
  schema: []
1636
1636
  },
1637
- name: RULE_NAME$28,
1638
- create: create$28,
1637
+ name: RULE_NAME$29,
1638
+ create: create$29,
1639
1639
  defaultOptions: []
1640
1640
  });
1641
- function create$28(context) {
1641
+ function create$29(context) {
1642
1642
  if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
1643
1643
  const { importSource } = getSettingsFromContext(context);
1644
1644
  return {
@@ -1669,7 +1669,7 @@ function isDevelopmentOnlyCheck(node) {
1669
1669
 
1670
1670
  //#endregion
1671
1671
  //#region src/rules/no-nested-component-definitions.ts
1672
- const RULE_NAME$27 = "no-nested-component-definitions";
1672
+ const RULE_NAME$28 = "no-nested-component-definitions";
1673
1673
  var no_nested_component_definitions_default = createRule({
1674
1674
  meta: {
1675
1675
  type: "problem",
@@ -1677,11 +1677,11 @@ var no_nested_component_definitions_default = createRule({
1677
1677
  messages: { noNestedComponentDefinitions: "Do not nest component definitions inside other components or props. {{suggestion}}" },
1678
1678
  schema: []
1679
1679
  },
1680
- name: RULE_NAME$27,
1681
- create: create$27,
1680
+ name: RULE_NAME$28,
1681
+ create: create$28,
1682
1682
  defaultOptions: []
1683
1683
  });
1684
- function create$27(context) {
1684
+ function create$28(context) {
1685
1685
  const fCollector = useComponentCollector(context, { hint: ComponentDetectionHint.SkipArrayMapArgument | ComponentDetectionHint.SkipNullLiteral | ComponentDetectionHint.SkipUndefined | ComponentDetectionHint.SkipBooleanLiteral | ComponentDetectionHint.SkipStringLiteral | ComponentDetectionHint.SkipNumberLiteral | ComponentDetectionHint.StrictLogical | ComponentDetectionHint.StrictConditional });
1686
1686
  const cCollector = useComponentCollectorLegacy();
1687
1687
  return {
@@ -1789,7 +1789,7 @@ function isInsideCreateElementProps(context, node) {
1789
1789
 
1790
1790
  //#endregion
1791
1791
  //#region src/rules/no-nested-lazy-component-declarations.ts
1792
- const RULE_NAME$26 = "no-nested-lazy-component-declarations";
1792
+ const RULE_NAME$27 = "no-nested-lazy-component-declarations";
1793
1793
  var no_nested_lazy_component_declarations_default = createRule({
1794
1794
  meta: {
1795
1795
  type: "problem",
@@ -1797,11 +1797,11 @@ var no_nested_lazy_component_declarations_default = createRule({
1797
1797
  messages: { noNestedLazyComponentDeclarations: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
1798
1798
  schema: []
1799
1799
  },
1800
- name: RULE_NAME$26,
1801
- create: create$26,
1800
+ name: RULE_NAME$27,
1801
+ create: create$27,
1802
1802
  defaultOptions: []
1803
1803
  });
1804
- function create$26(context) {
1804
+ function create$27(context) {
1805
1805
  const hint = ComponentDetectionHint.None;
1806
1806
  const collector = useComponentCollector(context, { hint });
1807
1807
  const collectorLegacy = useComponentCollectorLegacy();
@@ -1832,7 +1832,7 @@ function create$26(context) {
1832
1832
 
1833
1833
  //#endregion
1834
1834
  //#region src/rules/no-prop-types.ts
1835
- const RULE_NAME$25 = "no-prop-types";
1835
+ const RULE_NAME$26 = "no-prop-types";
1836
1836
  var no_prop_types_default = createRule({
1837
1837
  meta: {
1838
1838
  type: "problem",
@@ -1840,11 +1840,11 @@ var no_prop_types_default = createRule({
1840
1840
  messages: { noPropTypes: "[Deprecated] Use TypeScript or another type-checking solution instead." },
1841
1841
  schema: []
1842
1842
  },
1843
- name: RULE_NAME$25,
1844
- create: create$25,
1843
+ name: RULE_NAME$26,
1844
+ create: create$26,
1845
1845
  defaultOptions: []
1846
1846
  });
1847
- function create$25(context) {
1847
+ function create$26(context) {
1848
1848
  if (!context.sourceCode.text.includes("propTypes")) return {};
1849
1849
  return {
1850
1850
  AssignmentExpression(node) {
@@ -1872,7 +1872,7 @@ function create$25(context) {
1872
1872
 
1873
1873
  //#endregion
1874
1874
  //#region src/rules/no-redundant-should-component-update.ts
1875
- const RULE_NAME$24 = "no-redundant-should-component-update";
1875
+ const RULE_NAME$25 = "no-redundant-should-component-update";
1876
1876
  function isShouldComponentUpdate(node) {
1877
1877
  return AST.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
1878
1878
  }
@@ -1883,11 +1883,11 @@ var no_redundant_should_component_update_default = createRule({
1883
1883
  messages: { noRedundantShouldComponentUpdate: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'." },
1884
1884
  schema: []
1885
1885
  },
1886
- name: RULE_NAME$24,
1887
- create: create$24,
1886
+ name: RULE_NAME$25,
1887
+ create: create$25,
1888
1888
  defaultOptions: []
1889
1889
  });
1890
- function create$24(context) {
1890
+ function create$25(context) {
1891
1891
  if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
1892
1892
  const { ctx, listeners } = useComponentCollectorLegacy();
1893
1893
  return {
@@ -1908,7 +1908,7 @@ function create$24(context) {
1908
1908
 
1909
1909
  //#endregion
1910
1910
  //#region src/rules/no-set-state-in-component-did-mount.ts
1911
- const RULE_NAME$23 = "no-set-state-in-component-did-mount";
1911
+ const RULE_NAME$24 = "no-set-state-in-component-did-mount";
1912
1912
  var no_set_state_in_component_did_mount_default = createRule({
1913
1913
  meta: {
1914
1914
  type: "problem",
@@ -1916,11 +1916,11 @@ var no_set_state_in_component_did_mount_default = createRule({
1916
1916
  messages: { noSetStateInComponentDidMount: "Do not call `this.setState` in `componentDidMount` outside functions such as callbacks." },
1917
1917
  schema: []
1918
1918
  },
1919
- name: RULE_NAME$23,
1920
- create: create$23,
1919
+ name: RULE_NAME$24,
1920
+ create: create$24,
1921
1921
  defaultOptions: []
1922
1922
  });
1923
- function create$23(context) {
1923
+ function create$24(context) {
1924
1924
  if (!context.sourceCode.text.includes("componentDidMount")) return {};
1925
1925
  return { CallExpression(node) {
1926
1926
  if (!isThisSetState(node)) return;
@@ -1938,7 +1938,7 @@ function create$23(context) {
1938
1938
 
1939
1939
  //#endregion
1940
1940
  //#region src/rules/no-set-state-in-component-did-update.ts
1941
- const RULE_NAME$22 = "no-set-state-in-component-did-update";
1941
+ const RULE_NAME$23 = "no-set-state-in-component-did-update";
1942
1942
  var no_set_state_in_component_did_update_default = createRule({
1943
1943
  meta: {
1944
1944
  type: "problem",
@@ -1946,11 +1946,11 @@ var no_set_state_in_component_did_update_default = createRule({
1946
1946
  messages: { noSetStateInComponentDidUpdate: "Do not call `this.setState` in `componentDidUpdate` outside functions such as callbacks." },
1947
1947
  schema: []
1948
1948
  },
1949
- name: RULE_NAME$22,
1950
- create: create$22,
1949
+ name: RULE_NAME$23,
1950
+ create: create$23,
1951
1951
  defaultOptions: []
1952
1952
  });
1953
- function create$22(context) {
1953
+ function create$23(context) {
1954
1954
  if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
1955
1955
  return { CallExpression(node) {
1956
1956
  if (!isThisSetState(node)) return;
@@ -1968,7 +1968,7 @@ function create$22(context) {
1968
1968
 
1969
1969
  //#endregion
1970
1970
  //#region src/rules/no-set-state-in-component-will-update.ts
1971
- const RULE_NAME$21 = "no-set-state-in-component-will-update";
1971
+ const RULE_NAME$22 = "no-set-state-in-component-will-update";
1972
1972
  var no_set_state_in_component_will_update_default = createRule({
1973
1973
  meta: {
1974
1974
  type: "problem",
@@ -1976,11 +1976,11 @@ var no_set_state_in_component_will_update_default = createRule({
1976
1976
  messages: { noSetStateInComponentWillUpdate: "Do not call `this.setState` in `componentWillUpdate` outside functions such as callbacks." },
1977
1977
  schema: []
1978
1978
  },
1979
- name: RULE_NAME$21,
1980
- create: create$21,
1979
+ name: RULE_NAME$22,
1980
+ create: create$22,
1981
1981
  defaultOptions: []
1982
1982
  });
1983
- function create$21(context) {
1983
+ function create$22(context) {
1984
1984
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
1985
1985
  return { CallExpression(node) {
1986
1986
  if (!isThisSetState(node)) return;
@@ -1998,7 +1998,7 @@ function create$21(context) {
1998
1998
 
1999
1999
  //#endregion
2000
2000
  //#region src/rules/no-string-refs.ts
2001
- const RULE_NAME$20 = "no-string-refs";
2001
+ const RULE_NAME$21 = "no-string-refs";
2002
2002
  var no_string_refs_default = createRule({
2003
2003
  meta: {
2004
2004
  type: "problem",
@@ -2007,11 +2007,11 @@ var no_string_refs_default = createRule({
2007
2007
  messages: { noStringRefs: "[Deprecated] Use callback refs instead." },
2008
2008
  schema: []
2009
2009
  },
2010
- name: RULE_NAME$20,
2011
- create: create$20,
2010
+ name: RULE_NAME$21,
2011
+ create: create$21,
2012
2012
  defaultOptions: []
2013
2013
  });
2014
- function create$20(context) {
2014
+ function create$21(context) {
2015
2015
  const state = { isWithinClassComponent: false };
2016
2016
  function onClassBodyEnter(node) {
2017
2017
  if (isClassComponent(node.parent)) state.isWithinClassComponent = true;
@@ -2056,19 +2056,19 @@ function getJsxAttributeValueText(context, node) {
2056
2056
 
2057
2057
  //#endregion
2058
2058
  //#region src/rules/no-unnecessary-key.ts
2059
- const RULE_NAME$19 = "no-unnecessary-key";
2059
+ const RULE_NAME$20 = "no-unnecessary-key";
2060
2060
  var no_unnecessary_key_default = createRule({
2061
2061
  meta: {
2062
2062
  type: "problem",
2063
- docs: { description: "Disallows unnecessary `key` props on elements." },
2063
+ docs: { description: "Disallows unnecessary 'key' props on elements." },
2064
2064
  messages: { noUnnecessaryKey: "Unnecessary `key` prop on this element. {{reason}}" },
2065
2065
  schema: []
2066
2066
  },
2067
- name: RULE_NAME$19,
2068
- create: create$19,
2067
+ name: RULE_NAME$20,
2068
+ create: create$20,
2069
2069
  defaultOptions: []
2070
2070
  });
2071
- function create$19(context) {
2071
+ function create$20(context) {
2072
2072
  if (!context.sourceCode.text.includes("key=")) return {};
2073
2073
  const jsxConfig = {
2074
2074
  ...getJsxConfigFromContext(context),
@@ -2081,7 +2081,7 @@ function create$19(context) {
2081
2081
  if (jsxElement.openingElement.attributes.some((attr) => attr.type === AST_NODE_TYPES.JSXSpreadAttribute)) return;
2082
2082
  const mapCallback = AST.findParentNode(jsxElement, isMapCallback);
2083
2083
  if (mapCallback == null || AST.findParentNode(jsxElement, AST.isFunction) !== mapCallback) {
2084
- if (!(AST.findParentNode(jsxElement, (n) => AST.isConditional(n) || AST.isControlFlow(n) || getInstanceId(n) != null) != null)) context.report({
2084
+ if (!(AST.findParentNode(jsxElement, (n) => AST.isConditional(n) || AST.isControlFlow(n) || findEnclosingAssignmentTarget(n) != null) != null)) context.report({
2085
2085
  messageId: "noUnnecessaryKey",
2086
2086
  node,
2087
2087
  data: { reason: "The `key` prop is not needed outside of dynamic rendering contexts." }
@@ -2114,7 +2114,7 @@ function isMapCallback(node) {
2114
2114
 
2115
2115
  //#endregion
2116
2116
  //#region src/rules/no-unnecessary-use-callback.ts
2117
- const RULE_NAME$18 = "no-unnecessary-use-callback";
2117
+ const RULE_NAME$19 = "no-unnecessary-use-callback";
2118
2118
  var no_unnecessary_use_callback_default = createRule({
2119
2119
  meta: {
2120
2120
  type: "problem",
@@ -2125,11 +2125,11 @@ var no_unnecessary_use_callback_default = createRule({
2125
2125
  },
2126
2126
  schema: []
2127
2127
  },
2128
- name: RULE_NAME$18,
2129
- create: create$18,
2128
+ name: RULE_NAME$19,
2129
+ create: create$19,
2130
2130
  defaultOptions: []
2131
2131
  });
2132
- function create$18(context) {
2132
+ function create$19(context) {
2133
2133
  if (!context.sourceCode.text.includes("useCallback")) return {};
2134
2134
  return { CallExpression(node) {
2135
2135
  if (!isUseCallbackCall(node)) return;
@@ -2187,7 +2187,7 @@ function checkForUsageInsideUseEffect$1(sourceCode, node) {
2187
2187
 
2188
2188
  //#endregion
2189
2189
  //#region src/rules/no-unnecessary-use-memo.ts
2190
- const RULE_NAME$17 = "no-unnecessary-use-memo";
2190
+ const RULE_NAME$18 = "no-unnecessary-use-memo";
2191
2191
  var no_unnecessary_use_memo_default = createRule({
2192
2192
  meta: {
2193
2193
  type: "problem",
@@ -2198,11 +2198,11 @@ var no_unnecessary_use_memo_default = createRule({
2198
2198
  },
2199
2199
  schema: []
2200
2200
  },
2201
- name: RULE_NAME$17,
2202
- create: create$17,
2201
+ name: RULE_NAME$18,
2202
+ create: create$18,
2203
2203
  defaultOptions: []
2204
2204
  });
2205
- function create$17(context) {
2205
+ function create$18(context) {
2206
2206
  if (!context.sourceCode.text.includes("useMemo")) return {};
2207
2207
  return { CallExpression(node) {
2208
2208
  const initialScope = context.sourceCode.getScope(node);
@@ -2264,7 +2264,7 @@ function checkForUsageInsideUseEffect(sourceCode, node) {
2264
2264
 
2265
2265
  //#endregion
2266
2266
  //#region src/rules/no-unnecessary-use-prefix.ts
2267
- const RULE_NAME$16 = "no-unnecessary-use-prefix";
2267
+ const RULE_NAME$17 = "no-unnecessary-use-prefix";
2268
2268
  const WELL_KNOWN_HOOKS = ["useMDXComponents"];
2269
2269
  function containsUseComments(context, node) {
2270
2270
  return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
@@ -2276,11 +2276,11 @@ var no_unnecessary_use_prefix_default = createRule({
2276
2276
  messages: { noUnnecessaryUsePrefix: "If your function doesn't call any Hooks, avoid the 'use' prefix. Instead, write it as a regular function without the 'use' prefix." },
2277
2277
  schema: []
2278
2278
  },
2279
- name: RULE_NAME$16,
2280
- create: create$16,
2279
+ name: RULE_NAME$17,
2280
+ create: create$17,
2281
2281
  defaultOptions: []
2282
2282
  });
2283
- function create$16(context) {
2283
+ function create$17(context) {
2284
2284
  const { ctx, listeners } = useHookCollector();
2285
2285
  return {
2286
2286
  ...listeners,
@@ -2301,6 +2301,42 @@ function create$16(context) {
2301
2301
  };
2302
2302
  }
2303
2303
 
2304
+ //#endregion
2305
+ //#region src/rules/no-unnecessary-use-ref.ts
2306
+ const RULE_NAME$16 = "no-unnecessary-use-ref";
2307
+ var no_unnecessary_use_ref_default = createRule({
2308
+ meta: {
2309
+ type: "problem",
2310
+ docs: { description: "Disallows unnecessary usage of 'useRef'." },
2311
+ messages: { noUnnecessaryUseRef: "Unnecessary use of 'useRef'. Instead, co-locate the value inside the effect that uses it." },
2312
+ schema: []
2313
+ },
2314
+ name: RULE_NAME$16,
2315
+ create: create$16,
2316
+ defaultOptions: []
2317
+ });
2318
+ function create$16(context) {
2319
+ return { VariableDeclarator(node) {
2320
+ const { id, init } = node;
2321
+ if (id.type !== AST_NODE_TYPES.Identifier || init == null || !isUseRefCall(init)) return;
2322
+ const variable = context.sourceCode.getDeclaredVariables(node).at(0);
2323
+ if (variable == null) return;
2324
+ const effects = /* @__PURE__ */ new Set();
2325
+ let globalUsages = 0;
2326
+ for (const ref of variable.references) {
2327
+ if (ref.init != null) continue;
2328
+ const effect = AST.findParentNode(ref.identifier, isUseEffectLikeCall);
2329
+ if (effect == null) globalUsages++;
2330
+ else effects.add(effect);
2331
+ }
2332
+ if (globalUsages > 0 || effects.size !== 1) return;
2333
+ context.report({
2334
+ messageId: "noUnnecessaryUseRef",
2335
+ node: node.parent
2336
+ });
2337
+ } };
2338
+ }
2339
+
2304
2340
  //#endregion
2305
2341
  //#region src/rules/no-unsafe-component-will-mount.ts
2306
2342
  const RULE_NAME$15 = "no-unsafe-component-will-mount";
@@ -3464,6 +3500,7 @@ const plugin = {
3464
3500
  "no-unnecessary-use-callback": no_unnecessary_use_callback_default,
3465
3501
  "no-unnecessary-use-memo": no_unnecessary_use_memo_default,
3466
3502
  "no-unnecessary-use-prefix": no_unnecessary_use_prefix_default,
3503
+ "no-unnecessary-use-ref": no_unnecessary_use_ref_default,
3467
3504
  "no-unsafe-component-will-mount": no_unsafe_component_will_mount_default,
3468
3505
  "no-unsafe-component-will-receive-props": no_unsafe_component_will_receive_props_default,
3469
3506
  "no-unsafe-component-will-update": no_unsafe_component_will_update_default,
@@ -3596,6 +3633,7 @@ const rules$2 = {
3596
3633
  "react-x/no-misused-capture-owner-stack": "error",
3597
3634
  "react-x/no-unnecessary-use-callback": "warn",
3598
3635
  "react-x/no-unnecessary-use-memo": "warn",
3636
+ "react-x/no-unnecessary-use-ref": "warn",
3599
3637
  "react-x/no-unstable-context-value": "warn",
3600
3638
  "react-x/no-unstable-default-props": "warn",
3601
3639
  "react-x/no-unused-class-component-members": "warn",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.5.7",
3
+ "version": "2.5.8",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -46,16 +46,16 @@
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-api-utils": "^2.4.0",
48
48
  "ts-pattern": "^5.9.0",
49
- "@eslint-react/ast": "2.5.7",
50
- "@eslint-react/core": "2.5.7",
51
- "@eslint-react/eff": "2.5.7",
52
- "@eslint-react/shared": "2.5.7",
53
- "@eslint-react/var": "2.5.7"
49
+ "@eslint-react/ast": "2.5.8",
50
+ "@eslint-react/core": "2.5.8",
51
+ "@eslint-react/eff": "2.5.8",
52
+ "@eslint-react/shared": "2.5.8",
53
+ "@eslint-react/var": "2.5.8"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.8",
57
57
  "@types/react-dom": "^19.2.3",
58
- "tsdown": "^0.20.0-beta.1",
58
+ "tsdown": "^0.20.0-beta.2",
59
59
  "@local/configs": "0.0.0"
60
60
  },
61
61
  "peerDependencies": {