eslint-plugin-react-x 2.6.3-beta.0 → 2.6.4-beta.0

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.
package/dist/index.d.ts CHANGED
@@ -4,18 +4,27 @@ import * as _eslint_react_shared0 from "@eslint-react/shared";
4
4
  declare const _default: {
5
5
  configs: {
6
6
  /**
7
- * Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects
7
+ * Disable experimental rules that might be subject to change in the future
8
8
  */
9
- recommended: {
9
+ "disable-experimental": {
10
10
  plugins: {};
11
11
  name?: string;
12
12
  rules?: Record<string, _eslint_react_shared0.RuleConfig>;
13
13
  settings?: _eslint_react_shared0.SettingsConfig;
14
14
  };
15
15
  /**
16
- * Same as the `recommended` preset but disables rules that can be enforced by TypeScript
16
+ * Disable rules that can be enforced by TypeScript
17
17
  */
18
- "recommended-typescript": {
18
+ "disable-type-checked": {
19
+ plugins: {};
20
+ name?: string;
21
+ rules?: Record<string, _eslint_react_shared0.RuleConfig>;
22
+ settings?: _eslint_react_shared0.SettingsConfig;
23
+ };
24
+ /**
25
+ * Enforce rules that are recommended by ESLint React for general purpose React + React DOM projects
26
+ */
27
+ recommended: {
19
28
  plugins: {};
20
29
  name?: string;
21
30
  rules?: Record<string, _eslint_react_shared0.RuleConfig>;
@@ -31,18 +40,18 @@ declare const _default: {
31
40
  settings?: _eslint_react_shared0.SettingsConfig;
32
41
  };
33
42
  /**
34
- * More strict version of the `recommended` preset
43
+ * Same as the `recommended` preset but disables rules that can be enforced by TypeScript
35
44
  */
36
- strict: {
45
+ "recommended-typescript": {
37
46
  plugins: {};
38
47
  name?: string;
39
48
  rules?: Record<string, _eslint_react_shared0.RuleConfig>;
40
49
  settings?: _eslint_react_shared0.SettingsConfig;
41
50
  };
42
51
  /**
43
- * Same as the `strict` preset but enables additional rules that require type information
52
+ * More strict version of the `recommended` preset
44
53
  */
45
- "strict-typescript": {
54
+ strict: {
46
55
  plugins: {};
47
56
  name?: string;
48
57
  rules?: Record<string, _eslint_react_shared0.RuleConfig>;
@@ -57,6 +66,15 @@ declare const _default: {
57
66
  rules?: Record<string, _eslint_react_shared0.RuleConfig>;
58
67
  settings?: _eslint_react_shared0.SettingsConfig;
59
68
  };
69
+ /**
70
+ * Same as the `strict` preset but disables rules that can be enforced by TypeScript
71
+ */
72
+ "strict-typescript": {
73
+ plugins: {};
74
+ name?: string;
75
+ rules?: Record<string, _eslint_react_shared0.RuleConfig>;
76
+ settings?: _eslint_react_shared0.SettingsConfig;
77
+ };
60
78
  };
61
79
  meta: {
62
80
  name: string;
package/dist/index.js CHANGED
@@ -19,9 +19,9 @@ import { camelCase } from "string-ts";
19
19
  var __defProp = Object.defineProperty;
20
20
  var __exportAll = (all, symbols) => {
21
21
  let target = {};
22
- for (var name$7 in all) {
23
- __defProp(target, name$7, {
24
- get: all[name$7],
22
+ for (var name$9 in all) {
23
+ __defProp(target, name$9, {
24
+ get: all[name$9],
25
25
  enumerable: true
26
26
  });
27
27
  }
@@ -31,10 +31,44 @@ var __exportAll = (all, symbols) => {
31
31
  return target;
32
32
  };
33
33
 
34
+ //#endregion
35
+ //#region src/configs/disable-experimental.ts
36
+ var disable_experimental_exports = /* @__PURE__ */ __exportAll({
37
+ name: () => name$8,
38
+ rules: () => rules$8
39
+ });
40
+ const name$8 = "react-x/disable-experimental";
41
+ const rules$8 = {
42
+ "react-x/jsx-key-before-spread": "off",
43
+ "react-x/jsx-no-iife": "off",
44
+ "react-x/no-duplicate-key": "off",
45
+ "react-x/no-implicit-key": "off",
46
+ "react-x/no-misused-capture-owner-stack": "off",
47
+ "react-x/no-unnecessary-key": "off",
48
+ "react-x/no-unnecessary-use-callback": "off",
49
+ "react-x/no-unnecessary-use-memo": "off",
50
+ "react-x/no-unnecessary-use-ref": "off",
51
+ "react-x/no-unused-props": "off",
52
+ "react-x/prefer-read-only-props": "off"
53
+ };
54
+
55
+ //#endregion
56
+ //#region src/configs/disable-type-checked.ts
57
+ var disable_type_checked_exports = /* @__PURE__ */ __exportAll({
58
+ name: () => name$7,
59
+ rules: () => rules$7
60
+ });
61
+ const name$7 = "react-x/disable-type-checked";
62
+ const rules$7 = {
63
+ "react-x/no-leaked-conditional-rendering": "off",
64
+ "react-x/no-unused-props": "off",
65
+ "react-x/prefer-read-only-props": "off"
66
+ };
67
+
34
68
  //#endregion
35
69
  //#region package.json
36
70
  var name$6 = "eslint-plugin-react-x";
37
- var version = "2.6.3-beta.0";
71
+ var version = "2.6.4-beta.0";
38
72
 
39
73
  //#endregion
40
74
  //#region src/utils/create-rule.ts
@@ -282,10 +316,10 @@ function create$60(context) {
282
316
  const props = [];
283
317
  for (const attr of node.attributes) {
284
318
  if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
285
- const name$7 = attr.name.name;
286
- if (typeof name$7 !== "string") continue;
287
- if (!props.includes(name$7)) {
288
- props.push(name$7);
319
+ const name$9 = attr.name.name;
320
+ if (typeof name$9 !== "string") continue;
321
+ if (!props.includes(name$9)) {
322
+ props.push(name$9);
289
323
  continue;
290
324
  }
291
325
  context.report({
@@ -343,17 +377,17 @@ var jsx_no_undef_default = createRule({
343
377
  });
344
378
  function create$58(context) {
345
379
  return { JSXOpeningElement(node) {
346
- const name$7 = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({
380
+ const name$9 = match(node.name).with({ type: AST_NODE_TYPES.JSXIdentifier }, (n) => n.name).with({
347
381
  type: AST_NODE_TYPES.JSXMemberExpression,
348
382
  object: { type: AST_NODE_TYPES.JSXIdentifier }
349
383
  }, (n) => n.object.name).otherwise(() => null);
350
- if (name$7 == null) return;
351
- if (name$7 === "this") return;
352
- if (/^[a-z]/u.test(name$7)) return;
353
- if (findVariable(name$7, context.sourceCode.getScope(node)) == null) context.report({
384
+ if (name$9 == null) return;
385
+ if (name$9 === "this") return;
386
+ if (/^[a-z]/u.test(name$9)) return;
387
+ if (findVariable(name$9, context.sourceCode.getScope(node)) == null) context.report({
354
388
  messageId: "jsxNoUndef",
355
389
  node,
356
- data: { name: name$7 }
390
+ data: { name: name$9 }
357
391
  });
358
392
  } };
359
393
  }
@@ -491,12 +525,12 @@ function create$55(context) {
491
525
  JSXOpeningFragment: handleJsxElement
492
526
  };
493
527
  }
494
- function debugReport(context, node, name$7) {
528
+ function debugReport(context, node, name$9) {
495
529
  if (process.env["ESLINT_REACT_DEBUG"] !== "1") return;
496
530
  context.report({
497
531
  messageId: "jsxUsesReact",
498
532
  node,
499
- data: { name: name$7 }
533
+ data: { name: name$9 }
500
534
  });
501
535
  }
502
536
 
@@ -640,8 +674,8 @@ const arrayIndexParamPosition = new Map([
640
674
  function getArrayIndexParamPosition(methodName) {
641
675
  return arrayIndexParamPosition.get(methodName) ?? -1;
642
676
  }
643
- function isReactChildrenMethod(name$7) {
644
- return REACT_CHILDREN_METHOD.includes(name$7);
677
+ function isReactChildrenMethod(name$9) {
678
+ return REACT_CHILDREN_METHOD.includes(name$9);
645
679
  }
646
680
  function isUsingReactChildren(context, node) {
647
681
  const { importSource = "react" } = coerceSettings(context.settings);
@@ -657,8 +691,8 @@ function getMapIndexParamName(context, node) {
657
691
  const { callee } = node;
658
692
  if (callee.type !== AST_NODE_TYPES.MemberExpression) return unit;
659
693
  if (callee.property.type !== AST_NODE_TYPES.Identifier) return unit;
660
- const { name: name$7 } = callee.property;
661
- const indexPosition = getArrayIndexParamPosition(name$7);
694
+ const { name: name$9 } = callee.property;
695
+ const indexPosition = getArrayIndexParamPosition(name$9);
662
696
  if (indexPosition === -1) return unit;
663
697
  const callbackArg = node.arguments[isUsingReactChildren(context, node) ? 1 : 0];
664
698
  if (callbackArg == null) return unit;
@@ -687,7 +721,7 @@ var no_array_index_key_default = createRule({
687
721
  function create$52(context) {
688
722
  const indexParamNames = [];
689
723
  function isArrayIndex(node) {
690
- return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name$7) => name$7 != null && name$7 === node.name);
724
+ return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name$9) => name$9 != null && name$9 === node.name);
691
725
  }
692
726
  function isCreateOrCloneElementCall(node) {
693
727
  return isCreateElementCall(context, node) || isCloneElementCall(context, node);
@@ -695,7 +729,7 @@ function create$52(context) {
695
729
  function getReportDescriptors(node) {
696
730
  switch (node.type) {
697
731
  case AST_NODE_TYPES.Identifier:
698
- if (indexParamNames.some((name$7) => name$7 != null && name$7 === node.name)) return [{
732
+ if (indexParamNames.some((name$9) => name$9 != null && name$9 === node.name)) return [{
699
733
  messageId: "noArrayIndexKey",
700
734
  node
701
735
  }];
@@ -907,12 +941,12 @@ function create$45(context) {
907
941
  return {
908
942
  ...listeners,
909
943
  "Program:exit"(program) {
910
- for (const { name: name$7 = "anonymous", node: component } of ctx.getAllComponents(program)) {
944
+ for (const { name: name$9 = "anonymous", node: component } of ctx.getAllComponents(program)) {
911
945
  if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) continue;
912
946
  context.report({
913
947
  messageId: "noClassComponent",
914
948
  node: component,
915
- data: { name: name$7 }
949
+ data: { name: name$9 }
916
950
  });
917
951
  }
918
952
  }
@@ -1713,15 +1747,15 @@ function create$28(context) {
1713
1747
  const isClassComponent$1 = (node) => {
1714
1748
  return AST.isClass(node) && cComponents.some((component) => component.node === node);
1715
1749
  };
1716
- for (const { name: name$7, node: component } of fComponents) {
1717
- if (name$7 == null) continue;
1750
+ for (const { name: name$9, node: component } of fComponents) {
1751
+ if (name$9 == null) continue;
1718
1752
  if (isDirectValueOfRenderPropertyLoose(component)) continue;
1719
1753
  if (isInsideJSXAttributeValue(component)) {
1720
1754
  if (!isDeclaredInRenderPropLoose(component)) context.report({
1721
1755
  messageId: "noNestedComponentDefinitions",
1722
1756
  node: component,
1723
1757
  data: {
1724
- name: name$7,
1758
+ name: name$9,
1725
1759
  suggestion: "Move it to the top level or pass it as a prop."
1726
1760
  }
1727
1761
  });
@@ -1732,7 +1766,7 @@ function create$28(context) {
1732
1766
  messageId: "noNestedComponentDefinitions",
1733
1767
  node: component,
1734
1768
  data: {
1735
- name: name$7,
1769
+ name: name$9,
1736
1770
  suggestion: "Move it to the top level or pass it as a prop."
1737
1771
  }
1738
1772
  });
@@ -1744,7 +1778,7 @@ function create$28(context) {
1744
1778
  messageId: "noNestedComponentDefinitions",
1745
1779
  node: component,
1746
1780
  data: {
1747
- name: name$7,
1781
+ name: name$9,
1748
1782
  suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
1749
1783
  }
1750
1784
  });
@@ -1754,18 +1788,18 @@ function create$28(context) {
1754
1788
  messageId: "noNestedComponentDefinitions",
1755
1789
  node: component,
1756
1790
  data: {
1757
- name: name$7,
1791
+ name: name$9,
1758
1792
  suggestion: "Move it to the top level."
1759
1793
  }
1760
1794
  });
1761
1795
  }
1762
- for (const { name: name$7 = "unknown", node: component } of cComponents) {
1796
+ for (const { name: name$9 = "unknown", node: component } of cComponents) {
1763
1797
  if (AST.findParentNode(component, (n) => isClassComponent$1(n) || isFunctionComponent(n)) == null) continue;
1764
1798
  context.report({
1765
1799
  messageId: "noNestedComponentDefinitions",
1766
1800
  node: component,
1767
1801
  data: {
1768
- name: name$7,
1802
+ name: name$9,
1769
1803
  suggestion: component.parent.type === AST_NODE_TYPES.Property ? "Move it to the top level or pass it as a prop." : "Move it to the top level."
1770
1804
  }
1771
1805
  });
@@ -1910,13 +1944,13 @@ function create$25(context) {
1910
1944
  return {
1911
1945
  ...listeners,
1912
1946
  "Program:exit"(program) {
1913
- for (const { name: name$7 = "PureComponent", node: component, flag } of ctx.getAllComponents(program)) {
1947
+ for (const { name: name$9 = "PureComponent", node: component, flag } of ctx.getAllComponents(program)) {
1914
1948
  if ((flag & ComponentFlag.PureComponent) === 0n) continue;
1915
1949
  const { body } = component.body;
1916
1950
  for (const member of body) if (isShouldComponentUpdate(member)) context.report({
1917
1951
  messageId: "noRedundantShouldComponentUpdate",
1918
1952
  node: member,
1919
- data: { componentName: name$7 }
1953
+ data: { componentName: name$9 }
1920
1954
  });
1921
1955
  }
1922
1956
  }
@@ -2299,16 +2333,16 @@ function create$17(context) {
2299
2333
  return {
2300
2334
  ...listeners,
2301
2335
  "Program:exit"(program) {
2302
- for (const { id, name: name$7, node, hookCalls } of ctx.getAllHooks(program)) {
2336
+ for (const { id, name: name$9, node, hookCalls } of ctx.getAllHooks(program)) {
2303
2337
  if (hookCalls.length > 0) continue;
2304
2338
  if (AST.isFunctionEmpty(node)) continue;
2305
- if (WELL_KNOWN_HOOKS.includes(name$7)) continue;
2339
+ if (WELL_KNOWN_HOOKS.includes(name$9)) continue;
2306
2340
  if (containsUseComments(context, node)) continue;
2307
2341
  if (AST.findParentNode(node, AST.isViMockCallback) != null) continue;
2308
2342
  context.report({
2309
2343
  messageId: "noUnnecessaryUsePrefix",
2310
2344
  node: id ?? node,
2311
- data: { name: name$7 }
2345
+ data: { name: name$9 }
2312
2346
  });
2313
2347
  }
2314
2348
  }
@@ -2498,9 +2532,9 @@ function create$12(context) {
2498
2532
  }
2499
2533
  };
2500
2534
  }
2501
- function isContextName(name$7, isReact18OrBelow) {
2502
- if (name$7 === "Provider") return true;
2503
- if (!isReact18OrBelow) return name$7.endsWith("Context") || name$7.endsWith("CONTEXT");
2535
+ function isContextName(name$9, isReact18OrBelow) {
2536
+ if (name$9 === "Provider") return true;
2537
+ if (!isReact18OrBelow) return name$9.endsWith("Context") || name$9.endsWith("CONTEXT");
2504
2538
  return false;
2505
2539
  }
2506
2540
 
@@ -2552,8 +2586,8 @@ function create$11(context, [options]) {
2552
2586
  const { params } = component;
2553
2587
  const [props] = params;
2554
2588
  if (props == null) continue;
2555
- const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties$1 }) => properties$1).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name$7 }) => {
2556
- return declarators.get(component)?.filter((d) => d.init.name === name$7).flatMap((d) => d.id.properties) ?? [];
2589
+ const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties$1 }) => properties$1).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name$9 }) => {
2590
+ return declarators.get(component)?.filter((d) => d.init.name === name$9).flatMap((d) => d.id.properties) ?? [];
2557
2591
  }).otherwise(() => []);
2558
2592
  for (const prop of properties) {
2559
2593
  if (prop.type !== AST_NODE_TYPES.Property || prop.value.type !== AST_NODE_TYPES.AssignmentPattern) continue;
@@ -3443,17 +3477,17 @@ function create(context, [option]) {
3443
3477
  else if (node.name.type === AST_NODE_TYPES.JSXNamespacedName) nodeName = node.name.name.name;
3444
3478
  for (const attr of node.attributes) {
3445
3479
  if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
3446
- const name$7 = attr.name.name;
3447
- if (typeof name$7 !== "string") continue;
3480
+ const name$9 = attr.name.name;
3481
+ if (typeof name$9 !== "string") continue;
3448
3482
  for (const forbiddenPropItem of forbid) {
3449
3483
  if (typeof forbiddenPropItem !== "string" && nodeName != null) {
3450
3484
  if ("excludedNodes" in forbiddenPropItem && forbiddenPropItem.excludedNodes.includes(nodeName)) continue;
3451
3485
  if ("includedNodes" in forbiddenPropItem && !forbiddenPropItem.includedNodes.includes(nodeName)) continue;
3452
3486
  }
3453
- if (toRegExp(typeof forbiddenPropItem === "string" ? forbiddenPropItem : forbiddenPropItem.prop).test(name$7)) context.report({
3487
+ if (toRegExp(typeof forbiddenPropItem === "string" ? forbiddenPropItem : forbiddenPropItem.prop).test(name$9)) context.report({
3454
3488
  messageId,
3455
3489
  node: attr,
3456
- data: { name: name$7 }
3490
+ data: { name: name$9 }
3457
3491
  });
3458
3492
  }
3459
3493
  }
@@ -3698,12 +3732,14 @@ const { toFlatConfig } = getConfigAdapters("react-x", plugin);
3698
3732
  var src_default = {
3699
3733
  ...plugin,
3700
3734
  configs: {
3735
+ ["disable-experimental"]: toFlatConfig(disable_experimental_exports),
3736
+ ["disable-type-checked"]: toFlatConfig(disable_type_checked_exports),
3701
3737
  ["recommended"]: toFlatConfig(recommended_exports),
3702
- ["recommended-typescript"]: toFlatConfig(recommended_typescript_exports),
3703
3738
  ["recommended-type-checked"]: toFlatConfig(recommended_type_checked_exports),
3739
+ ["recommended-typescript"]: toFlatConfig(recommended_typescript_exports),
3704
3740
  ["strict"]: toFlatConfig(strict_exports),
3705
- ["strict-typescript"]: toFlatConfig(strict_typescript_exports),
3706
- ["strict-type-checked"]: toFlatConfig(strict_type_checked_exports)
3741
+ ["strict-type-checked"]: toFlatConfig(strict_type_checked_exports),
3742
+ ["strict-typescript"]: toFlatConfig(strict_typescript_exports)
3707
3743
  }
3708
3744
  };
3709
3745
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.6.3-beta.0",
3
+ "version": "2.6.4-beta.0",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -46,11 +46,11 @@
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-api-utils": "^2.4.0",
48
48
  "ts-pattern": "^5.9.0",
49
- "@eslint-react/ast": "2.6.3-beta.0",
50
- "@eslint-react/core": "2.6.3-beta.0",
51
- "@eslint-react/eff": "2.6.3-beta.0",
52
- "@eslint-react/var": "2.6.3-beta.0",
53
- "@eslint-react/shared": "2.6.3-beta.0"
49
+ "@eslint-react/ast": "2.6.4-beta.0",
50
+ "@eslint-react/core": "2.6.4-beta.0",
51
+ "@eslint-react/shared": "2.6.4-beta.0",
52
+ "@eslint-react/var": "2.6.4-beta.0",
53
+ "@eslint-react/eff": "2.6.4-beta.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.8",