eslint-plugin-react-x 5.30.0-beta.6 → 5.30.0-beta.7

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 +142 -82
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { DEFAULT_ESLINT_REACT_SETTINGS, getSettingsFromContext, toRegExp } from
2
2
  import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
3
3
  import { Analyze, Check, Collect, Compare, Extract, Traverse } from "@eslint-react/ast";
4
4
  import * as core from "@eslint-react/core";
5
- import { getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
5
+ import { complete, getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
6
6
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
7
7
  import { P, isMatching, match } from "ts-pattern";
8
8
  import { isAssignmentTargetEqual, isInitializedFromReact, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin, resolveOriginChain } from "@eslint-react/var";
@@ -130,7 +130,7 @@ const rules$6 = {
130
130
  };
131
131
  // package.json
132
132
  var name$6 = "eslint-plugin-react-x";
133
- var version = "5.30.0-beta.6";
133
+ var version = "5.30.0-beta.7";
134
134
  // src/utils/create-rule.ts
135
135
  function getDocsUrl(ruleName) {
136
136
  return `https://eslint-react.xyz/docs/rules/${ruleName}`;
@@ -1815,6 +1815,7 @@ var no_children_count_default = createRule({
1815
1815
  create: create$45
1816
1816
  });
1817
1817
  function create$45(context) {
1818
+ if (!context.sourceCode.text.includes("Children")) return {};
1818
1819
  return { MemberExpression(node) {
1819
1820
  if (core.isChildrenCount(context, node)) context.report({
1820
1821
  messageId: "default",
@@ -1833,6 +1834,7 @@ var no_children_for_each_default = createRule({
1833
1834
  create: create$44
1834
1835
  });
1835
1836
  function create$44(context) {
1837
+ if (!context.sourceCode.text.includes("Children")) return {};
1836
1838
  return { MemberExpression(node) {
1837
1839
  if (core.isChildrenForEach(context, node)) context.report({
1838
1840
  messageId: "default",
@@ -1851,6 +1853,7 @@ var no_children_map_default = createRule({
1851
1853
  create: create$43
1852
1854
  });
1853
1855
  function create$43(context) {
1856
+ if (!context.sourceCode.text.includes("Children")) return {};
1854
1857
  return { MemberExpression(node) {
1855
1858
  if (core.isChildrenMap(context, node)) context.report({
1856
1859
  messageId: "default",
@@ -1869,6 +1872,7 @@ var no_children_only_default = createRule({
1869
1872
  create: create$42
1870
1873
  });
1871
1874
  function create$42(context) {
1875
+ if (!context.sourceCode.text.includes("Children")) return {};
1872
1876
  return { MemberExpression(node) {
1873
1877
  if (core.isChildrenOnly(context, node)) context.report({
1874
1878
  messageId: "default",
@@ -1887,6 +1891,7 @@ var no_children_to_array_default = createRule({
1887
1891
  create: create$41
1888
1892
  });
1889
1893
  function create$41(context) {
1894
+ if (!context.sourceCode.text.includes("Children")) return {};
1890
1895
  return { MemberExpression(node) {
1891
1896
  if (core.isChildrenToArray(context, node)) context.report({
1892
1897
  messageId: "default",
@@ -2070,6 +2075,7 @@ var no_clone_element_default = createRule({
2070
2075
  create: create$39
2071
2076
  });
2072
2077
  function create$39(context) {
2078
+ if (!context.sourceCode.text.includes("cloneElement")) return {};
2073
2079
  return { CallExpression(node) {
2074
2080
  if (core.isCloneElementCall(context, node)) context.report({
2075
2081
  messageId: "default",
@@ -2247,6 +2253,20 @@ var no_direct_mutation_state_default = createRule({
2247
2253
  name: "no-direct-mutation-state",
2248
2254
  create: create$33
2249
2255
  });
2256
+ function create$33(context) {
2257
+ if (!context.sourceCode.text.includes("Component")) return {};
2258
+ return { AssignmentExpression(node) {
2259
+ if (!isAssignmentToThisState(node)) return;
2260
+ const fact = Traverse.findParent(node, Check.isClass);
2261
+ if (fact == null || !core.isClassComponent(fact)) return;
2262
+ const constructor = Traverse.findParent(node, isConstructorFunction);
2263
+ if (Traverse.findParent(node, Check.isFunctionOrClass) === constructor) return;
2264
+ context.report({
2265
+ messageId: "default",
2266
+ node
2267
+ });
2268
+ } };
2269
+ }
2250
2270
  function isConstructorFunction(node) {
2251
2271
  return Check.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && Check.isPropertyOrMethod(node.parent) && Check.isIdentifier(node.parent.key, "constructor");
2252
2272
  }
@@ -2261,16 +2281,23 @@ function isAssignmentToThisState(node) {
2261
2281
  }
2262
2282
  return false;
2263
2283
  }
2264
- function create$33(context) {
2265
- return { AssignmentExpression(node) {
2266
- if (!isAssignmentToThisState(node)) return;
2267
- const fact = Traverse.findParent(node, Check.isClass);
2268
- if (fact == null) return;
2269
- if (core.isClassComponent(fact) && context.sourceCode.getScope(node).block !== Traverse.findParent(node, isConstructorFunction)) context.report({
2270
- messageId: "default",
2271
- node
2272
- });
2273
- } };
2284
+ // src/utils/jsx-iterator.ts
2285
+ const KNOWN_CALLBACK_POSITIONS = /* @__PURE__ */ new Map([
2286
+ ["flatMap", 0],
2287
+ ["from", 1],
2288
+ ["map", 0]
2289
+ ]);
2290
+ function getIteratorCallback(node) {
2291
+ const callee = Extract.unwrap(node.callee);
2292
+ if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
2293
+ if (!Check.isIdentifier(callee.property)) return null;
2294
+ const position = KNOWN_CALLBACK_POSITIONS.get(callee.property.name);
2295
+ if (position == null) return null;
2296
+ const argument = node.arguments[position];
2297
+ if (argument == null) return null;
2298
+ const callback = Extract.unwrap(argument);
2299
+ if (!Check.isFunction(callback)) return null;
2300
+ return callback;
2274
2301
  }
2275
2302
  var no_duplicate_key_default = createRule({
2276
2303
  meta: {
@@ -2283,59 +2310,72 @@ var no_duplicate_key_default = createRule({
2283
2310
  create: create$32
2284
2311
  });
2285
2312
  function create$32(context) {
2286
- if (!context.sourceCode.text.includes("key=")) return {};
2287
- const keyedEntries = /* @__PURE__ */ new Map();
2313
+ if (!/\bkey\b/u.test(context.sourceCode.text)) return {};
2314
+ let childrenRekeyingDepth = 0;
2315
+ const duplicateKeys = /* @__PURE__ */ new Set();
2316
+ const siblingKeys = /* @__PURE__ */ new Map();
2317
+ function getKeyValue(node) {
2318
+ const { value } = node;
2319
+ if (value == null) return null;
2320
+ return value.type === AST_NODE_TYPES.JSXExpressionContainer ? Extract.unwrap(value.expression) : value;
2321
+ }
2288
2322
  function isKeyValueEqual(a, b) {
2289
- const aValue = a.value;
2290
- const bValue = b.value;
2291
- if (aValue == null || bValue == null) return false;
2323
+ const aValue = getKeyValue(a);
2324
+ const bValue = getKeyValue(b);
2325
+ if (aValue == null || bValue == null) return aValue === bValue;
2292
2326
  return Compare.isEqual(aValue, bValue);
2293
2327
  }
2328
+ function isStaticKey(node) {
2329
+ const value = getKeyValue(node);
2330
+ if (value == null) return true;
2331
+ if (value.type === AST_NODE_TYPES.Literal) return typeof value.value === "string" || typeof value.value === "number";
2332
+ return value.type === AST_NODE_TYPES.TemplateLiteral && value.expressions.length === 0;
2333
+ }
2334
+ function isChildrenRekeyingCall(node) {
2335
+ return core.isChildrenToArrayCall(context, node) || core.isChildrenMapCall(context, node);
2336
+ }
2294
2337
  return {
2295
2338
  "JSXAttribute[name.name='key']"(node) {
2339
+ if (childrenRekeyingDepth > 0) return;
2296
2340
  const jsxElement = node.parent.parent;
2297
2341
  switch (jsxElement.parent.type) {
2298
2342
  case AST_NODE_TYPES.ArrayExpression:
2299
2343
  case AST_NODE_TYPES.JSXElement:
2300
2344
  case AST_NODE_TYPES.JSXFragment: {
2301
2345
  const root = jsxElement.parent;
2302
- const prevKeys = keyedEntries.get(root)?.keys ?? [];
2303
- keyedEntries.set(root, {
2304
- hasDuplicate: prevKeys.some((prevKey) => isKeyValueEqual(prevKey, node)),
2305
- keys: [...prevKeys, node],
2306
- root: jsxElement.parent
2307
- });
2346
+ const prevKeys = siblingKeys.get(root) ?? [];
2347
+ for (const prevKey of prevKeys) {
2348
+ if (!isKeyValueEqual(prevKey, node)) continue;
2349
+ duplicateKeys.add(prevKey);
2350
+ duplicateKeys.add(node);
2351
+ break;
2352
+ }
2353
+ siblingKeys.set(root, [...prevKeys, node]);
2308
2354
  break;
2309
2355
  }
2310
2356
  default: {
2311
- const call = Traverse.findParent(jsxElement, (n) => {
2312
- if (n.type !== AST_NODE_TYPES.CallExpression) return false;
2313
- const callee = Extract.unwrap(n.callee);
2314
- if (callee.type !== AST_NODE_TYPES.MemberExpression) return false;
2315
- return Check.isIdentifier(callee.property, "map");
2316
- });
2357
+ const call = Traverse.findParent(jsxElement, (n) => n.type === AST_NODE_TYPES.CallExpression && getIteratorCallback(n) != null);
2317
2358
  if (call == null) return;
2359
+ const callback = getIteratorCallback(call);
2360
+ if (callback == null) return;
2318
2361
  const iter = Traverse.findParent(jsxElement, Check.isFunction, (n) => n === call);
2319
2362
  if (iter == null) return;
2320
- const arg0 = call.arguments[0];
2321
- if (arg0 == null) return;
2322
- if (Extract.unwrap(arg0) !== iter) return;
2323
- keyedEntries.set(call, {
2324
- hasDuplicate: node.value?.type === AST_NODE_TYPES.Literal,
2325
- keys: [node],
2326
- root: call
2327
- });
2363
+ if (callback !== iter) return;
2364
+ if (isStaticKey(node)) duplicateKeys.add(node);
2328
2365
  }
2329
2366
  }
2330
2367
  },
2368
+ CallExpression(node) {
2369
+ if (isChildrenRekeyingCall(node)) childrenRekeyingDepth += 1;
2370
+ },
2371
+ "CallExpression:exit"(node) {
2372
+ if (isChildrenRekeyingCall(node)) childrenRekeyingDepth -= 1;
2373
+ },
2331
2374
  "Program:exit"() {
2332
- for (const { hasDuplicate, keys } of keyedEntries.values()) {
2333
- if (!hasDuplicate) continue;
2334
- for (const key of keys) context.report({
2335
- messageId: "default",
2336
- node: key
2337
- });
2338
- }
2375
+ for (const key of duplicateKeys) context.report({
2376
+ messageId: "default",
2377
+ node: key
2378
+ });
2339
2379
  }
2340
2380
  };
2341
2381
  }
@@ -2466,6 +2506,7 @@ var no_implicit_children_default = createRule({
2466
2506
  create: create$30
2467
2507
  });
2468
2508
  function create$30(context) {
2509
+ if (!context.sourceCode.text.includes("...")) return {};
2469
2510
  return createImplicitPropListener(context, {
2470
2511
  name: "children",
2471
2512
  isAllowedProp: (fqn) => fqn.endsWith("attributes.children") || fqn.endsWith("propswithchildren.children"),
@@ -2489,6 +2530,7 @@ var no_implicit_key_default = createRule({
2489
2530
  create: create$29
2490
2531
  });
2491
2532
  function create$29(context) {
2533
+ if (!context.sourceCode.text.includes("...")) return {};
2492
2534
  return createImplicitPropListener(context, {
2493
2535
  name: "key",
2494
2536
  isAllowedProp: (fqn) => fqn.endsWith("react.attributes.key"),
@@ -2515,6 +2557,7 @@ var no_implicit_ref_default = createRule({
2515
2557
  create: create$28
2516
2558
  });
2517
2559
  function create$28(context) {
2560
+ if (!context.sourceCode.text.includes("...")) return {};
2518
2561
  return createImplicitPropListener(context, {
2519
2562
  name: "ref",
2520
2563
  isAllowedProp: (fqn) => fqn.endsWith("attributes.ref"),
@@ -2659,7 +2702,19 @@ function create$25(context) {
2659
2702
  })) context.report({
2660
2703
  fix(fixer) {
2661
2704
  if (id.type !== AST_NODE_TYPES.Identifier || id.parent !== call.parent) return [];
2662
- return fixer.insertTextAfter(context.sourceCode.getTokenAfter(call) ?? call, [
2705
+ const declaration = id.parent.parent;
2706
+ if (declaration == null || declaration.type !== AST_NODE_TYPES.VariableDeclaration) return [];
2707
+ switch (declaration.parent.type) {
2708
+ case AST_NODE_TYPES.BlockStatement:
2709
+ case AST_NODE_TYPES.Program:
2710
+ case AST_NODE_TYPES.StaticBlock:
2711
+ case AST_NODE_TYPES.SwitchCase:
2712
+ case AST_NODE_TYPES.TSModuleBlock: break;
2713
+ default: return [];
2714
+ }
2715
+ const lastToken = context.sourceCode.getLastToken(declaration);
2716
+ if (lastToken == null) return [];
2717
+ return fixer.insertTextAfter(lastToken, [
2663
2718
  "\n",
2664
2719
  id.name,
2665
2720
  ".",
@@ -2678,12 +2733,6 @@ function create$25(context) {
2678
2733
  }
2679
2734
  };
2680
2735
  }
2681
- // src/rules/no-missing-key/lib.ts
2682
- const KNOWN_CALLBACK_POSITIONS = /* @__PURE__ */ new Map([
2683
- ["flatMap", 0],
2684
- ["from", 1],
2685
- ["map", 0]
2686
- ]);
2687
2736
  var no_missing_key_default = createRule({
2688
2737
  meta: {
2689
2738
  type: "problem",
@@ -2697,16 +2746,6 @@ var no_missing_key_default = createRule({
2697
2746
  name: "no-missing-key",
2698
2747
  create: create$24
2699
2748
  });
2700
- function getIteratorCallback(node) {
2701
- const callee = Extract.unwrap(node.callee);
2702
- if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
2703
- if (!Check.isIdentifier(callee.property)) return null;
2704
- const position = KNOWN_CALLBACK_POSITIONS.get(callee.property.name);
2705
- if (position == null) return null;
2706
- const callback = node.arguments[position];
2707
- if (callback == null || !Check.isFunction(callback)) return null;
2708
- return callback;
2709
- }
2710
2749
  function create$24(context) {
2711
2750
  let childrenToArrayDepth = 0;
2712
2751
  function visitItemExpression(node) {
@@ -2965,6 +3004,7 @@ var no_nested_lazy_component_declarations_default = createRule({
2965
3004
  create: create$21
2966
3005
  });
2967
3006
  function create$21(context) {
3007
+ if (!context.sourceCode.text.includes("lazy")) return {};
2968
3008
  const fc = core.getFunctionComponentCollector(context);
2969
3009
  const cc = core.getClassComponentCollector(context);
2970
3010
  const hc = core.getHookCollector(context);
@@ -3265,6 +3305,7 @@ const schema$1 = [{
3265
3305
  additionalProperties: false,
3266
3306
  properties: { safeDefaultProps: {
3267
3307
  type: "array",
3308
+ description: "Property names or patterns that are safe to use as default props.",
3268
3309
  items: { type: "string" }
3269
3310
  } }
3270
3311
  }];
@@ -3279,13 +3320,13 @@ var no_unstable_default_props_default = createRule({
3279
3320
  name: RULE_NAME$12,
3280
3321
  create: create$12
3281
3322
  });
3282
- function create$12(context, [options]) {
3323
+ function create$12(context) {
3324
+ const { safeDefaultProps } = complete(context.options[0], defaultOptions$1[0]);
3283
3325
  const { compilationMode } = getSettingsFromContext(context);
3284
3326
  if (compilationMode === "infer" || compilationMode === "all") return {};
3285
3327
  if (compilationMode === "annotation" && context.sourceCode.ast.body.some((stmt) => Check.isDirective(stmt, "use memo"))) return {};
3286
3328
  const { api, visitor } = core.getFunctionComponentCollector(context);
3287
3329
  const declarators = /* @__PURE__ */ new WeakMap();
3288
- const { safeDefaultProps = [] } = options;
3289
3330
  const safePatterns = safeDefaultProps.map((s) => toRegExp(s));
3290
3331
  return merge(visitor, {
3291
3332
  [SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR](node) {
@@ -3359,8 +3400,7 @@ function isExportedClass(node) {
3359
3400
  default: return false;
3360
3401
  }
3361
3402
  }
3362
- function isPublicMethod(def) {
3363
- const member = def.parent;
3403
+ function isPublicMethod(member) {
3364
3404
  switch (member.type) {
3365
3405
  case AST_NODE_TYPES.MethodDefinition: return member.accessibility == null || member.accessibility === "public";
3366
3406
  case AST_NODE_TYPES.PropertyDefinition: return (member.accessibility == null || member.accessibility === "public") && (member.value?.type === AST_NODE_TYPES.ArrowFunctionExpression || member.value?.type === AST_NODE_TYPES.FunctionExpression);
@@ -3378,8 +3418,17 @@ var no_unused_class_component_members_default = createRule({
3378
3418
  create: create$11
3379
3419
  });
3380
3420
  function create$11(context) {
3421
+ if (!context.sourceCode.text.includes("Component")) return {};
3381
3422
  const propertyDefs = /* @__PURE__ */ new WeakMap();
3423
+ const publicMethods = /* @__PURE__ */ new WeakMap();
3382
3424
  const propertyUsages = /* @__PURE__ */ new WeakMap();
3425
+ function getStaticName(key, computed) {
3426
+ const unwrapped = Extract.unwrap(key);
3427
+ if (!computed && Check.isIdentifier(unwrapped)) return unwrapped.name;
3428
+ if (unwrapped.type === AST_NODE_TYPES.Literal && typeof unwrapped.value === "string") return unwrapped.value;
3429
+ if (unwrapped.type === AST_NODE_TYPES.TemplateLiteral && unwrapped.expressions.length === 0) return unwrapped.quasis[0]?.value.cooked ?? unwrapped.quasis[0]?.value.raw ?? null;
3430
+ return null;
3431
+ }
3383
3432
  function classExit(node) {
3384
3433
  if (!core.isClassComponent(node)) return;
3385
3434
  const id = core.getClassId(node);
@@ -3387,21 +3436,20 @@ function create$11(context) {
3387
3436
  if (defs == null) return;
3388
3437
  const usages = propertyUsages.get(node);
3389
3438
  const exported = isExportedClass(node);
3390
- for (const def of defs) {
3391
- const methodName = def.name;
3439
+ const publicMembers = publicMethods.get(node);
3440
+ for (const [methodName, defNode] of defs) {
3392
3441
  if (usages?.has(methodName) ?? false) continue;
3393
- if (LIFECYCLE_METHODS.has(methodName)) {
3394
- if (methodName === "shouldComponentUpdate" && core.isPureComponent(node)) {} else continue;
3395
- }
3442
+ const isPureComponentShouldUpdate = methodName === "shouldComponentUpdate" && core.isPureComponent(node);
3443
+ if (LIFECYCLE_METHODS.has(methodName) && !isPureComponentShouldUpdate) continue;
3396
3444
  if (KNOWN_HOST_CONVENTION_METHODS.has(methodName)) continue;
3397
- if (exported && isPublicMethod(def)) continue;
3445
+ if (exported && (publicMembers?.has(methodName) ?? false)) continue;
3398
3446
  context.report({
3399
3447
  data: {
3400
3448
  className: id != null ? getText(context, id) : "Component",
3401
3449
  methodName
3402
3450
  },
3403
3451
  messageId: "default",
3404
- node: def
3452
+ node: defNode
3405
3453
  });
3406
3454
  }
3407
3455
  }
@@ -3409,7 +3457,11 @@ function create$11(context) {
3409
3457
  const currentClass = Traverse.findParent(node, Check.isClass);
3410
3458
  if (currentClass == null || !core.isClassComponent(currentClass)) return;
3411
3459
  if (node.static) return;
3412
- if (!node.computed && node.key.type === AST_NODE_TYPES.Identifier) getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Set()).add(node.key);
3460
+ if (node.computed || !Check.isIdentifier(node.key)) return;
3461
+ const methodName = node.key.name;
3462
+ const defs = getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Map());
3463
+ if (!defs.has(methodName)) defs.set(methodName, node.key);
3464
+ if (isPublicMethod(node)) getOrInsertComputed(publicMethods, currentClass, () => /* @__PURE__ */ new Set()).add(methodName);
3413
3465
  }
3414
3466
  return {
3415
3467
  "ClassDeclaration:exit": classExit,
@@ -3419,12 +3471,17 @@ function create$11(context) {
3419
3471
  const currentMethod = Traverse.findParent(node, Check.isPropertyOrMethod);
3420
3472
  if (currentClass == null || currentMethod == null) return;
3421
3473
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3422
- if (node.object.type !== AST_NODE_TYPES.ThisExpression || node.computed || node.property.type !== AST_NODE_TYPES.Identifier) return;
3474
+ if (node.object.type !== AST_NODE_TYPES.ThisExpression) return;
3423
3475
  if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
3424
- getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Set()).add(node.property);
3476
+ if (!node.computed && Check.isIdentifier(node.property)) {
3477
+ const defs = getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Map());
3478
+ if (!defs.has(node.property.name)) defs.set(node.property.name, node.property);
3479
+ }
3425
3480
  return;
3426
3481
  }
3427
- getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(node.property.name);
3482
+ const propertyName = getStaticName(node.property, node.computed);
3483
+ if (propertyName == null) return;
3484
+ getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(propertyName);
3428
3485
  },
3429
3486
  MethodDefinition: methodEnter,
3430
3487
  PropertyDefinition: methodEnter,
@@ -3433,8 +3490,11 @@ function create$11(context) {
3433
3490
  const currentMethod = Traverse.findParent(node, Check.isPropertyOrMethod);
3434
3491
  if (currentClass == null || currentMethod == null) return;
3435
3492
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3436
- if (node.init != null && node.init.type === AST_NODE_TYPES.ThisExpression && node.id.type === AST_NODE_TYPES.ObjectPattern) {
3437
- for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && !prop.computed && prop.key.type === AST_NODE_TYPES.Identifier) getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(prop.key.name);
3493
+ if (node.init != null && node.init.type === AST_NODE_TYPES.ThisExpression && node.id.type === AST_NODE_TYPES.ObjectPattern) for (const prop of node.id.properties) {
3494
+ if (prop.type !== AST_NODE_TYPES.Property) continue;
3495
+ const name = getStaticName(prop.key, prop.computed);
3496
+ if (name == null) continue;
3497
+ getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(name);
3438
3498
  }
3439
3499
  }
3440
3500
  };
@@ -8358,15 +8418,15 @@ const schema = [{
8358
8418
  properties: {
8359
8419
  enforceAssignment: {
8360
8420
  type: "boolean",
8361
- default: true
8421
+ description: "Require the useState result to be assigned to a destructured value/setter pair."
8362
8422
  },
8363
8423
  enforceLazyInitialization: {
8364
8424
  type: "boolean",
8365
- default: true
8425
+ description: "Require expensive initializers to be wrapped in a lazy initializer function."
8366
8426
  },
8367
8427
  enforceSetterName: {
8368
8428
  type: "boolean",
8369
- default: true
8429
+ description: "Require the setter name to match the state value name."
8370
8430
  }
8371
8431
  }
8372
8432
  }];
@@ -8386,7 +8446,7 @@ var use_state_default = createRule({
8386
8446
  create
8387
8447
  });
8388
8448
  function create(context) {
8389
- const { enforceAssignment = true, enforceLazyInitialization = true, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
8449
+ const { enforceAssignment, enforceLazyInitialization, enforceSetterName } = complete(context.options[0], defaultOptions[0]);
8390
8450
  const { additionalStateHooks } = getSettingsFromContext(context);
8391
8451
  return { CallExpression(node) {
8392
8452
  if (!core.isUseStateLikeCall(node, additionalStateHooks)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.30.0-beta.6",
3
+ "version": "5.30.0-beta.7",
4
4
  "description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -36,12 +36,12 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@eslint-react/ast": "5.30.0-beta.6",
40
- "@eslint-react/core": "5.30.0-beta.6",
41
- "@eslint-react/eslint": "5.30.0-beta.6",
42
- "@eslint-react/jsx": "5.30.0-beta.6",
43
- "@eslint-react/shared": "5.30.0-beta.6",
44
- "@eslint-react/var": "5.30.0-beta.6",
39
+ "@eslint-react/ast": "5.30.0-beta.7",
40
+ "@eslint-react/core": "5.30.0-beta.7",
41
+ "@eslint-react/eslint": "5.30.0-beta.7",
42
+ "@eslint-react/jsx": "5.30.0-beta.7",
43
+ "@eslint-react/shared": "5.30.0-beta.7",
44
+ "@eslint-react/var": "5.30.0-beta.7",
45
45
  "@typescript-eslint/scope-manager": "^8.72.1",
46
46
  "@typescript-eslint/types": "^8.72.1",
47
47
  "@typescript-eslint/utils": "^8.72.1",