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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +122 -74
  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.8";
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,17 +2281,6 @@ 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
- } };
2274
- }
2275
2284
  var no_duplicate_key_default = createRule({
2276
2285
  meta: {
2277
2286
  type: "problem",
@@ -2283,13 +2292,20 @@ var no_duplicate_key_default = createRule({
2283
2292
  create: create$32
2284
2293
  });
2285
2294
  function create$32(context) {
2286
- if (!context.sourceCode.text.includes("key=")) return {};
2287
- const keyedEntries = /* @__PURE__ */ new Map();
2288
- function isKeyValueEqual(a, b) {
2289
- const aValue = a.value;
2290
- const bValue = b.value;
2291
- if (aValue == null || bValue == null) return false;
2292
- return Compare.isEqual(aValue, bValue);
2295
+ if (!/\bkey\b/u.test(context.sourceCode.text)) return {};
2296
+ const keyGroups = /* @__PURE__ */ new Map();
2297
+ function recordSiblingKey(root, key) {
2298
+ const prevKeys = keyGroups.get(root)?.keys ?? [];
2299
+ keyGroups.set(root, {
2300
+ hasDuplicate: prevKeys.some((prevKey) => isKeyValueEqual(prevKey, key)),
2301
+ keys: [...prevKeys, key]
2302
+ });
2303
+ }
2304
+ function recordMapCallbackKey(call, key) {
2305
+ keyGroups.set(call, {
2306
+ hasDuplicate: key.value?.type === AST_NODE_TYPES.Literal,
2307
+ keys: [key]
2308
+ });
2293
2309
  }
2294
2310
  return {
2295
2311
  "JSXAttribute[name.name='key']"(node) {
@@ -2297,16 +2313,9 @@ function create$32(context) {
2297
2313
  switch (jsxElement.parent.type) {
2298
2314
  case AST_NODE_TYPES.ArrayExpression:
2299
2315
  case AST_NODE_TYPES.JSXElement:
2300
- case AST_NODE_TYPES.JSXFragment: {
2301
- 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
- });
2308
- break;
2309
- }
2316
+ case AST_NODE_TYPES.JSXFragment:
2317
+ recordSiblingKey(jsxElement.parent, node);
2318
+ return;
2310
2319
  default: {
2311
2320
  const call = Traverse.findParent(jsxElement, (n) => {
2312
2321
  if (n.type !== AST_NODE_TYPES.CallExpression) return false;
@@ -2315,21 +2324,15 @@ function create$32(context) {
2315
2324
  return Check.isIdentifier(callee.property, "map");
2316
2325
  });
2317
2326
  if (call == null) return;
2318
- const iter = Traverse.findParent(jsxElement, Check.isFunction, (n) => n === call);
2319
- 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
- });
2327
+ const callback = call.arguments[0];
2328
+ if (callback == null) return;
2329
+ if (Traverse.findParent(jsxElement, Check.isFunction, (n) => n === call) !== Extract.unwrap(callback)) return;
2330
+ recordMapCallbackKey(call, node);
2328
2331
  }
2329
2332
  }
2330
2333
  },
2331
2334
  "Program:exit"() {
2332
- for (const { hasDuplicate, keys } of keyedEntries.values()) {
2335
+ for (const { hasDuplicate, keys } of keyGroups.values()) {
2333
2336
  if (!hasDuplicate) continue;
2334
2337
  for (const key of keys) context.report({
2335
2338
  messageId: "default",
@@ -2339,6 +2342,12 @@ function create$32(context) {
2339
2342
  }
2340
2343
  };
2341
2344
  }
2345
+ function isKeyValueEqual(a, b) {
2346
+ const aValue = a.value;
2347
+ const bValue = b.value;
2348
+ if (aValue == null || bValue == null) return false;
2349
+ return Compare.isEqual(aValue, bValue);
2350
+ }
2342
2351
  var no_forward_ref_default = createRule({
2343
2352
  meta: {
2344
2353
  type: "suggestion",
@@ -2466,6 +2475,7 @@ var no_implicit_children_default = createRule({
2466
2475
  create: create$30
2467
2476
  });
2468
2477
  function create$30(context) {
2478
+ if (!context.sourceCode.text.includes("...")) return {};
2469
2479
  return createImplicitPropListener(context, {
2470
2480
  name: "children",
2471
2481
  isAllowedProp: (fqn) => fqn.endsWith("attributes.children") || fqn.endsWith("propswithchildren.children"),
@@ -2489,6 +2499,7 @@ var no_implicit_key_default = createRule({
2489
2499
  create: create$29
2490
2500
  });
2491
2501
  function create$29(context) {
2502
+ if (!context.sourceCode.text.includes("...")) return {};
2492
2503
  return createImplicitPropListener(context, {
2493
2504
  name: "key",
2494
2505
  isAllowedProp: (fqn) => fqn.endsWith("react.attributes.key"),
@@ -2515,6 +2526,7 @@ var no_implicit_ref_default = createRule({
2515
2526
  create: create$28
2516
2527
  });
2517
2528
  function create$28(context) {
2529
+ if (!context.sourceCode.text.includes("...")) return {};
2518
2530
  return createImplicitPropListener(context, {
2519
2531
  name: "ref",
2520
2532
  isAllowedProp: (fqn) => fqn.endsWith("attributes.ref"),
@@ -2659,7 +2671,20 @@ function create$25(context) {
2659
2671
  })) context.report({
2660
2672
  fix(fixer) {
2661
2673
  if (id.type !== AST_NODE_TYPES.Identifier || id.parent !== call.parent) return [];
2662
- return fixer.insertTextAfter(context.sourceCode.getTokenAfter(call) ?? call, [
2674
+ const declaration = id.parent.parent;
2675
+ if (declaration == null || declaration.type !== AST_NODE_TYPES.VariableDeclaration) return [];
2676
+ switch (declaration.parent.type) {
2677
+ case AST_NODE_TYPES.BlockStatement:
2678
+ case AST_NODE_TYPES.ExportNamedDeclaration:
2679
+ case AST_NODE_TYPES.Program:
2680
+ case AST_NODE_TYPES.StaticBlock:
2681
+ case AST_NODE_TYPES.SwitchCase:
2682
+ case AST_NODE_TYPES.TSModuleBlock: break;
2683
+ default: return [];
2684
+ }
2685
+ const lastToken = context.sourceCode.getLastToken(declaration);
2686
+ if (lastToken == null) return [];
2687
+ return fixer.insertTextAfter(lastToken, [
2663
2688
  "\n",
2664
2689
  id.name,
2665
2690
  ".",
@@ -2678,12 +2703,24 @@ function create$25(context) {
2678
2703
  }
2679
2704
  };
2680
2705
  }
2681
- // src/rules/no-missing-key/lib.ts
2706
+ // src/utils/jsx-iterator.ts
2682
2707
  const KNOWN_CALLBACK_POSITIONS = /* @__PURE__ */ new Map([
2683
2708
  ["flatMap", 0],
2684
2709
  ["from", 1],
2685
2710
  ["map", 0]
2686
2711
  ]);
2712
+ function getIteratorCallback(node) {
2713
+ const callee = Extract.unwrap(node.callee);
2714
+ if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
2715
+ if (!Check.isIdentifier(callee.property)) return null;
2716
+ const position = KNOWN_CALLBACK_POSITIONS.get(callee.property.name);
2717
+ if (position == null) return null;
2718
+ const argument = node.arguments[position];
2719
+ if (argument == null) return null;
2720
+ const callback = Extract.unwrap(argument);
2721
+ if (!Check.isFunction(callback)) return null;
2722
+ return callback;
2723
+ }
2687
2724
  var no_missing_key_default = createRule({
2688
2725
  meta: {
2689
2726
  type: "problem",
@@ -2697,16 +2734,6 @@ var no_missing_key_default = createRule({
2697
2734
  name: "no-missing-key",
2698
2735
  create: create$24
2699
2736
  });
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
2737
  function create$24(context) {
2711
2738
  let childrenToArrayDepth = 0;
2712
2739
  function visitItemExpression(node) {
@@ -2965,6 +2992,7 @@ var no_nested_lazy_component_declarations_default = createRule({
2965
2992
  create: create$21
2966
2993
  });
2967
2994
  function create$21(context) {
2995
+ if (!context.sourceCode.text.includes("lazy")) return {};
2968
2996
  const fc = core.getFunctionComponentCollector(context);
2969
2997
  const cc = core.getClassComponentCollector(context);
2970
2998
  const hc = core.getHookCollector(context);
@@ -3265,6 +3293,7 @@ const schema$1 = [{
3265
3293
  additionalProperties: false,
3266
3294
  properties: { safeDefaultProps: {
3267
3295
  type: "array",
3296
+ description: "Property names or patterns that are safe to use as default props.",
3268
3297
  items: { type: "string" }
3269
3298
  } }
3270
3299
  }];
@@ -3279,13 +3308,13 @@ var no_unstable_default_props_default = createRule({
3279
3308
  name: RULE_NAME$12,
3280
3309
  create: create$12
3281
3310
  });
3282
- function create$12(context, [options]) {
3311
+ function create$12(context) {
3312
+ const { safeDefaultProps } = complete(context.options[0], defaultOptions$1[0]);
3283
3313
  const { compilationMode } = getSettingsFromContext(context);
3284
3314
  if (compilationMode === "infer" || compilationMode === "all") return {};
3285
3315
  if (compilationMode === "annotation" && context.sourceCode.ast.body.some((stmt) => Check.isDirective(stmt, "use memo"))) return {};
3286
3316
  const { api, visitor } = core.getFunctionComponentCollector(context);
3287
3317
  const declarators = /* @__PURE__ */ new WeakMap();
3288
- const { safeDefaultProps = [] } = options;
3289
3318
  const safePatterns = safeDefaultProps.map((s) => toRegExp(s));
3290
3319
  return merge(visitor, {
3291
3320
  [SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR](node) {
@@ -3359,8 +3388,7 @@ function isExportedClass(node) {
3359
3388
  default: return false;
3360
3389
  }
3361
3390
  }
3362
- function isPublicMethod(def) {
3363
- const member = def.parent;
3391
+ function isPublicMethod(member) {
3364
3392
  switch (member.type) {
3365
3393
  case AST_NODE_TYPES.MethodDefinition: return member.accessibility == null || member.accessibility === "public";
3366
3394
  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 +3406,17 @@ var no_unused_class_component_members_default = createRule({
3378
3406
  create: create$11
3379
3407
  });
3380
3408
  function create$11(context) {
3409
+ if (!context.sourceCode.text.includes("Component")) return {};
3381
3410
  const propertyDefs = /* @__PURE__ */ new WeakMap();
3411
+ const publicMethods = /* @__PURE__ */ new WeakMap();
3382
3412
  const propertyUsages = /* @__PURE__ */ new WeakMap();
3413
+ function getStaticName(key, computed) {
3414
+ const unwrapped = Extract.unwrap(key);
3415
+ if (!computed && Check.isIdentifier(unwrapped)) return unwrapped.name;
3416
+ if (unwrapped.type === AST_NODE_TYPES.Literal && typeof unwrapped.value === "string") return unwrapped.value;
3417
+ if (unwrapped.type === AST_NODE_TYPES.TemplateLiteral && unwrapped.expressions.length === 0) return unwrapped.quasis[0]?.value.cooked ?? unwrapped.quasis[0]?.value.raw ?? null;
3418
+ return null;
3419
+ }
3383
3420
  function classExit(node) {
3384
3421
  if (!core.isClassComponent(node)) return;
3385
3422
  const id = core.getClassId(node);
@@ -3387,21 +3424,20 @@ function create$11(context) {
3387
3424
  if (defs == null) return;
3388
3425
  const usages = propertyUsages.get(node);
3389
3426
  const exported = isExportedClass(node);
3390
- for (const def of defs) {
3391
- const methodName = def.name;
3427
+ const publicMembers = publicMethods.get(node);
3428
+ for (const [methodName, defNode] of defs) {
3392
3429
  if (usages?.has(methodName) ?? false) continue;
3393
- if (LIFECYCLE_METHODS.has(methodName)) {
3394
- if (methodName === "shouldComponentUpdate" && core.isPureComponent(node)) {} else continue;
3395
- }
3430
+ const isPureComponentShouldUpdate = methodName === "shouldComponentUpdate" && core.isPureComponent(node);
3431
+ if (LIFECYCLE_METHODS.has(methodName) && !isPureComponentShouldUpdate) continue;
3396
3432
  if (KNOWN_HOST_CONVENTION_METHODS.has(methodName)) continue;
3397
- if (exported && isPublicMethod(def)) continue;
3433
+ if (exported && (publicMembers?.has(methodName) ?? false)) continue;
3398
3434
  context.report({
3399
3435
  data: {
3400
3436
  className: id != null ? getText(context, id) : "Component",
3401
3437
  methodName
3402
3438
  },
3403
3439
  messageId: "default",
3404
- node: def
3440
+ node: defNode
3405
3441
  });
3406
3442
  }
3407
3443
  }
@@ -3409,7 +3445,11 @@ function create$11(context) {
3409
3445
  const currentClass = Traverse.findParent(node, Check.isClass);
3410
3446
  if (currentClass == null || !core.isClassComponent(currentClass)) return;
3411
3447
  if (node.static) return;
3412
- if (!node.computed && node.key.type === AST_NODE_TYPES.Identifier) getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Set()).add(node.key);
3448
+ if (node.computed || !Check.isIdentifier(node.key)) return;
3449
+ const methodName = node.key.name;
3450
+ const defs = getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Map());
3451
+ if (!defs.has(methodName)) defs.set(methodName, node.key);
3452
+ if (isPublicMethod(node)) getOrInsertComputed(publicMethods, currentClass, () => /* @__PURE__ */ new Set()).add(methodName);
3413
3453
  }
3414
3454
  return {
3415
3455
  "ClassDeclaration:exit": classExit,
@@ -3419,12 +3459,17 @@ function create$11(context) {
3419
3459
  const currentMethod = Traverse.findParent(node, Check.isPropertyOrMethod);
3420
3460
  if (currentClass == null || currentMethod == null) return;
3421
3461
  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;
3462
+ if (node.object.type !== AST_NODE_TYPES.ThisExpression) return;
3423
3463
  if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
3424
- getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Set()).add(node.property);
3464
+ if (!node.computed && Check.isIdentifier(node.property)) {
3465
+ const defs = getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Map());
3466
+ if (!defs.has(node.property.name)) defs.set(node.property.name, node.property);
3467
+ }
3425
3468
  return;
3426
3469
  }
3427
- getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(node.property.name);
3470
+ const propertyName = getStaticName(node.property, node.computed);
3471
+ if (propertyName == null) return;
3472
+ getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(propertyName);
3428
3473
  },
3429
3474
  MethodDefinition: methodEnter,
3430
3475
  PropertyDefinition: methodEnter,
@@ -3433,8 +3478,11 @@ function create$11(context) {
3433
3478
  const currentMethod = Traverse.findParent(node, Check.isPropertyOrMethod);
3434
3479
  if (currentClass == null || currentMethod == null) return;
3435
3480
  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);
3481
+ 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) {
3482
+ if (prop.type !== AST_NODE_TYPES.Property) continue;
3483
+ const name = getStaticName(prop.key, prop.computed);
3484
+ if (name == null) continue;
3485
+ getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(name);
3438
3486
  }
3439
3487
  }
3440
3488
  };
@@ -8358,15 +8406,15 @@ const schema = [{
8358
8406
  properties: {
8359
8407
  enforceAssignment: {
8360
8408
  type: "boolean",
8361
- default: true
8409
+ description: "Require the useState result to be assigned to a destructured value/setter pair."
8362
8410
  },
8363
8411
  enforceLazyInitialization: {
8364
8412
  type: "boolean",
8365
- default: true
8413
+ description: "Require expensive initializers to be wrapped in a lazy initializer function."
8366
8414
  },
8367
8415
  enforceSetterName: {
8368
8416
  type: "boolean",
8369
- default: true
8417
+ description: "Require the setter name to match the state value name."
8370
8418
  }
8371
8419
  }
8372
8420
  }];
@@ -8386,7 +8434,7 @@ var use_state_default = createRule({
8386
8434
  create
8387
8435
  });
8388
8436
  function create(context) {
8389
- const { enforceAssignment = true, enforceLazyInitialization = true, enforceSetterName = true } = context.options[0] ?? defaultOptions[0];
8437
+ const { enforceAssignment, enforceLazyInitialization, enforceSetterName } = complete(context.options[0], defaultOptions[0]);
8390
8438
  const { additionalStateHooks } = getSettingsFromContext(context);
8391
8439
  return { CallExpression(node) {
8392
8440
  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.8",
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.8",
40
+ "@eslint-react/core": "5.30.0-beta.8",
41
+ "@eslint-react/eslint": "5.30.0-beta.8",
42
+ "@eslint-react/jsx": "5.30.0-beta.8",
43
+ "@eslint-react/shared": "5.30.0-beta.8",
44
+ "@eslint-react/var": "5.30.0-beta.8",
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",