eslint-plugin-react-x 1.24.0-beta.1 → 1.24.0-beta.5

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.js CHANGED
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
42
42
 
43
43
  // package.json
44
44
  var name = "eslint-plugin-react-x";
45
- var version = "1.24.0-beta.1";
45
+ var version = "1.24.0-beta.5";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -1171,7 +1171,7 @@ var no_direct_mutation_state_default = createRule({
1171
1171
  if (!isAssignmentToThisState(node)) {
1172
1172
  return;
1173
1173
  }
1174
- const parentClass = AST11__namespace.findParentNodeGuard(
1174
+ const parentClass = AST11__namespace.findParentNode(
1175
1175
  node,
1176
1176
  AST11__namespace.isOneOf([
1177
1177
  types.AST_NODE_TYPES.ClassDeclaration,
@@ -1179,7 +1179,7 @@ var no_direct_mutation_state_default = createRule({
1179
1179
  ])
1180
1180
  );
1181
1181
  if (parentClass == null) return;
1182
- if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11__namespace.findParentNodeGuard(node, isConstructorFunction)) {
1182
+ if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11__namespace.findParentNode(node, isConstructorFunction)) {
1183
1183
  context.report({
1184
1184
  messageId: "noDirectMutationState",
1185
1185
  node
@@ -1280,7 +1280,7 @@ var no_duplicate_key_default = createRule({
1280
1280
  break;
1281
1281
  }
1282
1282
  default: {
1283
- const call = AST11__namespace.findParentNodeGuard(jsxElement, AST11__namespace.isMapCallLoose);
1283
+ const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.isMapCallLoose);
1284
1284
  const iter = AST11__namespace.findParentNode(jsxElement, (n) => n === call || AST11__namespace.isFunction(n));
1285
1285
  if (!AST11__namespace.isFunction(iter)) return;
1286
1286
  const arg0 = call?.arguments[0];
@@ -1649,7 +1649,17 @@ var no_missing_component_display_name_default = createRule({
1649
1649
  if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) {
1650
1650
  return {};
1651
1651
  }
1652
- const { ctx, listeners } = core.useComponentCollector(context);
1652
+ const {
1653
+ ctx,
1654
+ listeners
1655
+ } = core.useComponentCollector(
1656
+ context,
1657
+ core.DEFAULT_COMPONENT_HINT,
1658
+ {
1659
+ collectDisplayName: true,
1660
+ collectHookCalls: false
1661
+ }
1662
+ );
1653
1663
  return {
1654
1664
  ...listeners,
1655
1665
  "Program:exit"(node) {
@@ -1884,7 +1894,7 @@ var no_nested_components_default = createRule({
1884
1894
  });
1885
1895
  continue;
1886
1896
  }
1887
- const parentComponent = AST11__namespace.findParentNodeGuard(component, isFunctionComponent);
1897
+ const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
1888
1898
  const isParnetComponentNotDirectValueOfRenderProperty = parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent);
1889
1899
  if (isParnetComponentNotDirectValueOfRenderProperty) {
1890
1900
  context.report({
@@ -2058,7 +2068,7 @@ var no_set_state_in_component_did_mount_default = createRule({
2058
2068
  if (!core.isThisSetState(node)) {
2059
2069
  return;
2060
2070
  }
2061
- const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2071
+ const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
2062
2072
  const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
2063
2073
  if (clazz == null || method == null || method === clazz) return;
2064
2074
  const methodScope = context.sourceCode.getScope(method);
@@ -2103,7 +2113,7 @@ var no_set_state_in_component_did_update_default = createRule({
2103
2113
  if (!core.isThisSetState(node)) {
2104
2114
  return;
2105
2115
  }
2106
- const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2116
+ const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
2107
2117
  const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
2108
2118
  if (clazz == null || method == null || method === clazz) return;
2109
2119
  const methodScope = context.sourceCode.getScope(method);
@@ -2148,7 +2158,7 @@ var no_set_state_in_component_will_update_default = createRule({
2148
2158
  if (!core.isThisSetState(node)) {
2149
2159
  return;
2150
2160
  }
2151
- const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2161
+ const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
2152
2162
  const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
2153
2163
  if (clazz == null || method == null || method === clazz) return;
2154
2164
  const methodScope = context.sourceCode.getScope(method);
@@ -2392,8 +2402,7 @@ var no_unstable_context_value_default = createRule({
2392
2402
  if (core.isReactHookCall(construction.node)) {
2393
2403
  return;
2394
2404
  }
2395
- const prevs = constructions.get(functionEntry.node) ?? [];
2396
- constructions.set(functionEntry.node, [...prevs, construction]);
2405
+ eff.getOrUpdate(constructions, functionEntry.node, () => []).push(construction);
2397
2406
  },
2398
2407
  "Program:exit"(node) {
2399
2408
  const components = ctx.getAllComponents(node).values();
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as JSX7 from '@eslint-react/jsx';
2
2
  import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings } from '@eslint-react/shared';
3
3
  import * as AST11 from '@eslint-react/ast';
4
- import { isForwardRefCall, isThisSetState, isClassComponent, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, ERFunctionComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, ERClassComponentFlag, isReactHookCall, isCreateElementCall, isInitializedFromReact } from '@eslint-react/core';
5
- import { _ } from '@eslint-react/eff';
4
+ import { isForwardRefCall, isThisSetState, isClassComponent, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, DEFAULT_COMPONENT_HINT, ERFunctionComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, ERClassComponentFlag, isReactHookCall, isCreateElementCall, isInitializedFromReact } from '@eslint-react/core';
5
+ import { _, getOrUpdate } from '@eslint-react/eff';
6
6
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
7
7
  import { isMatching, match, P } from 'ts-pattern';
8
8
  import { compare } from 'compare-versions';
@@ -15,7 +15,7 @@ import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReado
15
15
 
16
16
  // package.json
17
17
  var name = "eslint-plugin-react-x";
18
- var version = "1.24.0-beta.1";
18
+ var version = "1.24.0-beta.5";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -1144,7 +1144,7 @@ var no_direct_mutation_state_default = createRule({
1144
1144
  if (!isAssignmentToThisState(node)) {
1145
1145
  return;
1146
1146
  }
1147
- const parentClass = AST11.findParentNodeGuard(
1147
+ const parentClass = AST11.findParentNode(
1148
1148
  node,
1149
1149
  AST11.isOneOf([
1150
1150
  AST_NODE_TYPES.ClassDeclaration,
@@ -1152,7 +1152,7 @@ var no_direct_mutation_state_default = createRule({
1152
1152
  ])
1153
1153
  );
1154
1154
  if (parentClass == null) return;
1155
- if (isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11.findParentNodeGuard(node, isConstructorFunction)) {
1155
+ if (isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11.findParentNode(node, isConstructorFunction)) {
1156
1156
  context.report({
1157
1157
  messageId: "noDirectMutationState",
1158
1158
  node
@@ -1253,7 +1253,7 @@ var no_duplicate_key_default = createRule({
1253
1253
  break;
1254
1254
  }
1255
1255
  default: {
1256
- const call = AST11.findParentNodeGuard(jsxElement, AST11.isMapCallLoose);
1256
+ const call = AST11.findParentNode(jsxElement, AST11.isMapCallLoose);
1257
1257
  const iter = AST11.findParentNode(jsxElement, (n) => n === call || AST11.isFunction(n));
1258
1258
  if (!AST11.isFunction(iter)) return;
1259
1259
  const arg0 = call?.arguments[0];
@@ -1622,7 +1622,17 @@ var no_missing_component_display_name_default = createRule({
1622
1622
  if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) {
1623
1623
  return {};
1624
1624
  }
1625
- const { ctx, listeners } = useComponentCollector(context);
1625
+ const {
1626
+ ctx,
1627
+ listeners
1628
+ } = useComponentCollector(
1629
+ context,
1630
+ DEFAULT_COMPONENT_HINT,
1631
+ {
1632
+ collectDisplayName: true,
1633
+ collectHookCalls: false
1634
+ }
1635
+ );
1626
1636
  return {
1627
1637
  ...listeners,
1628
1638
  "Program:exit"(node) {
@@ -1857,7 +1867,7 @@ var no_nested_components_default = createRule({
1857
1867
  });
1858
1868
  continue;
1859
1869
  }
1860
- const parentComponent = AST11.findParentNodeGuard(component, isFunctionComponent);
1870
+ const parentComponent = AST11.findParentNode(component, isFunctionComponent);
1861
1871
  const isParnetComponentNotDirectValueOfRenderProperty = parentComponent != null && !isDirectValueOfRenderPropertyLoose(parentComponent);
1862
1872
  if (isParnetComponentNotDirectValueOfRenderProperty) {
1863
1873
  context.report({
@@ -2031,7 +2041,7 @@ var no_set_state_in_component_did_mount_default = createRule({
2031
2041
  if (!isThisSetState(node)) {
2032
2042
  return;
2033
2043
  }
2034
- const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2044
+ const clazz = AST11.findParentNode(node, isClassComponent);
2035
2045
  const method = AST11.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
2036
2046
  if (clazz == null || method == null || method === clazz) return;
2037
2047
  const methodScope = context.sourceCode.getScope(method);
@@ -2076,7 +2086,7 @@ var no_set_state_in_component_did_update_default = createRule({
2076
2086
  if (!isThisSetState(node)) {
2077
2087
  return;
2078
2088
  }
2079
- const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2089
+ const clazz = AST11.findParentNode(node, isClassComponent);
2080
2090
  const method = AST11.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
2081
2091
  if (clazz == null || method == null || method === clazz) return;
2082
2092
  const methodScope = context.sourceCode.getScope(method);
@@ -2121,7 +2131,7 @@ var no_set_state_in_component_will_update_default = createRule({
2121
2131
  if (!isThisSetState(node)) {
2122
2132
  return;
2123
2133
  }
2124
- const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2134
+ const clazz = AST11.findParentNode(node, isClassComponent);
2125
2135
  const method = AST11.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
2126
2136
  if (clazz == null || method == null || method === clazz) return;
2127
2137
  const methodScope = context.sourceCode.getScope(method);
@@ -2365,8 +2375,7 @@ var no_unstable_context_value_default = createRule({
2365
2375
  if (isReactHookCall(construction.node)) {
2366
2376
  return;
2367
2377
  }
2368
- const prevs = constructions.get(functionEntry.node) ?? [];
2369
- constructions.set(functionEntry.node, [...prevs, construction]);
2378
+ getOrUpdate(constructions, functionEntry.node, () => []).push(construction);
2370
2379
  },
2371
2380
  "Program:exit"(node) {
2372
2381
  const components = ctx.getAllComponents(node).values();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.24.0-beta.1",
3
+ "version": "1.24.0-beta.5",
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",
@@ -48,16 +48,15 @@
48
48
  "is-immutable-type": "^5.0.1",
49
49
  "string-ts": "^2.2.0",
50
50
  "ts-pattern": "^5.6.0",
51
- "@eslint-react/ast": "1.24.0-beta.1",
52
- "@eslint-react/core": "1.24.0-beta.1",
53
- "@eslint-react/eff": "1.24.0-beta.1",
54
- "@eslint-react/jsx": "1.24.0-beta.1",
55
- "@eslint-react/shared": "1.24.0-beta.1",
56
- "@eslint-react/types": "1.24.0-beta.1",
57
- "@eslint-react/var": "1.24.0-beta.1"
51
+ "@eslint-react/core": "1.24.0-beta.5",
52
+ "@eslint-react/ast": "1.24.0-beta.5",
53
+ "@eslint-react/eff": "1.24.0-beta.5",
54
+ "@eslint-react/shared": "1.24.0-beta.5",
55
+ "@eslint-react/var": "1.24.0-beta.5",
56
+ "@eslint-react/jsx": "1.24.0-beta.5"
58
57
  },
59
58
  "devDependencies": {
60
- "@types/react": "^19.0.5",
59
+ "@types/react": "^19.0.6",
61
60
  "@types/react-dom": "^19.0.3",
62
61
  "ts-api-utils": "^2.0.0",
63
62
  "tsup": "^8.3.5",