eslint-plugin-react-x 3.0.0-next.28 → 3.0.0-next.31

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 +424 -374
  2. package/package.json +6 -7
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@ import { P, isMatching, match } from "ts-pattern";
6
6
  import ts from "typescript";
7
7
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
8
8
  import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectType, getVariableInitializer, isAssignmentTargetEqual } from "@eslint-react/var";
9
+ import { DefinitionType } from "@typescript-eslint/scope-manager";
9
10
  import { constFalse, constTrue, constVoid, flow, getOrElseUpdate, identity, not, unit } from "@eslint-react/eff";
10
11
  import { compare } from "compare-versions";
11
- import { getConstrainedTypeAtLocation, isTypeReadonly } from "@typescript-eslint/type-utils";
12
- import { isPropertyReadonlyInType, unionConstituents } from "ts-api-utils";
12
+ import { getConstrainedTypeAtLocation } from "@typescript-eslint/type-utils";
13
+ import { unionConstituents } from "ts-api-utils";
13
14
  import { getStaticValue, isIdentifier, isVariableDeclarator } from "@typescript-eslint/utils/ast-utils";
14
- import { getTypeImmutability, isImmutable, isReadonlyDeep, isReadonlyShallow, isUnknown } from "is-immutable-type";
15
15
  import { snakeCase } from "string-ts";
16
16
 
17
17
  //#region \0rolldown/runtime.js
@@ -39,6 +39,7 @@ var disable_experimental_exports = /* @__PURE__ */ __exportAll({
39
39
  const name$8 = "react-x/disable-experimental";
40
40
  const rules$8 = {
41
41
  "react-x/exhaustive-deps": "off",
42
+ "react-x/immutability": "off",
42
43
  "react-x/jsx-key-before-spread": "off",
43
44
  "react-x/no-duplicate-key": "off",
44
45
  "react-x/no-implicit-key": "off",
@@ -46,7 +47,6 @@ const rules$8 = {
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
50
  "react-x/refs": "off",
51
51
  "react-x/rules-of-hooks": "off",
52
52
  "react-x/set-state-in-render": "off"
@@ -62,14 +62,13 @@ const name$7 = "react-x/disable-type-checked";
62
62
  const rules$7 = {
63
63
  "react-x/no-implicit-key": "off",
64
64
  "react-x/no-leaked-conditional-rendering": "off",
65
- "react-x/no-unused-props": "off",
66
- "react-x/prefer-read-only-props": "off"
65
+ "react-x/no-unused-props": "off"
67
66
  };
68
67
 
69
68
  //#endregion
70
69
  //#region package.json
71
70
  var name$6 = "eslint-plugin-react-x";
72
- var version = "3.0.0-next.28";
71
+ var version = "3.0.0-next.31";
73
72
 
74
73
  //#endregion
75
74
  //#region src/utils/create-rule.ts
@@ -226,7 +225,7 @@ function getTypeVariants(types) {
226
225
 
227
226
  //#endregion
228
227
  //#region src/rules/component-hook-factories.ts
229
- const RULE_NAME$64 = "component-hook-factories";
228
+ const RULE_NAME$62 = "component-hook-factories";
230
229
  var component_hook_factories_default = createRule({
231
230
  meta: {
232
231
  type: "problem",
@@ -237,11 +236,11 @@ var component_hook_factories_default = createRule({
237
236
  },
238
237
  schema: []
239
238
  },
240
- name: RULE_NAME$64,
241
- create: create$64,
239
+ name: RULE_NAME$62,
240
+ create: create$62,
242
241
  defaultOptions: []
243
242
  });
244
- function create$64(context) {
243
+ function create$62(context) {
245
244
  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;
246
245
  const fCollector = core.useComponentCollector(context, { hint });
247
246
  const cCollector = core.useComponentCollectorLegacy(context);
@@ -285,7 +284,7 @@ function create$64(context) {
285
284
 
286
285
  //#endregion
287
286
  //#region src/rules/error-boundaries.ts
288
- const RULE_NAME$63 = "error-boundaries";
287
+ const RULE_NAME$61 = "error-boundaries";
289
288
  var error_boundaries_default = createRule({
290
289
  meta: {
291
290
  type: "problem",
@@ -296,11 +295,11 @@ var error_boundaries_default = createRule({
296
295
  },
297
296
  schema: []
298
297
  },
299
- name: RULE_NAME$63,
300
- create: create$63,
298
+ name: RULE_NAME$61,
299
+ create: create$61,
301
300
  defaultOptions: []
302
301
  });
303
- function create$63(context) {
302
+ function create$61(context) {
304
303
  if (!context.sourceCode.text.includes("try")) return {};
305
304
  const { ctx, visitor } = core.useComponentCollector(context);
306
305
  const reported = /* @__PURE__ */ new Set();
@@ -1238,9 +1237,173 @@ function getUnknownDependenciesMessage(reactiveHookName) {
1238
1237
  return `React Hook ${reactiveHookName} received a function whose dependencies are unknown. Pass an inline function instead.`;
1239
1238
  }
1240
1239
 
1240
+ //#endregion
1241
+ //#region src/rules/immutability.ts
1242
+ const RULE_NAME$60 = "immutability";
1243
+ /**
1244
+ * Array methods that mutate the array in place.
1245
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
1246
+ */
1247
+ const MUTATING_ARRAY_METHODS = new Set([
1248
+ "copyWithin",
1249
+ "fill",
1250
+ "pop",
1251
+ "push",
1252
+ "reverse",
1253
+ "shift",
1254
+ "sort",
1255
+ "splice",
1256
+ "unshift"
1257
+ ]);
1258
+ /**
1259
+ * Get the root identifier of a (possibly nested) member expression.
1260
+ * For `a.b.c`, returns the `a` Identifier node.
1261
+ * @param node The expression to analyze
1262
+ * @returns The root Identifier node, or null if it cannot be determined (e.g. non-identifier root)
1263
+ */
1264
+ function getRootIdentifier(node) {
1265
+ switch (node.type) {
1266
+ case AST_NODE_TYPES.Identifier: return node;
1267
+ case AST_NODE_TYPES.MemberExpression: return getRootIdentifier(node.object);
1268
+ default: return null;
1269
+ }
1270
+ }
1271
+ var immutability_default = createRule({
1272
+ meta: {
1273
+ type: "problem",
1274
+ docs: { description: "Validates against mutating props, state, and other values that are immutable." },
1275
+ messages: {
1276
+ mutatingArrayMethod: "Do not call '{{method}}()' on '{{name}}'. Props and state are immutable — create a new array instead.",
1277
+ mutatingAssignment: "Do not mutate '{{name}}' directly. Props and state are immutable — create a new object instead."
1278
+ },
1279
+ schema: []
1280
+ },
1281
+ name: RULE_NAME$60,
1282
+ create: create$60,
1283
+ defaultOptions: []
1284
+ });
1285
+ function create$60(context) {
1286
+ const { additionalStateHooks } = getSettingsFromContext(context);
1287
+ const hCollector = core.useHookCollector(context);
1288
+ const cCollector = core.useComponentCollector(context);
1289
+ /**
1290
+ * Violations accumulated while traversing. Each entry records the node to
1291
+ * report and the enclosing function so we can filter at Program:exit.
1292
+ */
1293
+ const violations = [];
1294
+ function isUseStateCall(node) {
1295
+ return core.isUseStateLikeCall(node, additionalStateHooks);
1296
+ }
1297
+ /**
1298
+ * Return true when `id` is the *value* variable (index 0) produced by a
1299
+ * `useState(…)` call, i.e. the first element of `const [value, setter] = useState(…)`.
1300
+ * @param id The identifier to check. May be a reference to the state variable, e.g. used inside an event handler nested in the component body — scope resolution will trace it back to the original declaration.
1301
+ * @returns True if `id` is a state variable, false otherwise.
1302
+ */
1303
+ function isStateValue(id) {
1304
+ const initNode = getVariableInitializer(findVariable(id, context.sourceCode.getScope(id)), 0);
1305
+ if (initNode == null || initNode.type !== AST_NODE_TYPES.CallExpression) return false;
1306
+ if (!isUseStateCall(initNode)) return false;
1307
+ const declarator = initNode.parent;
1308
+ if (!("id" in declarator) || declarator.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
1309
+ return declarator.id.elements.findIndex((el) => el?.type === AST_NODE_TYPES.Identifier && el.name === id.name) === 0;
1310
+ }
1311
+ /**
1312
+ * Return true when `id` is a direct (non-destructured) props parameter at
1313
+ * position 0 of any ancestor function.
1314
+ *
1315
+ * Uses scope resolution so that references to `props` inside nested arrow
1316
+ * functions (e.g. event handlers) are correctly traced back to the component
1317
+ * parameter, e.g.:
1318
+ *
1319
+ * function Component(props) { // ← props defined here
1320
+ * const handleClick = () => {
1321
+ * props.items.push(4); // ← props resolved via scope to Component's param
1322
+ * };
1323
+ * }
1324
+ * @param id The identifier to check. May be a reference to the props parameter, e.g. used inside an event handler nested in the component body — scope resolution will trace it back to the original declaration.
1325
+ * @returns True if `id` is a props parameter, false otherwise.
1326
+ */
1327
+ function isPropsObject(id) {
1328
+ const variable = findVariable(id, context.sourceCode.getScope(id));
1329
+ if (variable == null) return false;
1330
+ for (const def of variable.defs) {
1331
+ if (def.type !== DefinitionType.Parameter) continue;
1332
+ if (!ast.isFunction(def.node)) continue;
1333
+ const firstParam = def.node.params.at(0);
1334
+ return firstParam?.type === AST_NODE_TYPES.Identifier && firstParam.name === id.name;
1335
+ }
1336
+ return false;
1337
+ }
1338
+ return defineRuleListener(hCollector.visitor, cCollector.visitor, {
1339
+ CallExpression(node) {
1340
+ if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
1341
+ const { object, property } = node.callee;
1342
+ if (property.type !== AST_NODE_TYPES.Identifier) return;
1343
+ if (!MUTATING_ARRAY_METHODS.has(property.name)) return;
1344
+ const rootId = getRootIdentifier(object);
1345
+ if (rootId == null) return;
1346
+ if (rootId.name === "draft") return;
1347
+ const enclosingFn = ast.findParentNode(node, ast.isFunction);
1348
+ if (enclosingFn == null) return;
1349
+ const isState = isStateValue(rootId);
1350
+ const isProps = isPropsObject(rootId);
1351
+ if (!isState && !isProps) return;
1352
+ violations.push({
1353
+ messageId: "mutatingArrayMethod",
1354
+ node,
1355
+ data: {
1356
+ name: context.sourceCode.getText(object),
1357
+ method: property.name
1358
+ },
1359
+ func: enclosingFn
1360
+ });
1361
+ },
1362
+ AssignmentExpression(node) {
1363
+ if (node.left.type !== AST_NODE_TYPES.MemberExpression) return;
1364
+ const rootId = getRootIdentifier(node.left);
1365
+ if (rootId == null) return;
1366
+ if (rootId.name === "draft") return;
1367
+ const enclosingFn = ast.findParentNode(node, ast.isFunction);
1368
+ if (enclosingFn == null) return;
1369
+ const isState = isStateValue(rootId);
1370
+ const isProps = isPropsObject(rootId);
1371
+ if (!isState && !isProps) return;
1372
+ violations.push({
1373
+ messageId: "mutatingAssignment",
1374
+ node,
1375
+ data: { name: context.sourceCode.getText(node.left.object) },
1376
+ func: enclosingFn
1377
+ });
1378
+ },
1379
+ "Program:exit"(program) {
1380
+ const components = cCollector.ctx.getAllComponents(program);
1381
+ const hooks = hCollector.ctx.getAllHooks(program);
1382
+ const componentAndHookFns = new Set([...components.map((c) => c.node), ...hooks.map((h) => h.node)]);
1383
+ for (const { messageId, node, data, func } of violations) {
1384
+ let current = func;
1385
+ let insideComponentOrHook = false;
1386
+ while (current != null) {
1387
+ if (componentAndHookFns.has(current)) {
1388
+ insideComponentOrHook = true;
1389
+ break;
1390
+ }
1391
+ current = ast.findParentNode(current, ast.isFunction);
1392
+ }
1393
+ if (!insideComponentOrHook) continue;
1394
+ context.report({
1395
+ messageId,
1396
+ node,
1397
+ data
1398
+ });
1399
+ }
1400
+ }
1401
+ });
1402
+ }
1403
+
1241
1404
  //#endregion
1242
1405
  //#region src/rules/jsx-dollar.ts
1243
- const RULE_NAME$62 = "jsx-dollar";
1406
+ const RULE_NAME$59 = "jsx-dollar";
1244
1407
  var jsx_dollar_default = createRule({
1245
1408
  meta: {
1246
1409
  type: "problem",
@@ -1253,11 +1416,11 @@ var jsx_dollar_default = createRule({
1253
1416
  },
1254
1417
  schema: []
1255
1418
  },
1256
- name: RULE_NAME$62,
1257
- create: create$62,
1419
+ name: RULE_NAME$59,
1420
+ create: create$59,
1258
1421
  defaultOptions: []
1259
1422
  });
1260
- function create$62(context) {
1423
+ function create$59(context) {
1261
1424
  /**
1262
1425
  * Visitor function for JSXElement and JSXFragment nodes
1263
1426
  * @param node The JSXElement or JSXFragment node to be checked
@@ -1298,7 +1461,7 @@ function create$62(context) {
1298
1461
 
1299
1462
  //#endregion
1300
1463
  //#region src/rules/jsx-key-before-spread.ts
1301
- const RULE_NAME$61 = "jsx-key-before-spread";
1464
+ const RULE_NAME$58 = "jsx-key-before-spread";
1302
1465
  var jsx_key_before_spread_default = createRule({
1303
1466
  meta: {
1304
1467
  type: "problem",
@@ -1306,11 +1469,11 @@ var jsx_key_before_spread_default = createRule({
1306
1469
  messages: { default: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
1307
1470
  schema: []
1308
1471
  },
1309
- name: RULE_NAME$61,
1310
- create: create$61,
1472
+ name: RULE_NAME$58,
1473
+ create: create$58,
1311
1474
  defaultOptions: []
1312
1475
  });
1313
- function create$61(context) {
1476
+ function create$58(context) {
1314
1477
  const { jsx } = {
1315
1478
  ...core.getJsxConfigFromContext(context),
1316
1479
  ...core.getJsxConfigFromAnnotation(context)
@@ -1334,7 +1497,7 @@ function create$61(context) {
1334
1497
 
1335
1498
  //#endregion
1336
1499
  //#region src/rules/jsx-no-comment-textnodes.ts
1337
- const RULE_NAME$60 = "jsx-no-comment-textnodes";
1500
+ const RULE_NAME$57 = "jsx-no-comment-textnodes";
1338
1501
  var jsx_no_comment_textnodes_default = createRule({
1339
1502
  meta: {
1340
1503
  type: "problem",
@@ -1342,11 +1505,11 @@ var jsx_no_comment_textnodes_default = createRule({
1342
1505
  messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
1343
1506
  schema: []
1344
1507
  },
1345
- name: RULE_NAME$60,
1346
- create: create$60,
1508
+ name: RULE_NAME$57,
1509
+ create: create$57,
1347
1510
  defaultOptions: []
1348
1511
  });
1349
- function create$60(context) {
1512
+ function create$57(context) {
1350
1513
  function hasCommentLike(node) {
1351
1514
  if (ast.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
1352
1515
  return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
@@ -1367,7 +1530,7 @@ function create$60(context) {
1367
1530
 
1368
1531
  //#endregion
1369
1532
  //#region src/rules/jsx-no-duplicate-props.ts
1370
- const RULE_NAME$59 = "jsx-no-duplicate-props";
1533
+ const RULE_NAME$56 = "jsx-no-duplicate-props";
1371
1534
  var jsx_no_duplicate_props_default = createRule({
1372
1535
  meta: {
1373
1536
  type: "problem",
@@ -1375,11 +1538,11 @@ var jsx_no_duplicate_props_default = createRule({
1375
1538
  messages: { default: "This JSX property is assigned multiple times." },
1376
1539
  schema: []
1377
1540
  },
1378
- name: RULE_NAME$59,
1379
- create: create$59,
1541
+ name: RULE_NAME$56,
1542
+ create: create$56,
1380
1543
  defaultOptions: []
1381
1544
  });
1382
- function create$59(context) {
1545
+ function create$56(context) {
1383
1546
  return defineRuleListener({ JSXOpeningElement(node) {
1384
1547
  const props = [];
1385
1548
  for (const attr of node.attributes) {
@@ -1398,40 +1561,9 @@ function create$59(context) {
1398
1561
  } });
1399
1562
  }
1400
1563
 
1401
- //#endregion
1402
- //#region src/rules/jsx-no-undef.ts
1403
- const RULE_NAME$58 = "jsx-no-undef";
1404
- var jsx_no_undef_default = createRule({
1405
- meta: {
1406
- type: "problem",
1407
- docs: { description: "Prevents using variables in JSX that are not defined in the scope." },
1408
- messages: { default: "JSX variable '{{name}}' is not defined." },
1409
- schema: []
1410
- },
1411
- name: RULE_NAME$58,
1412
- create: create$58,
1413
- defaultOptions: []
1414
- });
1415
- function create$58(context) {
1416
- return defineRuleListener({ JSXOpeningElement(node) {
1417
- const name = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({
1418
- type: AST_NODE_TYPES.JSXMemberExpression,
1419
- object: { type: AST_NODE_TYPES.JSXIdentifier }
1420
- }, (n) => n.object.name).otherwise(() => null);
1421
- if (name == null) return;
1422
- if (name === "this") return;
1423
- if (/^[a-z]/u.test(name)) return;
1424
- if (findVariable(name, context.sourceCode.getScope(node)) == null) context.report({
1425
- messageId: "default",
1426
- node,
1427
- data: { name }
1428
- });
1429
- } });
1430
- }
1431
-
1432
1564
  //#endregion
1433
1565
  //#region src/rules/jsx-shorthand-boolean.ts
1434
- const RULE_NAME$57 = "jsx-shorthand-boolean";
1566
+ const RULE_NAME$55 = "jsx-shorthand-boolean";
1435
1567
  const defaultOptions$4 = [1];
1436
1568
  const schema$4 = [{
1437
1569
  type: "integer",
@@ -1445,11 +1577,11 @@ var jsx_shorthand_boolean_default = createRule({
1445
1577
  messages: { default: "{{message}}" },
1446
1578
  schema: schema$4
1447
1579
  },
1448
- name: RULE_NAME$57,
1449
- create: create$57,
1580
+ name: RULE_NAME$55,
1581
+ create: create$55,
1450
1582
  defaultOptions: defaultOptions$4
1451
1583
  });
1452
- function create$57(context) {
1584
+ function create$55(context) {
1453
1585
  const policy = context.options[0] ?? defaultOptions$4[0];
1454
1586
  return defineRuleListener({ JSXAttribute(node) {
1455
1587
  const { value } = node;
@@ -1477,7 +1609,7 @@ function create$57(context) {
1477
1609
 
1478
1610
  //#endregion
1479
1611
  //#region src/rules/jsx-shorthand-fragment.ts
1480
- const RULE_NAME$56 = "jsx-shorthand-fragment";
1612
+ const RULE_NAME$54 = "jsx-shorthand-fragment";
1481
1613
  const defaultOptions$3 = [1];
1482
1614
  const schema$3 = [{
1483
1615
  type: "integer",
@@ -1491,11 +1623,11 @@ var jsx_shorthand_fragment_default = createRule({
1491
1623
  messages: { default: "{{message}}" },
1492
1624
  schema: schema$3
1493
1625
  },
1494
- name: RULE_NAME$56,
1495
- create: create$56,
1626
+ name: RULE_NAME$54,
1627
+ create: create$54,
1496
1628
  defaultOptions: defaultOptions$3
1497
1629
  });
1498
- function create$56(context) {
1630
+ function create$54(context) {
1499
1631
  const policy = context.options[0] ?? defaultOptions$3[0];
1500
1632
  const jsxConfig = {
1501
1633
  ...core.getJsxConfigFromContext(context),
@@ -1530,7 +1662,7 @@ function create$56(context) {
1530
1662
 
1531
1663
  //#endregion
1532
1664
  //#region src/rules/jsx-uses-react.ts
1533
- const RULE_NAME$55 = "jsx-uses-react";
1665
+ const RULE_NAME$53 = "jsx-uses-react";
1534
1666
  var jsx_uses_react_default = createRule({
1535
1667
  meta: {
1536
1668
  type: "problem",
@@ -1538,11 +1670,11 @@ var jsx_uses_react_default = createRule({
1538
1670
  messages: { default: "Marked {{name}} as used." },
1539
1671
  schema: []
1540
1672
  },
1541
- name: RULE_NAME$55,
1542
- create: create$55,
1673
+ name: RULE_NAME$53,
1674
+ create: create$53,
1543
1675
  defaultOptions: []
1544
1676
  });
1545
- function create$55(context) {
1677
+ function create$53(context) {
1546
1678
  const { jsx, jsxFactory, jsxFragmentFactory } = {
1547
1679
  ...core.getJsxConfigFromContext(context),
1548
1680
  ...core.getJsxConfigFromAnnotation(context)
@@ -1573,7 +1705,7 @@ function debugReport(context, node, name) {
1573
1705
 
1574
1706
  //#endregion
1575
1707
  //#region src/rules/jsx-uses-vars.ts
1576
- const RULE_NAME$54 = "jsx-uses-vars";
1708
+ const RULE_NAME$52 = "jsx-uses-vars";
1577
1709
  var jsx_uses_vars_default = createRule({
1578
1710
  meta: {
1579
1711
  type: "problem",
@@ -1581,11 +1713,11 @@ var jsx_uses_vars_default = createRule({
1581
1713
  messages: { default: "An identifier in JSX is marked as used." },
1582
1714
  schema: []
1583
1715
  },
1584
- name: RULE_NAME$54,
1585
- create: create$54,
1716
+ name: RULE_NAME$52,
1717
+ create: create$52,
1586
1718
  defaultOptions: []
1587
1719
  });
1588
- function create$54(context) {
1720
+ function create$52(context) {
1589
1721
  return defineRuleListener({ JSXOpeningElement(node) {
1590
1722
  switch (node.name.type) {
1591
1723
  case AST_NODE_TYPES.JSXIdentifier:
@@ -1603,7 +1735,7 @@ function create$54(context) {
1603
1735
 
1604
1736
  //#endregion
1605
1737
  //#region src/rules/no-access-state-in-setstate.ts
1606
- const RULE_NAME$53 = "no-access-state-in-setstate";
1738
+ const RULE_NAME$51 = "no-access-state-in-setstate";
1607
1739
  function isKeyLiteral$2(node, key) {
1608
1740
  return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
1609
1741
  type: AST_NODE_TYPES.TemplateLiteral,
@@ -1617,11 +1749,11 @@ var no_access_state_in_setstate_default = createRule({
1617
1749
  messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
1618
1750
  schema: []
1619
1751
  },
1620
- name: RULE_NAME$53,
1621
- create: create$53,
1752
+ name: RULE_NAME$51,
1753
+ create: create$51,
1622
1754
  defaultOptions: []
1623
1755
  });
1624
- function create$53(context) {
1756
+ function create$51(context) {
1625
1757
  if (!context.sourceCode.text.includes("setState")) return {};
1626
1758
  const classStack = [];
1627
1759
  const methodStack = [];
@@ -1692,7 +1824,7 @@ function create$53(context) {
1692
1824
 
1693
1825
  //#endregion
1694
1826
  //#region src/rules/no-array-index-key.ts
1695
- const RULE_NAME$52 = "no-array-index-key";
1827
+ const RULE_NAME$50 = "no-array-index-key";
1696
1828
  const REACT_CHILDREN_METHOD = ["forEach", "map"];
1697
1829
  function getIndexParamPosition(methodName) {
1698
1830
  switch (methodName) {
@@ -1751,11 +1883,11 @@ var no_array_index_key_default = createRule({
1751
1883
  messages: { default: "Do not use item index in the array as its key." },
1752
1884
  schema: []
1753
1885
  },
1754
- name: RULE_NAME$52,
1755
- create: create$52,
1886
+ name: RULE_NAME$50,
1887
+ create: create$50,
1756
1888
  defaultOptions: []
1757
1889
  });
1758
- function create$52(context) {
1890
+ function create$50(context) {
1759
1891
  const indexParamNames = [];
1760
1892
  function isArrayIndex(node) {
1761
1893
  return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name) => name != null && name === node.name);
@@ -1821,7 +1953,7 @@ function create$52(context) {
1821
1953
 
1822
1954
  //#endregion
1823
1955
  //#region src/rules/no-children-count.ts
1824
- const RULE_NAME$51 = "no-children-count";
1956
+ const RULE_NAME$49 = "no-children-count";
1825
1957
  var no_children_count_default = createRule({
1826
1958
  meta: {
1827
1959
  type: "problem",
@@ -1829,11 +1961,11 @@ var no_children_count_default = createRule({
1829
1961
  messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
1830
1962
  schema: []
1831
1963
  },
1832
- name: RULE_NAME$51,
1833
- create: create$51,
1964
+ name: RULE_NAME$49,
1965
+ create: create$49,
1834
1966
  defaultOptions: []
1835
1967
  });
1836
- function create$51(context) {
1968
+ function create$49(context) {
1837
1969
  return defineRuleListener({ MemberExpression(node) {
1838
1970
  if (core.isChildrenCount(context, node)) context.report({
1839
1971
  messageId: "default",
@@ -1844,7 +1976,7 @@ function create$51(context) {
1844
1976
 
1845
1977
  //#endregion
1846
1978
  //#region src/rules/no-children-for-each.ts
1847
- const RULE_NAME$50 = "no-children-for-each";
1979
+ const RULE_NAME$48 = "no-children-for-each";
1848
1980
  var no_children_for_each_default = createRule({
1849
1981
  meta: {
1850
1982
  type: "problem",
@@ -1852,11 +1984,11 @@ var no_children_for_each_default = createRule({
1852
1984
  messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
1853
1985
  schema: []
1854
1986
  },
1855
- name: RULE_NAME$50,
1856
- create: create$50,
1987
+ name: RULE_NAME$48,
1988
+ create: create$48,
1857
1989
  defaultOptions: []
1858
1990
  });
1859
- function create$50(context) {
1991
+ function create$48(context) {
1860
1992
  return defineRuleListener({ MemberExpression(node) {
1861
1993
  if (core.isChildrenForEach(context, node)) context.report({
1862
1994
  messageId: "default",
@@ -1867,7 +1999,7 @@ function create$50(context) {
1867
1999
 
1868
2000
  //#endregion
1869
2001
  //#region src/rules/no-children-map.ts
1870
- const RULE_NAME$49 = "no-children-map";
2002
+ const RULE_NAME$47 = "no-children-map";
1871
2003
  var no_children_map_default = createRule({
1872
2004
  meta: {
1873
2005
  type: "problem",
@@ -1875,11 +2007,11 @@ var no_children_map_default = createRule({
1875
2007
  messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
1876
2008
  schema: []
1877
2009
  },
1878
- name: RULE_NAME$49,
1879
- create: create$49,
2010
+ name: RULE_NAME$47,
2011
+ create: create$47,
1880
2012
  defaultOptions: []
1881
2013
  });
1882
- function create$49(context) {
2014
+ function create$47(context) {
1883
2015
  return defineRuleListener({ MemberExpression(node) {
1884
2016
  if (core.isChildrenMap(context, node)) context.report({
1885
2017
  messageId: "default",
@@ -1890,7 +2022,7 @@ function create$49(context) {
1890
2022
 
1891
2023
  //#endregion
1892
2024
  //#region src/rules/no-children-only.ts
1893
- const RULE_NAME$48 = "no-children-only";
2025
+ const RULE_NAME$46 = "no-children-only";
1894
2026
  var no_children_only_default = createRule({
1895
2027
  meta: {
1896
2028
  type: "problem",
@@ -1898,11 +2030,11 @@ var no_children_only_default = createRule({
1898
2030
  messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
1899
2031
  schema: []
1900
2032
  },
1901
- name: RULE_NAME$48,
1902
- create: create$48,
2033
+ name: RULE_NAME$46,
2034
+ create: create$46,
1903
2035
  defaultOptions: []
1904
2036
  });
1905
- function create$48(context) {
2037
+ function create$46(context) {
1906
2038
  return defineRuleListener({ MemberExpression(node) {
1907
2039
  if (core.isChildrenOnly(context, node)) context.report({
1908
2040
  messageId: "default",
@@ -1913,7 +2045,7 @@ function create$48(context) {
1913
2045
 
1914
2046
  //#endregion
1915
2047
  //#region src/rules/no-children-prop.ts
1916
- const RULE_NAME$47 = "no-children-prop";
2048
+ const RULE_NAME$45 = "no-children-prop";
1917
2049
  var no_children_prop_default = createRule({
1918
2050
  meta: {
1919
2051
  type: "problem",
@@ -1921,11 +2053,11 @@ var no_children_prop_default = createRule({
1921
2053
  messages: { default: "Do not pass 'children' as props." },
1922
2054
  schema: []
1923
2055
  },
1924
- name: RULE_NAME$47,
1925
- create: create$47,
2056
+ name: RULE_NAME$45,
2057
+ create: create$45,
1926
2058
  defaultOptions: []
1927
2059
  });
1928
- function create$47(context) {
2060
+ function create$45(context) {
1929
2061
  return defineRuleListener({ JSXElement(node) {
1930
2062
  const childrenProp = core.getJsxAttribute(context, node)("children");
1931
2063
  if (childrenProp != null) context.report({
@@ -1937,7 +2069,7 @@ function create$47(context) {
1937
2069
 
1938
2070
  //#endregion
1939
2071
  //#region src/rules/no-children-to-array.ts
1940
- const RULE_NAME$46 = "no-children-to-array";
2072
+ const RULE_NAME$44 = "no-children-to-array";
1941
2073
  var no_children_to_array_default = createRule({
1942
2074
  meta: {
1943
2075
  type: "problem",
@@ -1945,11 +2077,11 @@ var no_children_to_array_default = createRule({
1945
2077
  messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
1946
2078
  schema: []
1947
2079
  },
1948
- name: RULE_NAME$46,
1949
- create: create$46,
2080
+ name: RULE_NAME$44,
2081
+ create: create$44,
1950
2082
  defaultOptions: []
1951
2083
  });
1952
- function create$46(context) {
2084
+ function create$44(context) {
1953
2085
  return defineRuleListener({ MemberExpression(node) {
1954
2086
  if (core.isChildrenToArray(context, node)) context.report({
1955
2087
  messageId: "default",
@@ -1960,7 +2092,7 @@ function create$46(context) {
1960
2092
 
1961
2093
  //#endregion
1962
2094
  //#region src/rules/no-class-component.ts
1963
- const RULE_NAME$45 = "no-class-component";
2095
+ const RULE_NAME$43 = "no-class-component";
1964
2096
  var no_class_component_default = createRule({
1965
2097
  meta: {
1966
2098
  type: "problem",
@@ -1968,11 +2100,11 @@ var no_class_component_default = createRule({
1968
2100
  messages: { default: "Avoid using class components. Use function components instead." },
1969
2101
  schema: []
1970
2102
  },
1971
- name: RULE_NAME$45,
1972
- create: create$45,
2103
+ name: RULE_NAME$43,
2104
+ create: create$43,
1973
2105
  defaultOptions: []
1974
2106
  });
1975
- function create$45(context) {
2107
+ function create$43(context) {
1976
2108
  if (!context.sourceCode.text.includes("Component")) return {};
1977
2109
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
1978
2110
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -1989,7 +2121,7 @@ function create$45(context) {
1989
2121
 
1990
2122
  //#endregion
1991
2123
  //#region src/rules/no-clone-element.ts
1992
- const RULE_NAME$44 = "no-clone-element";
2124
+ const RULE_NAME$42 = "no-clone-element";
1993
2125
  var no_clone_element_default = createRule({
1994
2126
  meta: {
1995
2127
  type: "problem",
@@ -1997,11 +2129,11 @@ var no_clone_element_default = createRule({
1997
2129
  messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
1998
2130
  schema: []
1999
2131
  },
2000
- name: RULE_NAME$44,
2001
- create: create$44,
2132
+ name: RULE_NAME$42,
2133
+ create: create$42,
2002
2134
  defaultOptions: []
2003
2135
  });
2004
- function create$44(context) {
2136
+ function create$42(context) {
2005
2137
  return defineRuleListener({ CallExpression(node) {
2006
2138
  if (core.isCloneElementCall(context, node)) context.report({
2007
2139
  messageId: "default",
@@ -2012,7 +2144,7 @@ function create$44(context) {
2012
2144
 
2013
2145
  //#endregion
2014
2146
  //#region src/rules/no-component-will-mount.ts
2015
- const RULE_NAME$43 = "no-component-will-mount";
2147
+ const RULE_NAME$41 = "no-component-will-mount";
2016
2148
  var no_component_will_mount_default = createRule({
2017
2149
  meta: {
2018
2150
  type: "problem",
@@ -2021,11 +2153,11 @@ var no_component_will_mount_default = createRule({
2021
2153
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
2022
2154
  schema: []
2023
2155
  },
2024
- name: RULE_NAME$43,
2025
- create: create$43,
2156
+ name: RULE_NAME$41,
2157
+ create: create$41,
2026
2158
  defaultOptions: []
2027
2159
  });
2028
- function create$43(context) {
2160
+ function create$41(context) {
2029
2161
  if (!context.sourceCode.text.includes("componentWillMount")) return {};
2030
2162
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2031
2163
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2045,7 +2177,7 @@ function create$43(context) {
2045
2177
 
2046
2178
  //#endregion
2047
2179
  //#region src/rules/no-component-will-receive-props.ts
2048
- const RULE_NAME$42 = "no-component-will-receive-props";
2180
+ const RULE_NAME$40 = "no-component-will-receive-props";
2049
2181
  var no_component_will_receive_props_default = createRule({
2050
2182
  meta: {
2051
2183
  type: "problem",
@@ -2054,11 +2186,11 @@ var no_component_will_receive_props_default = createRule({
2054
2186
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
2055
2187
  schema: []
2056
2188
  },
2057
- name: RULE_NAME$42,
2058
- create: create$42,
2189
+ name: RULE_NAME$40,
2190
+ create: create$40,
2059
2191
  defaultOptions: []
2060
2192
  });
2061
- function create$42(context) {
2193
+ function create$40(context) {
2062
2194
  if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
2063
2195
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2064
2196
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2078,7 +2210,7 @@ function create$42(context) {
2078
2210
 
2079
2211
  //#endregion
2080
2212
  //#region src/rules/no-component-will-update.ts
2081
- const RULE_NAME$41 = "no-component-will-update";
2213
+ const RULE_NAME$39 = "no-component-will-update";
2082
2214
  var no_component_will_update_default = createRule({
2083
2215
  meta: {
2084
2216
  type: "problem",
@@ -2087,11 +2219,11 @@ var no_component_will_update_default = createRule({
2087
2219
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
2088
2220
  schema: []
2089
2221
  },
2090
- name: RULE_NAME$41,
2091
- create: create$41,
2222
+ name: RULE_NAME$39,
2223
+ create: create$39,
2092
2224
  defaultOptions: []
2093
2225
  });
2094
- function create$41(context) {
2226
+ function create$39(context) {
2095
2227
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
2096
2228
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2097
2229
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2111,7 +2243,7 @@ function create$41(context) {
2111
2243
 
2112
2244
  //#endregion
2113
2245
  //#region src/rules/no-context-provider.ts
2114
- const RULE_NAME$40 = "no-context-provider";
2246
+ const RULE_NAME$38 = "no-context-provider";
2115
2247
  var no_context_provider_default = createRule({
2116
2248
  meta: {
2117
2249
  type: "problem",
@@ -2120,11 +2252,11 @@ var no_context_provider_default = createRule({
2120
2252
  messages: { default: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'." },
2121
2253
  schema: []
2122
2254
  },
2123
- name: RULE_NAME$40,
2124
- create: create$40,
2255
+ name: RULE_NAME$38,
2256
+ create: create$38,
2125
2257
  defaultOptions: []
2126
2258
  });
2127
- function create$40(context) {
2259
+ function create$38(context) {
2128
2260
  if (!context.sourceCode.text.includes("Provider")) return {};
2129
2261
  const { version } = getSettingsFromContext(context);
2130
2262
  if (compare(version, "19.0.0", "<")) return {};
@@ -2151,7 +2283,7 @@ function create$40(context) {
2151
2283
 
2152
2284
  //#endregion
2153
2285
  //#region src/rules/no-create-ref.ts
2154
- const RULE_NAME$39 = "no-create-ref";
2286
+ const RULE_NAME$37 = "no-create-ref";
2155
2287
  var no_create_ref_default = createRule({
2156
2288
  meta: {
2157
2289
  type: "problem",
@@ -2159,11 +2291,11 @@ var no_create_ref_default = createRule({
2159
2291
  messages: { default: "[Deprecated] Use 'useRef' instead." },
2160
2292
  schema: []
2161
2293
  },
2162
- name: RULE_NAME$39,
2163
- create: create$39,
2294
+ name: RULE_NAME$37,
2295
+ create: create$37,
2164
2296
  defaultOptions: []
2165
2297
  });
2166
- function create$39(context) {
2298
+ function create$37(context) {
2167
2299
  return defineRuleListener({ CallExpression(node) {
2168
2300
  if (core.isCreateRefCall(context, node) && ast.findParentNode(node, core.isClassComponent) == null) context.report({
2169
2301
  messageId: "default",
@@ -2174,7 +2306,7 @@ function create$39(context) {
2174
2306
 
2175
2307
  //#endregion
2176
2308
  //#region src/rules/no-direct-mutation-state.ts
2177
- const RULE_NAME$38 = "no-direct-mutation-state";
2309
+ const RULE_NAME$36 = "no-direct-mutation-state";
2178
2310
  function isConstructorFunction(node) {
2179
2311
  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";
2180
2312
  }
@@ -2185,11 +2317,11 @@ var no_direct_mutation_state_default = createRule({
2185
2317
  messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
2186
2318
  schema: []
2187
2319
  },
2188
- name: RULE_NAME$38,
2189
- create: create$38,
2320
+ name: RULE_NAME$36,
2321
+ create: create$36,
2190
2322
  defaultOptions: []
2191
2323
  });
2192
- function create$38(context) {
2324
+ function create$36(context) {
2193
2325
  return defineRuleListener({ AssignmentExpression(node) {
2194
2326
  if (!core.isAssignmentToThisState(node)) return;
2195
2327
  const parentClass = ast.findParentNode(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
@@ -2203,7 +2335,7 @@ function create$38(context) {
2203
2335
 
2204
2336
  //#endregion
2205
2337
  //#region src/rules/no-duplicate-key.ts
2206
- const RULE_NAME$37 = "no-duplicate-key";
2338
+ const RULE_NAME$35 = "no-duplicate-key";
2207
2339
  var no_duplicate_key_default = createRule({
2208
2340
  meta: {
2209
2341
  type: "problem",
@@ -2211,11 +2343,11 @@ var no_duplicate_key_default = createRule({
2211
2343
  messages: { default: "The 'key' prop must be unique to its sibling elements." },
2212
2344
  schema: []
2213
2345
  },
2214
- name: RULE_NAME$37,
2215
- create: create$37,
2346
+ name: RULE_NAME$35,
2347
+ create: create$35,
2216
2348
  defaultOptions: []
2217
2349
  });
2218
- function create$37(context) {
2350
+ function create$35(context) {
2219
2351
  if (!context.sourceCode.text.includes("key=")) return {};
2220
2352
  const keyedEntries = /* @__PURE__ */ new Map();
2221
2353
  function isKeyValueEqual(a, b) {
@@ -2270,7 +2402,7 @@ function create$37(context) {
2270
2402
 
2271
2403
  //#endregion
2272
2404
  //#region src/rules/no-forward-ref.ts
2273
- const RULE_NAME$36 = "no-forward-ref";
2405
+ const RULE_NAME$34 = "no-forward-ref";
2274
2406
  var no_forward_ref_default = createRule({
2275
2407
  meta: {
2276
2408
  type: "problem",
@@ -2279,11 +2411,11 @@ var no_forward_ref_default = createRule({
2279
2411
  messages: { default: "In React 19, 'forwardRef' is no longer necessary. Pass 'ref' as a prop instead." },
2280
2412
  schema: []
2281
2413
  },
2282
- name: RULE_NAME$36,
2283
- create: create$36,
2414
+ name: RULE_NAME$34,
2415
+ create: create$34,
2284
2416
  defaultOptions: []
2285
2417
  });
2286
- function create$36(context) {
2418
+ function create$34(context) {
2287
2419
  if (!context.sourceCode.text.includes("forwardRef")) return {};
2288
2420
  const { version } = getSettingsFromContext(context);
2289
2421
  if (compare(version, "19.0.0", "<")) return {};
@@ -2378,7 +2510,7 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
2378
2510
 
2379
2511
  //#endregion
2380
2512
  //#region src/rules/no-implicit-key.ts
2381
- const RULE_NAME$35 = "no-implicit-key";
2513
+ const RULE_NAME$33 = "no-implicit-key";
2382
2514
  var no_implicit_key_default = createRule({
2383
2515
  meta: {
2384
2516
  type: "problem",
@@ -2386,11 +2518,11 @@ var no_implicit_key_default = createRule({
2386
2518
  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}'." },
2387
2519
  schema: []
2388
2520
  },
2389
- name: RULE_NAME$35,
2390
- create: create$35,
2521
+ name: RULE_NAME$33,
2522
+ create: create$33,
2391
2523
  defaultOptions: []
2392
2524
  });
2393
- function create$35(context) {
2525
+ function create$33(context) {
2394
2526
  const services = ESLintUtils.getParserServices(context, false);
2395
2527
  const checker = services.program.getTypeChecker();
2396
2528
  return defineRuleListener({ JSXSpreadAttribute(node) {
@@ -2408,7 +2540,7 @@ function create$35(context) {
2408
2540
 
2409
2541
  //#endregion
2410
2542
  //#region src/rules/no-leaked-conditional-rendering.ts
2411
- const RULE_NAME$34 = "no-leaked-conditional-rendering";
2543
+ const RULE_NAME$32 = "no-leaked-conditional-rendering";
2412
2544
  var no_leaked_conditional_rendering_default = createRule({
2413
2545
  meta: {
2414
2546
  type: "problem",
@@ -2416,11 +2548,11 @@ var no_leaked_conditional_rendering_default = createRule({
2416
2548
  messages: { default: "Potential leaked value {{value}} that might cause unintentionally rendered values or rendering crashes." },
2417
2549
  schema: []
2418
2550
  },
2419
- name: RULE_NAME$34,
2420
- create: create$34,
2551
+ name: RULE_NAME$32,
2552
+ create: create$32,
2421
2553
  defaultOptions: []
2422
2554
  });
2423
- function create$34(context) {
2555
+ function create$32(context) {
2424
2556
  if (!context.sourceCode.text.includes("&&")) return {};
2425
2557
  const { version } = getSettingsFromContext(context);
2426
2558
  const allowedVariants = [
@@ -2477,7 +2609,7 @@ function create$34(context) {
2477
2609
 
2478
2610
  //#endregion
2479
2611
  //#region src/rules/no-missing-component-display-name.ts
2480
- const RULE_NAME$33 = "no-missing-component-display-name";
2612
+ const RULE_NAME$31 = "no-missing-component-display-name";
2481
2613
  var no_missing_component_display_name_default = createRule({
2482
2614
  meta: {
2483
2615
  type: "problem",
@@ -2485,11 +2617,11 @@ var no_missing_component_display_name_default = createRule({
2485
2617
  messages: { default: "Add missing 'displayName' for component." },
2486
2618
  schema: []
2487
2619
  },
2488
- name: RULE_NAME$33,
2489
- create: create$33,
2620
+ name: RULE_NAME$31,
2621
+ create: create$31,
2490
2622
  defaultOptions: []
2491
2623
  });
2492
- function create$33(context) {
2624
+ function create$31(context) {
2493
2625
  if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
2494
2626
  const { ctx, visitor } = core.useComponentCollector(context, {
2495
2627
  collectDisplayName: true,
@@ -2511,7 +2643,7 @@ function create$33(context) {
2511
2643
 
2512
2644
  //#endregion
2513
2645
  //#region src/rules/no-missing-context-display-name.ts
2514
- const RULE_NAME$32 = "no-missing-context-display-name";
2646
+ const RULE_NAME$30 = "no-missing-context-display-name";
2515
2647
  var no_missing_context_display_name_default = createRule({
2516
2648
  meta: {
2517
2649
  type: "problem",
@@ -2520,11 +2652,11 @@ var no_missing_context_display_name_default = createRule({
2520
2652
  messages: { default: "Add missing 'displayName' for context." },
2521
2653
  schema: []
2522
2654
  },
2523
- name: RULE_NAME$32,
2524
- create: create$32,
2655
+ name: RULE_NAME$30,
2656
+ create: create$30,
2525
2657
  defaultOptions: []
2526
2658
  });
2527
- function create$32(context) {
2659
+ function create$30(context) {
2528
2660
  if (!context.sourceCode.text.includes("createContext")) return {};
2529
2661
  const createCalls = [];
2530
2662
  const displayNameAssignments = [];
@@ -2576,7 +2708,7 @@ function create$32(context) {
2576
2708
 
2577
2709
  //#endregion
2578
2710
  //#region src/rules/no-missing-key.ts
2579
- const RULE_NAME$31 = "no-missing-key";
2711
+ const RULE_NAME$29 = "no-missing-key";
2580
2712
  var no_missing_key_default = createRule({
2581
2713
  meta: {
2582
2714
  type: "problem",
@@ -2587,11 +2719,11 @@ var no_missing_key_default = createRule({
2587
2719
  },
2588
2720
  schema: []
2589
2721
  },
2590
- name: RULE_NAME$31,
2591
- create: create$31,
2722
+ name: RULE_NAME$29,
2723
+ create: create$29,
2592
2724
  defaultOptions: []
2593
2725
  });
2594
- function create$31(ctx) {
2726
+ function create$29(ctx) {
2595
2727
  let inChildrenToArray = false;
2596
2728
  function check(node) {
2597
2729
  if (node.type === AST_NODE_TYPES.JSXElement) return core.getJsxAttribute(ctx, node)("key") == null ? {
@@ -2662,7 +2794,7 @@ function create$31(ctx) {
2662
2794
 
2663
2795
  //#endregion
2664
2796
  //#region src/rules/no-misused-capture-owner-stack.ts
2665
- const RULE_NAME$30 = "no-misused-capture-owner-stack";
2797
+ const RULE_NAME$28 = "no-misused-capture-owner-stack";
2666
2798
  var no_misused_capture_owner_stack_default = createRule({
2667
2799
  meta: {
2668
2800
  type: "problem",
@@ -2673,11 +2805,11 @@ var no_misused_capture_owner_stack_default = createRule({
2673
2805
  },
2674
2806
  schema: []
2675
2807
  },
2676
- name: RULE_NAME$30,
2677
- create: create$30,
2808
+ name: RULE_NAME$28,
2809
+ create: create$28,
2678
2810
  defaultOptions: []
2679
2811
  });
2680
- function create$30(context) {
2812
+ function create$28(context) {
2681
2813
  if (!context.sourceCode.text.includes("captureOwnerStack")) return {};
2682
2814
  const { importSource } = getSettingsFromContext(context);
2683
2815
  return defineRuleListener({
@@ -2708,7 +2840,7 @@ function isDevelopmentOnlyCheck(node) {
2708
2840
 
2709
2841
  //#endregion
2710
2842
  //#region src/rules/no-nested-component-definitions.ts
2711
- const RULE_NAME$29 = "no-nested-component-definitions";
2843
+ const RULE_NAME$27 = "no-nested-component-definitions";
2712
2844
  var no_nested_component_definitions_default = createRule({
2713
2845
  meta: {
2714
2846
  type: "problem",
@@ -2716,23 +2848,24 @@ var no_nested_component_definitions_default = createRule({
2716
2848
  messages: { default: "Do not nest component definitions inside other components or props. {{suggestion}}" },
2717
2849
  schema: []
2718
2850
  },
2719
- name: RULE_NAME$29,
2720
- create: create$29,
2851
+ name: RULE_NAME$27,
2852
+ create: create$27,
2721
2853
  defaultOptions: []
2722
2854
  });
2723
- function create$29(context) {
2855
+ function create$27(context) {
2724
2856
  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;
2725
2857
  const fCollector = core.useComponentCollector(context, { hint });
2726
2858
  const cCollector = core.useComponentCollectorLegacy(context);
2727
2859
  return defineRuleListener(fCollector.visitor, cCollector.visitor, { "Program:exit"(program) {
2728
2860
  const fComponents = [...fCollector.ctx.getAllComponents(program)];
2729
2861
  const cComponents = [...cCollector.ctx.getAllComponents(program)];
2730
- const isFunctionComponent = (node) => {
2731
- return ast.isFunction(node) && fComponents.some((component) => component.node === node);
2732
- };
2733
- const isClassComponent = (node) => {
2734
- return ast.isClass(node) && cComponents.some((component) => component.node === node);
2735
- };
2862
+ function findEnclosingComponent(node) {
2863
+ return ast.findParentNode(node, (n) => {
2864
+ if (ast.isFunction(n)) return fComponents.some((c) => c.node === n);
2865
+ if (ast.isClass(n)) return cComponents.some((c) => c.node === n);
2866
+ return false;
2867
+ });
2868
+ }
2736
2869
  for (const { name, node: component } of fComponents) {
2737
2870
  if (name == null) continue;
2738
2871
  if (core.isDirectValueOfRenderPropertyLoose(component)) continue;
@@ -2758,8 +2891,8 @@ function create$29(context) {
2758
2891
  });
2759
2892
  continue;
2760
2893
  }
2761
- const parentComponent = ast.findParentNode(component, isFunctionComponent);
2762
- if (parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent)) {
2894
+ const enclosingComponent = findEnclosingComponent(component);
2895
+ if (enclosingComponent != null && !core.isDirectValueOfRenderPropertyLoose(enclosingComponent)) {
2763
2896
  context.report({
2764
2897
  messageId: "default",
2765
2898
  node: component,
@@ -2780,7 +2913,7 @@ function create$29(context) {
2780
2913
  });
2781
2914
  }
2782
2915
  for (const { name = "unknown", node: component } of cComponents) {
2783
- if (ast.findParentNode(component, (n) => isClassComponent(n) || isFunctionComponent(n)) == null) continue;
2916
+ if (findEnclosingComponent(component) == null) continue;
2784
2917
  context.report({
2785
2918
  messageId: "default",
2786
2919
  node: component,
@@ -2825,7 +2958,7 @@ function isInsideCreateElementProps(context, node) {
2825
2958
 
2826
2959
  //#endregion
2827
2960
  //#region src/rules/no-nested-lazy-component-declarations.ts
2828
- const RULE_NAME$28 = "no-nested-lazy-component-declarations";
2961
+ const RULE_NAME$26 = "no-nested-lazy-component-declarations";
2829
2962
  var no_nested_lazy_component_declarations_default = createRule({
2830
2963
  meta: {
2831
2964
  type: "problem",
@@ -2833,11 +2966,11 @@ var no_nested_lazy_component_declarations_default = createRule({
2833
2966
  messages: { default: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
2834
2967
  schema: []
2835
2968
  },
2836
- name: RULE_NAME$28,
2837
- create: create$28,
2969
+ name: RULE_NAME$26,
2970
+ create: create$26,
2838
2971
  defaultOptions: []
2839
2972
  });
2840
- function create$28(context) {
2973
+ function create$26(context) {
2841
2974
  const hint = core.ComponentDetectionHint.None;
2842
2975
  const collector = core.useComponentCollector(context, { hint });
2843
2976
  const collectorLegacy = core.useComponentCollectorLegacy(context);
@@ -2866,7 +2999,7 @@ function create$28(context) {
2866
2999
 
2867
3000
  //#endregion
2868
3001
  //#region src/rules/no-redundant-should-component-update.ts
2869
- const RULE_NAME$27 = "no-redundant-should-component-update";
3002
+ const RULE_NAME$25 = "no-redundant-should-component-update";
2870
3003
  function isShouldComponentUpdate(node) {
2871
3004
  return ast.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
2872
3005
  }
@@ -2877,11 +3010,11 @@ var no_redundant_should_component_update_default = createRule({
2877
3010
  messages: { default: "'{{componentName}}' does not need 'shouldComponentUpdate' when extending 'React.PureComponent'." },
2878
3011
  schema: []
2879
3012
  },
2880
- name: RULE_NAME$27,
2881
- create: create$27,
3013
+ name: RULE_NAME$25,
3014
+ create: create$25,
2882
3015
  defaultOptions: []
2883
3016
  });
2884
- function create$27(context) {
3017
+ function create$25(context) {
2885
3018
  if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
2886
3019
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2887
3020
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2899,7 +3032,7 @@ function create$27(context) {
2899
3032
 
2900
3033
  //#endregion
2901
3034
  //#region src/rules/no-set-state-in-component-did-mount.ts
2902
- const RULE_NAME$26 = "no-set-state-in-component-did-mount";
3035
+ const RULE_NAME$24 = "no-set-state-in-component-did-mount";
2903
3036
  var no_set_state_in_component_did_mount_default = createRule({
2904
3037
  meta: {
2905
3038
  type: "problem",
@@ -2907,11 +3040,11 @@ var no_set_state_in_component_did_mount_default = createRule({
2907
3040
  messages: { default: "Do not call `this.setState` in `componentDidMount` outside functions such as callbacks." },
2908
3041
  schema: []
2909
3042
  },
2910
- name: RULE_NAME$26,
2911
- create: create$26,
3043
+ name: RULE_NAME$24,
3044
+ create: create$24,
2912
3045
  defaultOptions: []
2913
3046
  });
2914
- function create$26(context) {
3047
+ function create$24(context) {
2915
3048
  if (!context.sourceCode.text.includes("componentDidMount")) return {};
2916
3049
  return defineRuleListener({ CallExpression(node) {
2917
3050
  if (!core.isThisSetState(node)) return;
@@ -2929,7 +3062,7 @@ function create$26(context) {
2929
3062
 
2930
3063
  //#endregion
2931
3064
  //#region src/rules/no-set-state-in-component-did-update.ts
2932
- const RULE_NAME$25 = "no-set-state-in-component-did-update";
3065
+ const RULE_NAME$23 = "no-set-state-in-component-did-update";
2933
3066
  var no_set_state_in_component_did_update_default = createRule({
2934
3067
  meta: {
2935
3068
  type: "problem",
@@ -2937,11 +3070,11 @@ var no_set_state_in_component_did_update_default = createRule({
2937
3070
  messages: { default: "Do not call `this.setState` in `componentDidUpdate` outside functions such as callbacks." },
2938
3071
  schema: []
2939
3072
  },
2940
- name: RULE_NAME$25,
2941
- create: create$25,
3073
+ name: RULE_NAME$23,
3074
+ create: create$23,
2942
3075
  defaultOptions: []
2943
3076
  });
2944
- function create$25(context) {
3077
+ function create$23(context) {
2945
3078
  if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
2946
3079
  return defineRuleListener({ CallExpression(node) {
2947
3080
  if (!core.isThisSetState(node)) return;
@@ -2959,7 +3092,7 @@ function create$25(context) {
2959
3092
 
2960
3093
  //#endregion
2961
3094
  //#region src/rules/no-set-state-in-component-will-update.ts
2962
- const RULE_NAME$24 = "no-set-state-in-component-will-update";
3095
+ const RULE_NAME$22 = "no-set-state-in-component-will-update";
2963
3096
  var no_set_state_in_component_will_update_default = createRule({
2964
3097
  meta: {
2965
3098
  type: "problem",
@@ -2967,11 +3100,11 @@ var no_set_state_in_component_will_update_default = createRule({
2967
3100
  messages: { default: "Do not call `this.setState` in `componentWillUpdate` outside functions such as callbacks." },
2968
3101
  schema: []
2969
3102
  },
2970
- name: RULE_NAME$24,
2971
- create: create$24,
3103
+ name: RULE_NAME$22,
3104
+ create: create$22,
2972
3105
  defaultOptions: []
2973
3106
  });
2974
- function create$24(context) {
3107
+ function create$22(context) {
2975
3108
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
2976
3109
  return defineRuleListener({ CallExpression(node) {
2977
3110
  if (!core.isThisSetState(node)) return;
@@ -2989,7 +3122,7 @@ function create$24(context) {
2989
3122
 
2990
3123
  //#endregion
2991
3124
  //#region src/rules/no-unnecessary-use-callback.ts
2992
- const RULE_NAME$23 = "no-unnecessary-use-callback";
3125
+ const RULE_NAME$21 = "no-unnecessary-use-callback";
2993
3126
  var no_unnecessary_use_callback_default = createRule({
2994
3127
  meta: {
2995
3128
  type: "problem",
@@ -3000,11 +3133,11 @@ var no_unnecessary_use_callback_default = createRule({
3000
3133
  },
3001
3134
  schema: []
3002
3135
  },
3003
- name: RULE_NAME$23,
3004
- create: create$23,
3136
+ name: RULE_NAME$21,
3137
+ create: create$21,
3005
3138
  defaultOptions: []
3006
3139
  });
3007
- function create$23(context) {
3140
+ function create$21(context) {
3008
3141
  if (!context.sourceCode.text.includes("useCallback")) return {};
3009
3142
  return defineRuleListener({ VariableDeclarator(node) {
3010
3143
  const { id, init } = node;
@@ -3018,9 +3151,9 @@ function create$23(context) {
3018
3151
  const [arg0, arg1] = init.arguments;
3019
3152
  if (arg0 == null || arg1 == null) return;
3020
3153
  if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
3021
- const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
3022
- if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
3023
- return variableNode.elements.length === 0;
3154
+ const initNode = getVariableInitializer(findVariable(n.name, scope), 0);
3155
+ if (initNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
3156
+ return initNode.elements.length === 0;
3024
3157
  }).otherwise(() => false)) {
3025
3158
  report(context)(checkForUsageInsideUseEffectReport);
3026
3159
  return;
@@ -3029,9 +3162,9 @@ function create$23(context) {
3029
3162
  if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
3030
3163
  return n;
3031
3164
  }).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
3032
- const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
3033
- if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
3034
- return variableNode;
3165
+ const initNode = getVariableInitializer(findVariable(n.name, scope), 0);
3166
+ if (initNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && initNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
3167
+ return initNode;
3035
3168
  }).otherwise(() => null);
3036
3169
  if (arg0Node == null) return;
3037
3170
  if (!getChildScopes(context.sourceCode.getScope(arg0Node)).flatMap((x) => x.references).some((x) => x.resolved?.scope.block === component)) {
@@ -3066,7 +3199,7 @@ function checkForUsageInsideUseEffect$1(sourceCode, node) {
3066
3199
 
3067
3200
  //#endregion
3068
3201
  //#region src/rules/no-unnecessary-use-memo.ts
3069
- const RULE_NAME$22 = "no-unnecessary-use-memo";
3202
+ const RULE_NAME$20 = "no-unnecessary-use-memo";
3070
3203
  var no_unnecessary_use_memo_default = createRule({
3071
3204
  meta: {
3072
3205
  type: "problem",
@@ -3077,11 +3210,11 @@ var no_unnecessary_use_memo_default = createRule({
3077
3210
  },
3078
3211
  schema: []
3079
3212
  },
3080
- name: RULE_NAME$22,
3081
- create: create$22,
3213
+ name: RULE_NAME$20,
3214
+ create: create$20,
3082
3215
  defaultOptions: []
3083
3216
  });
3084
- function create$22(context) {
3217
+ function create$20(context) {
3085
3218
  if (!context.sourceCode.text.includes("useMemo")) return {};
3086
3219
  return defineRuleListener({ VariableDeclarator(node) {
3087
3220
  const { id, init } = node;
@@ -3099,9 +3232,9 @@ function create$22(context) {
3099
3232
  return;
3100
3233
  }
3101
3234
  if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
3102
- const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
3103
- if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
3104
- return variableNode.elements.length === 0;
3235
+ const initNode = getVariableInitializer(findVariable(n.name, scope), 0);
3236
+ if (initNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
3237
+ return initNode.elements.length === 0;
3105
3238
  }).otherwise(() => false)) {
3106
3239
  report(context)(checkForUsageInsideUseEffectReport);
3107
3240
  return;
@@ -3147,7 +3280,7 @@ function checkForUsageInsideUseEffect(sourceCode, node) {
3147
3280
 
3148
3281
  //#endregion
3149
3282
  //#region src/rules/no-unnecessary-use-prefix.ts
3150
- const RULE_NAME$21 = "no-unnecessary-use-prefix";
3283
+ const RULE_NAME$19 = "no-unnecessary-use-prefix";
3151
3284
  const WELL_KNOWN_HOOKS = ["useMDXComponents"];
3152
3285
  function containsUseComments(context, node) {
3153
3286
  return context.sourceCode.getCommentsInside(node).some(({ value }) => /use\([\s\S]*?\)/u.test(value) || /use[A-Z0-9]\w*\([\s\S]*?\)/u.test(value));
@@ -3159,11 +3292,11 @@ var no_unnecessary_use_prefix_default = createRule({
3159
3292
  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." },
3160
3293
  schema: []
3161
3294
  },
3162
- name: RULE_NAME$21,
3163
- create: create$21,
3295
+ name: RULE_NAME$19,
3296
+ create: create$19,
3164
3297
  defaultOptions: []
3165
3298
  });
3166
- function create$21(context) {
3299
+ function create$19(context) {
3167
3300
  const { ctx, visitor } = core.useHookCollector(context);
3168
3301
  return defineRuleListener(visitor, { "Program:exit"(program) {
3169
3302
  for (const { id, name, node, hookCalls } of ctx.getAllHooks(program)) {
@@ -3183,7 +3316,7 @@ function create$21(context) {
3183
3316
 
3184
3317
  //#endregion
3185
3318
  //#region src/rules/no-unsafe-component-will-mount.ts
3186
- const RULE_NAME$20 = "no-unsafe-component-will-mount";
3319
+ const RULE_NAME$18 = "no-unsafe-component-will-mount";
3187
3320
  var no_unsafe_component_will_mount_default = createRule({
3188
3321
  meta: {
3189
3322
  type: "problem",
@@ -3191,11 +3324,11 @@ var no_unsafe_component_will_mount_default = createRule({
3191
3324
  messages: { default: "Do not use 'UNSAFE_componentWillMount'." },
3192
3325
  schema: []
3193
3326
  },
3194
- name: RULE_NAME$20,
3195
- create: create$20,
3327
+ name: RULE_NAME$18,
3328
+ create: create$18,
3196
3329
  defaultOptions: []
3197
3330
  });
3198
- function create$20(context) {
3331
+ function create$18(context) {
3199
3332
  if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
3200
3333
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
3201
3334
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -3211,7 +3344,7 @@ function create$20(context) {
3211
3344
 
3212
3345
  //#endregion
3213
3346
  //#region src/rules/no-unsafe-component-will-receive-props.ts
3214
- const RULE_NAME$19 = "no-unsafe-component-will-receive-props";
3347
+ const RULE_NAME$17 = "no-unsafe-component-will-receive-props";
3215
3348
  var no_unsafe_component_will_receive_props_default = createRule({
3216
3349
  meta: {
3217
3350
  type: "problem",
@@ -3219,11 +3352,11 @@ var no_unsafe_component_will_receive_props_default = createRule({
3219
3352
  messages: { default: "Do not use 'UNSAFE_componentWillReceiveProps'." },
3220
3353
  schema: []
3221
3354
  },
3222
- name: RULE_NAME$19,
3223
- create: create$19,
3355
+ name: RULE_NAME$17,
3356
+ create: create$17,
3224
3357
  defaultOptions: []
3225
3358
  });
3226
- function create$19(context) {
3359
+ function create$17(context) {
3227
3360
  if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
3228
3361
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
3229
3362
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -3239,7 +3372,7 @@ function create$19(context) {
3239
3372
 
3240
3373
  //#endregion
3241
3374
  //#region src/rules/no-unsafe-component-will-update.ts
3242
- const RULE_NAME$18 = "no-unsafe-component-will-update";
3375
+ const RULE_NAME$16 = "no-unsafe-component-will-update";
3243
3376
  var no_unsafe_component_will_update_default = createRule({
3244
3377
  meta: {
3245
3378
  type: "problem",
@@ -3247,11 +3380,11 @@ var no_unsafe_component_will_update_default = createRule({
3247
3380
  messages: { default: "Do not use 'UNSAFE_componentWillUpdate'." },
3248
3381
  schema: []
3249
3382
  },
3250
- name: RULE_NAME$18,
3251
- create: create$18,
3383
+ name: RULE_NAME$16,
3384
+ create: create$16,
3252
3385
  defaultOptions: []
3253
3386
  });
3254
- function create$18(context) {
3387
+ function create$16(context) {
3255
3388
  if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
3256
3389
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
3257
3390
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -3267,7 +3400,7 @@ function create$18(context) {
3267
3400
 
3268
3401
  //#endregion
3269
3402
  //#region src/rules/no-unstable-context-value.ts
3270
- const RULE_NAME$17 = "no-unstable-context-value";
3403
+ const RULE_NAME$15 = "no-unstable-context-value";
3271
3404
  var no_unstable_context_value_default = createRule({
3272
3405
  meta: {
3273
3406
  type: "problem",
@@ -3275,11 +3408,11 @@ var no_unstable_context_value_default = createRule({
3275
3408
  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}}" },
3276
3409
  schema: []
3277
3410
  },
3278
- name: RULE_NAME$17,
3279
- create: create$17,
3411
+ name: RULE_NAME$15,
3412
+ create: create$15,
3280
3413
  defaultOptions: []
3281
3414
  });
3282
- function create$17(context) {
3415
+ function create$15(context) {
3283
3416
  const { compilationMode, version } = getSettingsFromContext(context);
3284
3417
  if (compilationMode === "infer" || compilationMode === "all") return {};
3285
3418
  if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
@@ -3331,7 +3464,7 @@ function isContextName(name, isReact18OrBelow) {
3331
3464
 
3332
3465
  //#endregion
3333
3466
  //#region src/rules/no-unstable-default-props.ts
3334
- const RULE_NAME$16 = "no-unstable-default-props";
3467
+ const RULE_NAME$14 = "no-unstable-default-props";
3335
3468
  const defaultOptions$2 = [{ safeDefaultProps: [] }];
3336
3469
  const schema$2 = [{
3337
3470
  type: "object",
@@ -3348,8 +3481,8 @@ var no_unstable_default_props_default = createRule({
3348
3481
  messages: { default: "A/an '{{kind}}' as default prop. This could lead to potential infinite render loop in React. Use a variable instead of '{{kind}}'." },
3349
3482
  schema: schema$2
3350
3483
  },
3351
- name: RULE_NAME$16,
3352
- create: create$16,
3484
+ name: RULE_NAME$14,
3485
+ create: create$14,
3353
3486
  defaultOptions: defaultOptions$2
3354
3487
  });
3355
3488
  function extractIdentifier(node) {
@@ -3360,7 +3493,7 @@ function extractIdentifier(node) {
3360
3493
  }
3361
3494
  return null;
3362
3495
  }
3363
- function create$16(context, [options]) {
3496
+ function create$14(context, [options]) {
3364
3497
  const { compilationMode } = getSettingsFromContext(context);
3365
3498
  if (compilationMode === "infer" || compilationMode === "all") return {};
3366
3499
  if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
@@ -3406,7 +3539,7 @@ function create$16(context, [options]) {
3406
3539
 
3407
3540
  //#endregion
3408
3541
  //#region src/rules/no-unused-class-component-members.ts
3409
- const RULE_NAME$15 = "no-unused-class-component-members";
3542
+ const RULE_NAME$13 = "no-unused-class-component-members";
3410
3543
  const LIFECYCLE_METHODS = new Set([
3411
3544
  "componentDidCatch",
3412
3545
  "componentDidMount",
@@ -3437,11 +3570,11 @@ var no_unused_class_component_members_default = createRule({
3437
3570
  messages: { default: "Unused method or property '{{methodName}}'' of class '{{className}}'." },
3438
3571
  schema: []
3439
3572
  },
3440
- name: RULE_NAME$15,
3441
- create: create$15,
3573
+ name: RULE_NAME$13,
3574
+ create: create$13,
3442
3575
  defaultOptions: []
3443
3576
  });
3444
- function create$15(context) {
3577
+ function create$13(context) {
3445
3578
  const classStack = [];
3446
3579
  const methodStack = [];
3447
3580
  const propertyDefs = /* @__PURE__ */ new WeakMap();
@@ -3522,7 +3655,7 @@ function create$15(context) {
3522
3655
 
3523
3656
  //#endregion
3524
3657
  //#region src/rules/no-unused-props.ts
3525
- const RULE_NAME$14 = "no-unused-props";
3658
+ const RULE_NAME$12 = "no-unused-props";
3526
3659
  var no_unused_props_default = createRule({
3527
3660
  meta: {
3528
3661
  type: "problem",
@@ -3530,11 +3663,11 @@ var no_unused_props_default = createRule({
3530
3663
  messages: { default: "Prop `{{name}}` is declared but never used" },
3531
3664
  schema: []
3532
3665
  },
3533
- name: RULE_NAME$14,
3534
- create: create$14,
3666
+ name: RULE_NAME$12,
3667
+ create: create$12,
3535
3668
  defaultOptions: []
3536
3669
  });
3537
- function create$14(context) {
3670
+ function create$12(context) {
3538
3671
  const services = ESLintUtils.getParserServices(context, false);
3539
3672
  const checker = services.program.getTypeChecker();
3540
3673
  const { ctx, visitor } = core.useComponentCollector(context);
@@ -3634,7 +3767,7 @@ function reportUnusedProp(context, services, prop) {
3634
3767
 
3635
3768
  //#endregion
3636
3769
  //#region src/rules/no-unused-state.ts
3637
- const RULE_NAME$13 = "no-unused-state";
3770
+ const RULE_NAME$11 = "no-unused-state";
3638
3771
  function isKeyLiteral(node, key) {
3639
3772
  return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
3640
3773
  type: AST_NODE_TYPES.TemplateLiteral,
@@ -3648,11 +3781,11 @@ var no_unused_state_default = createRule({
3648
3781
  messages: { default: "Unused class component state in '{{className}}'" },
3649
3782
  schema: []
3650
3783
  },
3651
- name: RULE_NAME$13,
3652
- create: create$13,
3784
+ name: RULE_NAME$11,
3785
+ create: create$11,
3653
3786
  defaultOptions: []
3654
3787
  });
3655
- function create$13(context) {
3788
+ function create$11(context) {
3656
3789
  const classStack = [];
3657
3790
  const methodStack = [];
3658
3791
  const constructorStack = [];
@@ -3761,7 +3894,7 @@ function create$13(context) {
3761
3894
 
3762
3895
  //#endregion
3763
3896
  //#region src/rules/no-use-context.ts
3764
- const RULE_NAME$12 = "no-use-context";
3897
+ const RULE_NAME$10 = "no-use-context";
3765
3898
  var no_use_context_default = createRule({
3766
3899
  meta: {
3767
3900
  type: "problem",
@@ -3770,11 +3903,11 @@ var no_use_context_default = createRule({
3770
3903
  messages: { default: "In React 19, 'use' is preferred over 'useContext' because it is more flexible." },
3771
3904
  schema: []
3772
3905
  },
3773
- name: RULE_NAME$12,
3774
- create: create$12,
3906
+ name: RULE_NAME$10,
3907
+ create: create$10,
3775
3908
  defaultOptions: []
3776
3909
  });
3777
- function create$12(context) {
3910
+ function create$10(context) {
3778
3911
  if (!context.sourceCode.text.includes("useContext")) return {};
3779
3912
  const settings = getSettingsFromContext(context);
3780
3913
  if (compare(settings.version, "19.0.0", "<")) return {};
@@ -3837,36 +3970,9 @@ function getCorrelativeTokens(context, node) {
3837
3970
  return tokens;
3838
3971
  }
3839
3972
 
3840
- //#endregion
3841
- //#region src/rules/no-useless-forward-ref.ts
3842
- const RULE_NAME$11 = "no-useless-forward-ref";
3843
- var no_useless_forward_ref_default = createRule({
3844
- meta: {
3845
- type: "problem",
3846
- docs: { description: "Disallows useless 'forwardRef' calls on components that don't use 'ref's." },
3847
- messages: { default: "A 'forwardRef' is used with this component but no 'ref' parameter is set." },
3848
- schema: []
3849
- },
3850
- name: RULE_NAME$11,
3851
- create: create$11,
3852
- defaultOptions: []
3853
- });
3854
- function create$11(context) {
3855
- return defineRuleListener({ CallExpression(node) {
3856
- if (!core.isForwardRefCall(context, node)) return;
3857
- const [component] = node.arguments;
3858
- if (component == null || !ast.isFunction(component)) return;
3859
- if (component.params[1] != null) return;
3860
- context.report({
3861
- messageId: "default",
3862
- node: node.callee
3863
- });
3864
- } });
3865
- }
3866
-
3867
3973
  //#endregion
3868
3974
  //#region src/rules/no-useless-fragment.ts
3869
- const RULE_NAME$10 = "no-useless-fragment";
3975
+ const RULE_NAME$9 = "no-useless-fragment";
3870
3976
  const defaultOptions$1 = [{
3871
3977
  allowEmptyFragment: false,
3872
3978
  allowExpressions: true
@@ -3894,11 +4000,11 @@ var no_useless_fragment_default = createRule({
3894
4000
  messages: { default: "A fragment {{reason}} is useless." },
3895
4001
  schema: schema$1
3896
4002
  },
3897
- name: RULE_NAME$10,
3898
- create: create$10,
4003
+ name: RULE_NAME$9,
4004
+ create: create$9,
3899
4005
  defaultOptions: defaultOptions$1
3900
4006
  });
3901
- function create$10(context, [option]) {
4007
+ function create$9(context, [option]) {
3902
4008
  const { allowEmptyFragment = false, allowExpressions = true } = option;
3903
4009
  const jsxConfig = {
3904
4010
  ...core.getJsxConfigFromContext(context),
@@ -4006,7 +4112,7 @@ function trimLikeReact(text) {
4006
4112
 
4007
4113
  //#endregion
4008
4114
  //#region src/rules/prefer-destructuring-assignment.ts
4009
- const RULE_NAME$9 = "prefer-destructuring-assignment";
4115
+ const RULE_NAME$8 = "prefer-destructuring-assignment";
4010
4116
  var prefer_destructuring_assignment_default = createRule({
4011
4117
  meta: {
4012
4118
  type: "problem",
@@ -4014,11 +4120,11 @@ var prefer_destructuring_assignment_default = createRule({
4014
4120
  messages: { default: "Use destructuring assignment for component props." },
4015
4121
  schema: []
4016
4122
  },
4017
- name: RULE_NAME$9,
4018
- create: create$9,
4123
+ name: RULE_NAME$8,
4124
+ create: create$8,
4019
4125
  defaultOptions: []
4020
4126
  });
4021
- function create$9(context) {
4127
+ function create$8(context) {
4022
4128
  const { ctx, visitor } = core.useComponentCollector(context);
4023
4129
  return defineRuleListener(visitor, { "Program:exit"(program) {
4024
4130
  for (const component of ctx.getAllComponents(program)) {
@@ -4042,7 +4148,7 @@ function create$9(context) {
4042
4148
 
4043
4149
  //#endregion
4044
4150
  //#region src/rules/prefer-namespace-import.ts
4045
- const RULE_NAME$8 = "prefer-namespace-import";
4151
+ const RULE_NAME$7 = "prefer-namespace-import";
4046
4152
  var prefer_namespace_import_default = createRule({
4047
4153
  meta: {
4048
4154
  type: "problem",
@@ -4051,11 +4157,11 @@ var prefer_namespace_import_default = createRule({
4051
4157
  messages: { default: "Prefer importing React as 'import * as React from \"{{importSource}}\"';" },
4052
4158
  schema: []
4053
4159
  },
4054
- name: RULE_NAME$8,
4055
- create: create$8,
4160
+ name: RULE_NAME$7,
4161
+ create: create$7,
4056
4162
  defaultOptions: []
4057
4163
  });
4058
- function create$8(context) {
4164
+ function create$7(context) {
4059
4165
  const { importSource } = getSettingsFromContext(context);
4060
4166
  return defineRuleListener({ [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
4061
4167
  const hasOtherSpecifiers = node.parent.specifiers.length > 1;
@@ -4077,59 +4183,6 @@ function create$8(context) {
4077
4183
  } });
4078
4184
  }
4079
4185
 
4080
- //#endregion
4081
- //#region src/rules/prefer-read-only-props.ts
4082
- const RULE_NAME$7 = "prefer-read-only-props";
4083
- var prefer_read_only_props_default = createRule({
4084
- meta: {
4085
- type: "problem",
4086
- docs: { description: "Enforces read-only props in components." },
4087
- messages: { default: "A function component's props should be read-only." },
4088
- schema: []
4089
- },
4090
- name: RULE_NAME$7,
4091
- create: create$7,
4092
- defaultOptions: []
4093
- });
4094
- function create$7(context) {
4095
- const services = ESLintUtils.getParserServices(context, false);
4096
- const checker = services.program.getTypeChecker();
4097
- const { ctx, visitor } = core.useComponentCollector(context);
4098
- return defineRuleListener(visitor, { "Program:exit"(program) {
4099
- for (const component of ctx.getAllComponents(program)) {
4100
- const [props] = component.node.params;
4101
- if (component.id == null || component.name == null) continue;
4102
- if (props == null) continue;
4103
- const propsType = getConstrainedTypeAtLocation(services, props);
4104
- if (isTypeReadonly(services.program, propsType)) continue;
4105
- if (isTypeReadonlyLoose(services, propsType)) continue;
4106
- if (propsType.isClassOrInterface() && isClassOrInterfaceReadonlyLoose(checker, propsType)) continue;
4107
- context.report({
4108
- messageId: "default",
4109
- node: props
4110
- });
4111
- }
4112
- } });
4113
- }
4114
- function isTypeReadonlyLoose(services, type) {
4115
- try {
4116
- const im = getTypeImmutability(services.program, type);
4117
- return isUnknown(im) || isImmutable(im) || isReadonlyShallow(im) || isReadonlyDeep(im);
4118
- } catch {
4119
- return true;
4120
- }
4121
- }
4122
- function isClassOrInterfaceReadonlyLoose(checker, type) {
4123
- const props = type.getProperties();
4124
- const types = type.getBaseTypes() ?? [];
4125
- if (props.length === 0) return true;
4126
- if (types.length === 0) return props.every((p) => isPropertyReadonlyInType(type, p.getEscapedName(), checker));
4127
- return props.every((p) => {
4128
- if (isPropertyReadonlyInType(type, p.getEscapedName(), checker)) return true;
4129
- return types.every((t) => isPropertyReadonlyInType(t, p.getEscapedName(), checker));
4130
- });
4131
- }
4132
-
4133
4186
  //#endregion
4134
4187
  //#region src/rules/purity.ts
4135
4188
  const RULE_NAME$6 = "purity";
@@ -6853,11 +6906,11 @@ function create$4(context) {
6853
6906
  }
6854
6907
  }
6855
6908
  function isIdFromUseStateCall(topLevelId, at) {
6856
- const variableNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
6857
- if (variableNode == null) return false;
6858
- if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
6859
- if (!isUseStateCall(variableNode)) return false;
6860
- const variableNodeParent = variableNode.parent;
6909
+ const initNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
6910
+ if (initNode == null) return false;
6911
+ if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
6912
+ if (!isUseStateCall(initNode)) return false;
6913
+ const variableNodeParent = initNode.parent;
6861
6914
  if (!("id" in variableNodeParent) || variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
6862
6915
  return variableNodeParent.id.elements.findIndex((e) => e?.type === AST_NODE_TYPES.Identifier && e.name === topLevelId.name) === at;
6863
6916
  }
@@ -7035,13 +7088,13 @@ function create$3(context) {
7035
7088
  return core.isUseStateLikeCall(node, additionalStateHooks);
7036
7089
  }
7037
7090
  function isIdFromUseStateCall(topLevelId, at) {
7038
- const variableNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
7039
- if (variableNode == null) return false;
7040
- if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
7041
- if (!isUseStateCall(variableNode)) return false;
7042
- const variableNodeParent = variableNode.parent;
7043
- if (!("id" in variableNodeParent) || variableNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
7044
- return variableNodeParent.id.elements.findIndex((e) => e?.type === AST_NODE_TYPES.Identifier && e.name === topLevelId.name) === at;
7091
+ const initNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
7092
+ if (initNode == null) return false;
7093
+ if (initNode.type !== AST_NODE_TYPES.CallExpression) return false;
7094
+ if (!isUseStateCall(initNode)) return false;
7095
+ const initNodeParent = initNode.parent;
7096
+ if (!("id" in initNodeParent) || initNodeParent.id?.type !== AST_NODE_TYPES.ArrayPattern) return true;
7097
+ return initNodeParent.id.elements.findIndex((e) => e?.type === AST_NODE_TYPES.Identifier && e.name === topLevelId.name) === at;
7045
7098
  }
7046
7099
  function isSetStateCall(node) {
7047
7100
  switch (node.callee.type) {
@@ -7413,11 +7466,11 @@ const plugin = {
7413
7466
  "component-hook-factories": component_hook_factories_default,
7414
7467
  "error-boundaries": error_boundaries_default,
7415
7468
  "exhaustive-deps": rule$1,
7469
+ immutability: immutability_default,
7416
7470
  "jsx-dollar": jsx_dollar_default,
7417
7471
  "jsx-key-before-spread": jsx_key_before_spread_default,
7418
7472
  "jsx-no-comment-textnodes": jsx_no_comment_textnodes_default,
7419
7473
  "jsx-no-duplicate-props": jsx_no_duplicate_props_default,
7420
- "jsx-no-undef": jsx_no_undef_default,
7421
7474
  "jsx-shorthand-boolean": jsx_shorthand_boolean_default,
7422
7475
  "jsx-shorthand-fragment": jsx_shorthand_fragment_default,
7423
7476
  "jsx-uses-react": jsx_uses_react_default,
@@ -7464,16 +7517,15 @@ const plugin = {
7464
7517
  "no-unused-props": no_unused_props_default,
7465
7518
  "no-unused-state": no_unused_state_default,
7466
7519
  "no-use-context": no_use_context_default,
7467
- "no-useless-forward-ref": no_useless_forward_ref_default,
7468
7520
  "no-useless-fragment": no_useless_fragment_default,
7469
7521
  "prefer-destructuring-assignment": prefer_destructuring_assignment_default,
7470
7522
  "prefer-namespace-import": prefer_namespace_import_default,
7471
- "prefer-read-only-props": prefer_read_only_props_default,
7472
7523
  purity: purity_default,
7473
7524
  refs: refs_default,
7474
7525
  "rules-of-hooks": rule,
7475
7526
  "set-state-in-effect": set_state_in_effect_default,
7476
7527
  "set-state-in-render": set_state_in_render_default,
7528
+ "static-components": no_nested_component_definitions_default,
7477
7529
  "unsupported-syntax": unsupported_syntax_default,
7478
7530
  "use-memo": use_memo_default,
7479
7531
  "use-state": use_state_default
@@ -7524,8 +7576,8 @@ const rules$6 = {
7524
7576
  "react-x/no-unsafe-component-will-mount": "warn",
7525
7577
  "react-x/no-unsafe-component-will-receive-props": "warn",
7526
7578
  "react-x/no-unsafe-component-will-update": "warn",
7579
+ "react-x/no-unused-class-component-members": "warn",
7527
7580
  "react-x/no-use-context": "warn",
7528
- "react-x/no-useless-forward-ref": "warn",
7529
7581
  "react-x/purity": "warn",
7530
7582
  "react-x/rules-of-hooks": "error",
7531
7583
  "react-x/set-state-in-effect": "warn",
@@ -7544,7 +7596,6 @@ const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
7544
7596
  */
7545
7597
  const rules$5 = {
7546
7598
  "react-x/jsx-no-duplicate-props": "off",
7547
- "react-x/jsx-no-undef": "off",
7548
7599
  "react-x/jsx-uses-react": "off",
7549
7600
  "react-x/jsx-uses-vars": "off"
7550
7601
  };
@@ -7600,7 +7651,6 @@ const rules$2 = {
7600
7651
  "react-x/no-unnecessary-use-memo": "warn",
7601
7652
  "react-x/no-unstable-context-value": "warn",
7602
7653
  "react-x/no-unstable-default-props": "warn",
7603
- "react-x/no-unused-class-component-members": "warn",
7604
7654
  "react-x/no-unused-state": "warn",
7605
7655
  "react-x/no-useless-fragment": "warn",
7606
7656
  "react-x/prefer-destructuring-assignment": "warn"