eslint-plugin-react-x 1.26.3-beta.13 → 1.26.3-beta.16

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
+ import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
1
2
  import * as JSX7 from '@eslint-react/jsx';
2
- import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings } from '@eslint-react/shared';
3
3
  import * as AST11 from '@eslint-react/ast';
4
4
  import { isForwardRefCall, isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, isReactHookCall, isReactHookCallWithNameAlias, isCreateElementCall, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
5
5
  import { _, getOrUpdate, identity } from '@eslint-react/eff';
@@ -13,9 +13,104 @@ import { unionTypeParts, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType }
13
13
  import ts from 'typescript';
14
14
  import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
15
15
 
16
+ var __defProp = Object.defineProperty;
17
+ var __export = (target, all) => {
18
+ for (var name5 in all)
19
+ __defProp(target, name5, { get: all[name5], enumerable: true });
20
+ };
21
+
22
+ // src/configs/recommended.ts
23
+ var recommended_exports = {};
24
+ __export(recommended_exports, {
25
+ name: () => name,
26
+ rules: () => rules,
27
+ settings: () => settings
28
+ });
29
+ var name = "react-x/recommended";
30
+ var rules = {
31
+ "react-x/ensure-forward-ref-using-ref": "warn",
32
+ "react-x/no-access-state-in-setstate": "error",
33
+ "react-x/no-array-index-key": "warn",
34
+ "react-x/no-children-count": "warn",
35
+ "react-x/no-children-for-each": "warn",
36
+ "react-x/no-children-map": "warn",
37
+ "react-x/no-children-only": "warn",
38
+ "react-x/no-children-to-array": "warn",
39
+ "react-x/no-clone-element": "warn",
40
+ "react-x/no-comment-textnodes": "warn",
41
+ "react-x/no-component-will-mount": "error",
42
+ "react-x/no-component-will-receive-props": "error",
43
+ "react-x/no-component-will-update": "error",
44
+ "react-x/no-context-provider": "warn",
45
+ "react-x/no-create-ref": "error",
46
+ "react-x/no-default-props": "error",
47
+ "react-x/no-direct-mutation-state": "error",
48
+ "react-x/no-duplicate-jsx-props": "warn",
49
+ "react-x/no-duplicate-key": "warn",
50
+ "react-x/no-forward-ref": "warn",
51
+ "react-x/no-implicit-key": "warn",
52
+ "react-x/no-missing-key": "error",
53
+ "react-x/no-nested-components": "error",
54
+ "react-x/no-prop-types": "error",
55
+ "react-x/no-redundant-should-component-update": "error",
56
+ "react-x/no-set-state-in-component-did-mount": "warn",
57
+ "react-x/no-set-state-in-component-did-update": "warn",
58
+ "react-x/no-set-state-in-component-will-update": "warn",
59
+ "react-x/no-string-refs": "error",
60
+ "react-x/no-unsafe-component-will-mount": "warn",
61
+ "react-x/no-unsafe-component-will-receive-props": "warn",
62
+ "react-x/no-unsafe-component-will-update": "warn",
63
+ "react-x/no-unstable-context-value": "warn",
64
+ "react-x/no-unstable-default-props": "warn",
65
+ "react-x/no-unused-class-component-members": "warn",
66
+ "react-x/no-unused-state": "warn",
67
+ "react-x/no-use-context": "warn",
68
+ "react-x/use-jsx-vars": "warn"
69
+ };
70
+ var settings = {
71
+ "react-x": DEFAULT_ESLINT_REACT_SETTINGS
72
+ };
73
+
74
+ // src/configs/recommended-type-checked.ts
75
+ var recommended_type_checked_exports = {};
76
+ __export(recommended_type_checked_exports, {
77
+ name: () => name3,
78
+ rules: () => rules3,
79
+ settings: () => settings3
80
+ });
81
+
82
+ // src/configs/recommended-typescript.ts
83
+ var recommended_typescript_exports = {};
84
+ __export(recommended_typescript_exports, {
85
+ name: () => name2,
86
+ rules: () => rules2,
87
+ settings: () => settings2
88
+ });
89
+ var name2 = "react-x/recommended-typescript";
90
+ var rules2 = {
91
+ ...rules,
92
+ "react-x/dom/no-unknown-property": "off",
93
+ "react-x/no-duplicate-jsx-props": "off",
94
+ "react-x/use-jsx-vars": "off"
95
+ };
96
+ var settings2 = {
97
+ ...settings
98
+ };
99
+
100
+ // src/configs/recommended-type-checked.ts
101
+ var name3 = "react-x/recommended-type-checked";
102
+ var rules3 = {
103
+ ...rules2,
104
+ "react-x/no-leaked-conditional-rendering": "warn"
105
+ // "react-x/prefer-read-only-props": "warn",
106
+ };
107
+ var settings3 = {
108
+ ...settings2
109
+ };
110
+
16
111
  // package.json
17
- var name = "eslint-plugin-react-x";
18
- var version = "1.26.3-beta.13";
112
+ var name4 = "eslint-plugin-react-x";
113
+ var version = "1.26.3-beta.16";
19
114
  var createRule = createRuleForPlugin("x");
20
115
 
21
116
  // src/utils/get-associated-tokens.ts
@@ -286,8 +381,8 @@ var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
286
381
  ["reduceRight", 2],
287
382
  ["some", 1]
288
383
  ]);
289
- function isReactChildrenMethod(name2) {
290
- return reactChildrenMethod.some((method) => method === name2);
384
+ function isReactChildrenMethod(name5) {
385
+ return reactChildrenMethod.some((method) => method === name5);
291
386
  }
292
387
  function isUsingReactChildren(node, context) {
293
388
  const { importSource = "react" } = unsafeDecodeSettings(context.settings);
@@ -315,8 +410,8 @@ function getMapIndexParamName(node, context) {
315
410
  if (callee.property.type !== AST_NODE_TYPES.Identifier) {
316
411
  return _;
317
412
  }
318
- const { name: name2 } = callee.property;
319
- if (!iteratorFunctionIndexParamPosition.has(name2)) {
413
+ const { name: name5 } = callee.property;
414
+ if (!iteratorFunctionIndexParamPosition.has(name5)) {
320
415
  return _;
321
416
  }
322
417
  const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
@@ -327,7 +422,7 @@ function getMapIndexParamName(node, context) {
327
422
  return _;
328
423
  }
329
424
  const { params } = callbackArg;
330
- const indexParamPosition = iteratorFunctionIndexParamPosition.get(name2);
425
+ const indexParamPosition = iteratorFunctionIndexParamPosition.get(name5);
331
426
  if (indexParamPosition == null) {
332
427
  return _;
333
428
  }
@@ -353,7 +448,7 @@ var no_array_index_key_default = createRule({
353
448
  create(context) {
354
449
  const indexParamNames = [];
355
450
  function isArrayIndex(node) {
356
- return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name2) => name2 != null && name2 === node.name);
451
+ return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name5) => name5 != null && name5 === node.name);
357
452
  }
358
453
  function isCreateOrCloneElementCall(node) {
359
454
  return isCreateElementCall(node, context) || isCloneElementCall(node, context);
@@ -362,7 +457,7 @@ var no_array_index_key_default = createRule({
362
457
  switch (node.type) {
363
458
  // key={bar}
364
459
  case AST_NODE_TYPES.Identifier: {
365
- if (indexParamNames.some((name2) => name2 != null && name2 === node.name)) {
460
+ if (indexParamNames.some((name5) => name5 != null && name5 === node.name)) {
366
461
  return [{
367
462
  messageId: "noArrayIndexKey",
368
463
  node
@@ -672,7 +767,7 @@ var no_class_component_default = createRule({
672
767
  ...listeners,
673
768
  "Program:exit"(node) {
674
769
  const components = ctx.getAllComponents(node);
675
- for (const { name: name2 = "anonymous", node: component } of components.values()) {
770
+ for (const { name: name5 = "anonymous", node: component } of components.values()) {
676
771
  if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
677
772
  continue;
678
773
  }
@@ -680,7 +775,7 @@ var no_class_component_default = createRule({
680
775
  messageId: "noClassComponent",
681
776
  node: component,
682
777
  data: {
683
- name: name2
778
+ name: name5
684
779
  }
685
780
  });
686
781
  }
@@ -998,8 +1093,8 @@ var no_context_provider_default = createRule({
998
1093
  }
999
1094
  return {
1000
1095
  JSXElement(node) {
1001
- const [name2, ...rest] = JSX7.getElementName(node).split(".").reverse();
1002
- if (name2 !== "Provider") return;
1096
+ const [name5, ...rest] = JSX7.getElementName(node).split(".").reverse();
1097
+ if (name5 !== "Provider") return;
1003
1098
  const contextName = rest.reverse().join(".");
1004
1099
  context.report({
1005
1100
  messageId: "noContextProvider",
@@ -1196,12 +1291,12 @@ var no_duplicate_jsx_props_default = createRule({
1196
1291
  if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) {
1197
1292
  continue;
1198
1293
  }
1199
- const name2 = attr.name.name;
1200
- if (typeof name2 !== "string") {
1294
+ const name5 = attr.name.name;
1295
+ if (typeof name5 !== "string") {
1201
1296
  continue;
1202
1297
  }
1203
- if (!props.includes(name2)) {
1204
- props.push(name2);
1298
+ if (!props.includes(name5)) {
1299
+ props.push(name5);
1205
1300
  continue;
1206
1301
  }
1207
1302
  context.report({
@@ -1833,11 +1928,11 @@ var no_nested_components_default = createRule({
1833
1928
  const isClassComponent11 = (node2) => {
1834
1929
  return AST11.isClass(node2) && classComponents.some((component) => component.node === node2);
1835
1930
  };
1836
- for (const { name: name2, node: component } of functionComponents) {
1931
+ for (const { name: name5, node: component } of functionComponents) {
1837
1932
  if (isDirectValueOfRenderPropertyLoose(component)) {
1838
1933
  continue;
1839
1934
  }
1840
- if (name2 === _) {
1935
+ if (name5 === _) {
1841
1936
  continue;
1842
1937
  }
1843
1938
  const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
@@ -1848,7 +1943,7 @@ var no_nested_components_default = createRule({
1848
1943
  messageId: "nestedComponentInProps",
1849
1944
  node: component,
1850
1945
  data: {
1851
- name: name2
1946
+ name: name5
1852
1947
  }
1853
1948
  });
1854
1949
  }
@@ -1859,7 +1954,7 @@ var no_nested_components_default = createRule({
1859
1954
  messageId: "nestedComponentInProps",
1860
1955
  node: component,
1861
1956
  data: {
1862
- name: name2
1957
+ name: name5
1863
1958
  }
1864
1959
  });
1865
1960
  continue;
@@ -1871,7 +1966,7 @@ var no_nested_components_default = createRule({
1871
1966
  messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
1872
1967
  node: component,
1873
1968
  data: {
1874
- name: name2
1969
+ name: name5
1875
1970
  }
1876
1971
  });
1877
1972
  continue;
@@ -1881,12 +1976,12 @@ var no_nested_components_default = createRule({
1881
1976
  messageId: "nestedComponent",
1882
1977
  node: component,
1883
1978
  data: {
1884
- name: name2
1979
+ name: name5
1885
1980
  }
1886
1981
  });
1887
1982
  }
1888
1983
  }
1889
- for (const { name: name2 = "unknown", node: component } of classComponents) {
1984
+ for (const { name: name5 = "unknown", node: component } of classComponents) {
1890
1985
  if (AST11.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
1891
1986
  continue;
1892
1987
  }
@@ -1894,7 +1989,7 @@ var no_nested_components_default = createRule({
1894
1989
  messageId: "nestedComponent",
1895
1990
  node: component,
1896
1991
  data: {
1897
- name: name2
1992
+ name: name5
1898
1993
  }
1899
1994
  });
1900
1995
  }
@@ -1987,7 +2082,7 @@ var no_redundant_should_component_update_default = createRule({
1987
2082
  ...listeners,
1988
2083
  "Program:exit"(node) {
1989
2084
  const components = ctx.getAllComponents(node);
1990
- for (const { name: name2 = "PureComponent", node: component, flag } of components.values()) {
2085
+ for (const { name: name5 = "PureComponent", node: component, flag } of components.values()) {
1991
2086
  if ((flag & ERComponentFlag.PureComponent) === 0n) {
1992
2087
  continue;
1993
2088
  }
@@ -1998,7 +2093,7 @@ var no_redundant_should_component_update_default = createRule({
1998
2093
  messageId: "noRedundantShouldComponentUpdate",
1999
2094
  node: member,
2000
2095
  data: {
2001
- componentName: name2
2096
+ componentName: name5
2002
2097
  }
2003
2098
  });
2004
2099
  }
@@ -2423,8 +2518,8 @@ var no_unstable_default_props_default = createRule({
2423
2518
  if (props == null) {
2424
2519
  continue;
2425
2520
  }
2426
- const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name2 }) => {
2427
- return declarators.get(component)?.filter((d) => d.init.name === name2).flatMap((d) => d.id.properties) ?? [];
2521
+ const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name5 }) => {
2522
+ return declarators.get(component)?.filter((d) => d.init.name === name5).flatMap((d) => d.id.properties) ?? [];
2428
2523
  }).otherwise(() => []);
2429
2524
  for (const prop of properties) {
2430
2525
  if (prop.type !== AST_NODE_TYPES.Property || prop.value.type !== AST_NODE_TYPES.AssignmentPattern) {
@@ -2822,9 +2917,9 @@ var no_use_context_default = createRule({
2822
2917
  name: RULE_NAME44,
2823
2918
  create(context) {
2824
2919
  if (!context.sourceCode.text.includes("useContext")) return {};
2825
- const settings = getSettingsFromContext(context);
2920
+ const settings4 = getSettingsFromContext(context);
2826
2921
  const useContextAlias = /* @__PURE__ */ new Set();
2827
- if (compare(settings.version, "19.0.0", "<")) {
2922
+ if (compare(settings4.version, "19.0.0", "<")) {
2828
2923
  return {};
2829
2924
  }
2830
2925
  return {
@@ -2850,7 +2945,7 @@ var no_use_context_default = createRule({
2850
2945
  });
2851
2946
  },
2852
2947
  ImportDeclaration(node) {
2853
- if (node.source.value !== settings.importSource) {
2948
+ if (node.source.value !== settings4.importSource) {
2854
2949
  return;
2855
2950
  }
2856
2951
  const isUseImported = node.specifiers.some(isMatching({ local: { type: AST_NODE_TYPES.Identifier, name: "use" } }));
@@ -3339,10 +3434,10 @@ var use_jsx_vars_default = createRule({
3339
3434
  defaultOptions: []
3340
3435
  });
3341
3436
 
3342
- // src/index.ts
3343
- var index_default = {
3437
+ // src/plugin.ts
3438
+ var plugin = {
3344
3439
  meta: {
3345
- name,
3440
+ name: name4,
3346
3441
  version
3347
3442
  },
3348
3443
  rules: {
@@ -3407,4 +3502,31 @@ var index_default = {
3407
3502
  }
3408
3503
  };
3409
3504
 
3505
+ // src/index.ts
3506
+ function makeConfig(config) {
3507
+ return {
3508
+ ...config,
3509
+ plugins: {
3510
+ "react-x": plugin
3511
+ }
3512
+ };
3513
+ }
3514
+ function makeLegacyConfig(config) {
3515
+ return {
3516
+ plugins: ["react-x"],
3517
+ rules: config.rules
3518
+ };
3519
+ }
3520
+ var index_default = {
3521
+ ...plugin,
3522
+ configs: {
3523
+ ["recommended"]: makeConfig(recommended_exports),
3524
+ ["recommended-legacy"]: makeLegacyConfig(recommended_exports),
3525
+ ["recommended-type-checked"]: makeConfig(recommended_type_checked_exports),
3526
+ ["recommended-type-checked-legacy"]: makeLegacyConfig(recommended_type_checked_exports),
3527
+ ["recommended-typescript"]: makeConfig(recommended_typescript_exports),
3528
+ ["recommended-typescript-legacy"]: makeLegacyConfig(recommended_typescript_exports)
3529
+ }
3530
+ };
3531
+
3410
3532
  export { index_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.26.3-beta.13",
3
+ "version": "1.26.3-beta.16",
4
4
  "description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,24 +42,24 @@
42
42
  "./package.json"
43
43
  ],
44
44
  "dependencies": {
45
- "@typescript-eslint/scope-manager": "^8.24.0",
46
- "@typescript-eslint/type-utils": "^8.24.0",
47
- "@typescript-eslint/types": "^8.24.0",
48
- "@typescript-eslint/utils": "^8.24.0",
45
+ "@typescript-eslint/scope-manager": "^8.24.1",
46
+ "@typescript-eslint/type-utils": "^8.24.1",
47
+ "@typescript-eslint/types": "^8.24.1",
48
+ "@typescript-eslint/utils": "^8.24.1",
49
49
  "compare-versions": "^6.1.1",
50
50
  "is-immutable-type": "^5.0.1",
51
51
  "string-ts": "^2.2.1",
52
52
  "ts-pattern": "^5.6.2",
53
- "@eslint-react/ast": "1.26.3-beta.13",
54
- "@eslint-react/core": "1.26.3-beta.13",
55
- "@eslint-react/eff": "1.26.3-beta.13",
56
- "@eslint-react/jsx": "1.26.3-beta.13",
57
- "@eslint-react/var": "1.26.3-beta.13",
58
- "@eslint-react/shared": "1.26.3-beta.13"
53
+ "@eslint-react/ast": "1.26.3-beta.16",
54
+ "@eslint-react/eff": "1.26.3-beta.16",
55
+ "@eslint-react/core": "1.26.3-beta.16",
56
+ "@eslint-react/jsx": "1.26.3-beta.16",
57
+ "@eslint-react/var": "1.26.3-beta.16",
58
+ "@eslint-react/shared": "1.26.3-beta.16"
59
59
  },
60
60
  "devDependencies": {
61
- "@types/react": "^19.0.9",
62
- "@types/react-dom": "^19.0.3",
61
+ "@types/react": "^19.0.10",
62
+ "@types/react-dom": "^19.0.4",
63
63
  "ts-api-utils": "^2.0.1",
64
64
  "tsup": "^8.3.6",
65
65
  "@local/configs": "0.0.0"