eslint-plugin-react-x 1.24.0-next.0 → 1.24.0-next.2

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 (3) hide show
  1. package/dist/index.js +52 -48
  2. package/dist/index.mjs +52 -48
  3. package/package.json +10 -10
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-next.0";
45
+ var version = "1.24.0-next.2";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -221,15 +221,15 @@ var no_access_state_in_setstate_default = createRule({
221
221
  if (!AST11__namespace.isThisExpression(node.object)) {
222
222
  return;
223
223
  }
224
- const [currClass, isComponent] = classEntries.at(-1) ?? [];
224
+ const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
225
225
  if (currClass == null || !isComponent) {
226
226
  return;
227
227
  }
228
- const [currMethod, isStatic] = methodEntries.at(-1) ?? [];
228
+ const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
229
229
  if (currMethod == null || isStatic) {
230
230
  return;
231
231
  }
232
- const [setState, hasThisState] = setStateEntries.at(-1) ?? [];
232
+ const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
233
233
  if (setState == null || hasThisState) {
234
234
  return;
235
235
  }
@@ -251,15 +251,15 @@ var no_access_state_in_setstate_default = createRule({
251
251
  methodEntries.pop();
252
252
  },
253
253
  VariableDeclarator(node) {
254
- const [currClass, isComponent] = classEntries.at(-1) ?? [];
254
+ const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
255
255
  if (currClass == null || !isComponent) {
256
256
  return;
257
257
  }
258
- const [currMethod, isStatic] = methodEntries.at(-1) ?? [];
258
+ const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
259
259
  if (currMethod == null || isStatic) {
260
260
  return;
261
261
  }
262
- const [setState, hasThisState] = setStateEntries.at(-1) ?? [];
262
+ const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
263
263
  if (setState == null || hasThisState) {
264
264
  return;
265
265
  }
@@ -615,7 +615,7 @@ var no_children_prop_default = createRule({
615
615
  context.sourceCode.getScope(node),
616
616
  node.openingElement.attributes
617
617
  );
618
- if (prop) {
618
+ if (prop != null) {
619
619
  context.report({
620
620
  messageId: "noChildrenProp",
621
621
  node: prop
@@ -1063,7 +1063,7 @@ var no_create_ref_default = createRule({
1063
1063
  create(context) {
1064
1064
  return {
1065
1065
  CallExpression(node) {
1066
- if (core.isCreateRefCall(node, context) && !AST11__namespace.findParentNode(node, core.isClassComponent)) {
1066
+ if (core.isCreateRefCall(node, context) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
1067
1067
  context.report({ messageId: "noCreateRef", node });
1068
1068
  }
1069
1069
  }
@@ -1109,7 +1109,7 @@ var no_default_props_default = createRule({
1109
1109
  }
1110
1110
  const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
1111
1111
  const variableNode = VAR__namespace.getVariableNode(variable, 0);
1112
- if (variableNode === eff._) return;
1112
+ if (variableNode == null) return;
1113
1113
  if (!AST11__namespace.isFunction(variableNode) && !core.isClassComponent(variableNode)) return;
1114
1114
  context.report({ messageId: "noDefaultProps", node: property });
1115
1115
  },
@@ -1171,15 +1171,15 @@ 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,
1178
1178
  types.AST_NODE_TYPES.ClassExpression
1179
1179
  ])
1180
1180
  );
1181
- if (!parentClass) return;
1182
- if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11__namespace.findParentNodeGuard(node, isConstructorFunction)) {
1181
+ if (parentClass == null) return;
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,10 +1280,11 @@ var no_duplicate_key_default = createRule({
1280
1280
  break;
1281
1281
  }
1282
1282
  default: {
1283
- const call = AST11__namespace.findParentNodeGuard(jsxElement, AST11__namespace.isMapCallLoose);
1284
- const iter = call && AST11__namespace.findParentNodeStop(jsxElement, call, AST11__namespace.isFunction);
1283
+ const call = AST11__namespace.findParentNode(jsxElement, AST11__namespace.isMapCallLoose);
1284
+ const iter = AST11__namespace.findParentNode(jsxElement, (n) => n === call || AST11__namespace.isFunction(n));
1285
+ if (!AST11__namespace.isFunction(iter)) return;
1285
1286
  const arg0 = call?.arguments[0];
1286
- if (!call || !iter || !arg0) return;
1287
+ if (call == null || arg0 == null) return;
1287
1288
  if (AST11__namespace.unwrapTypeExpression(arg0) !== iter) {
1288
1289
  return;
1289
1290
  }
@@ -1447,7 +1448,7 @@ var no_implicit_key_default = createRule({
1447
1448
  const keyPropOnElement = node.attributes.some(
1448
1449
  (n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
1449
1450
  );
1450
- if (keyPropFound && !keyPropOnElement) {
1451
+ if (keyPropFound != null && !keyPropOnElement) {
1451
1452
  context.report({ messageId: "noImplicitKey", node: keyPropFound });
1452
1453
  }
1453
1454
  }
@@ -1544,7 +1545,7 @@ function isInitExpression(node) {
1544
1545
  }
1545
1546
  function getVariableInitExpression(variable, at) {
1546
1547
  const def = variable?.defs[at];
1547
- if (def?.node === eff._ || !("init" in def.node)) {
1548
+ if (def?.node == null || !("init" in def.node)) {
1548
1549
  return eff._;
1549
1550
  }
1550
1551
  return isInitExpression(def.node.init) ? def.node.init : eff._;
@@ -1581,7 +1582,7 @@ var no_leaked_conditional_rendering_default = createRule({
1581
1582
  ];
1582
1583
  const services = utils.ESLintUtils.getParserServices(context, false);
1583
1584
  function getReportDescriptor(node) {
1584
- if (node === eff._) return eff._;
1585
+ if (node == null) return eff._;
1585
1586
  return tsPattern.match(node).when(AST11__namespace.isJSX, () => eff._).with({ type: types.AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1586
1587
  const isLeftUnaryNot = left.type === types.AST_NODE_TYPES.UnaryExpression && left.operator === "!";
1587
1588
  if (isLeftUnaryNot) {
@@ -1617,7 +1618,7 @@ var no_leaked_conditional_rendering_default = createRule({
1617
1618
  }
1618
1619
  const visitorFunction = (node) => {
1619
1620
  const descriptor = getReportDescriptor(node);
1620
- if (descriptor === eff._) return;
1621
+ if (descriptor == null) return;
1621
1622
  context.report(descriptor);
1622
1623
  };
1623
1624
  return {
@@ -1655,13 +1656,13 @@ var no_missing_component_display_name_default = createRule({
1655
1656
  const components = ctx.getAllComponents(node);
1656
1657
  for (const { node: node2, displayName, flag } of components.values()) {
1657
1658
  const isMemoOrForwardRef = (flag & (core.ERFunctionComponentFlag.ForwardRef | core.ERFunctionComponentFlag.Memo)) > 0n;
1658
- if (AST11__namespace.getFunctionIdentifier(node2)) {
1659
+ if (AST11__namespace.getFunctionIdentifier(node2) != null) {
1659
1660
  continue;
1660
1661
  }
1661
1662
  if (!isMemoOrForwardRef) {
1662
1663
  continue;
1663
1664
  }
1664
- if (!displayName) {
1665
+ if (displayName == null) {
1665
1666
  context.report({
1666
1667
  messageId: "noMissingComponentDisplayName",
1667
1668
  node: node2
@@ -1860,7 +1861,7 @@ var no_nested_components_default = createRule({
1860
1861
  continue;
1861
1862
  }
1862
1863
  const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
1863
- const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || !!JSX7__namespace.findParentProp(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer);
1864
+ const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.findParentProp(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
1864
1865
  if (isInsideJSXPropValue) {
1865
1866
  if (!core.isDeclaredInRenderPropLoose(component)) {
1866
1867
  context.report({
@@ -1883,8 +1884,8 @@ var no_nested_components_default = createRule({
1883
1884
  });
1884
1885
  continue;
1885
1886
  }
1886
- const parentComponent = AST11__namespace.findParentNodeGuard(component, isFunctionComponent);
1887
- const isParnetComponentNotDirectValueOfRenderProperty = !!parentComponent && !core.isDirectValueOfRenderPropertyLoose(parentComponent);
1887
+ const parentComponent = AST11__namespace.findParentNode(component, isFunctionComponent);
1888
+ const isParnetComponentNotDirectValueOfRenderProperty = parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent);
1888
1889
  if (isParnetComponentNotDirectValueOfRenderProperty) {
1889
1890
  context.report({
1890
1891
  messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
@@ -1906,7 +1907,7 @@ var no_nested_components_default = createRule({
1906
1907
  }
1907
1908
  }
1908
1909
  for (const { name: name2 = "unknown", node: component } of classComponents) {
1909
- if (!AST11__namespace.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n))) {
1910
+ if (AST11__namespace.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
1910
1911
  continue;
1911
1912
  }
1912
1913
  context.report({
@@ -1959,8 +1960,8 @@ var no_prop_types_default = createRule({
1959
1960
  return;
1960
1961
  }
1961
1962
  const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
1962
- const variableNode = variable && VAR__namespace.getVariableNode(variable, 0);
1963
- if (variableNode && (AST11__namespace.isFunction(variableNode) || core.isClassComponent(variableNode))) {
1963
+ const variableNode = VAR__namespace.getVariableNode(variable, 0);
1964
+ if (variableNode != null && (AST11__namespace.isFunction(variableNode) || core.isClassComponent(variableNode))) {
1964
1965
  context.report({ messageId: "noPropTypes", node: property });
1965
1966
  }
1966
1967
  },
@@ -2057,11 +2058,12 @@ var no_set_state_in_component_did_mount_default = createRule({
2057
2058
  if (!core.isThisSetState(node)) {
2058
2059
  return;
2059
2060
  }
2060
- const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2061
- const method = clazz && AST11__namespace.findParentNodeStop(node, clazz, isComponentDidMount);
2062
- const methodScope = method && context.sourceCode.getScope(method);
2061
+ const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
2062
+ const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
2063
+ if (clazz == null || method == null || method === clazz) return;
2064
+ const methodScope = context.sourceCode.getScope(method);
2063
2065
  const upperScope = context.sourceCode.getScope(node).upper;
2064
- if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2066
+ if (method.parent === clazz.body && upperScope === methodScope) {
2065
2067
  context.report({
2066
2068
  messageId: "noSetStateInComponentDidMount",
2067
2069
  node
@@ -2101,11 +2103,12 @@ var no_set_state_in_component_did_update_default = createRule({
2101
2103
  if (!core.isThisSetState(node)) {
2102
2104
  return;
2103
2105
  }
2104
- const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2105
- const method = clazz && AST11__namespace.findParentNodeStop(node, clazz, isComponentDidUpdate);
2106
- const methodScope = method && context.sourceCode.getScope(method);
2106
+ const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
2107
+ const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
2108
+ if (clazz == null || method == null || method === clazz) return;
2109
+ const methodScope = context.sourceCode.getScope(method);
2107
2110
  const upperScope = context.sourceCode.getScope(node).upper;
2108
- if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2111
+ if (method.parent === clazz.body && upperScope === methodScope) {
2109
2112
  context.report({
2110
2113
  messageId: "noSetStateInComponentDidUpdate",
2111
2114
  node
@@ -2145,11 +2148,12 @@ var no_set_state_in_component_will_update_default = createRule({
2145
2148
  if (!core.isThisSetState(node)) {
2146
2149
  return;
2147
2150
  }
2148
- const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2149
- const method = clazz && AST11__namespace.findParentNodeStop(node, clazz, isComponentWillUpdate3);
2150
- const methodScope = method && context.sourceCode.getScope(method);
2151
+ const clazz = AST11__namespace.findParentNode(node, core.isClassComponent);
2152
+ const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
2153
+ if (clazz == null || method == null || method === clazz) return;
2154
+ const methodScope = context.sourceCode.getScope(method);
2151
2155
  const upperScope = context.sourceCode.getScope(node).upper;
2152
- if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2156
+ if (method.parent === clazz.body && upperScope === methodScope) {
2153
2157
  context.report({
2154
2158
  messageId: "noSetStateInComponentWillUpdate",
2155
2159
  node
@@ -2374,17 +2378,17 @@ var no_unstable_context_value_default = createRule({
2374
2378
  return;
2375
2379
  }
2376
2380
  const functionEntry = ctx.getCurrentEntry();
2377
- if (functionEntry === eff._) return;
2381
+ if (functionEntry == null) return;
2378
2382
  const attribute = node.attributes.find(
2379
2383
  (attribute2) => attribute2.type === types.AST_NODE_TYPES.JSXAttribute && attribute2.name.name === "value"
2380
2384
  );
2381
- if (attribute === eff._ || !("value" in attribute)) return;
2385
+ if (attribute == null || !("value" in attribute)) return;
2382
2386
  const value = attribute.value;
2383
2387
  if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) return;
2384
2388
  const valueExpression = value.expression;
2385
2389
  const initialScope = context.sourceCode.getScope(valueExpression);
2386
2390
  const construction = VAR__namespace.getValueConstruction(valueExpression, initialScope);
2387
- if (construction === eff._) return;
2391
+ if (construction == null) return;
2388
2392
  if (core.isReactHookCall(construction.node)) {
2389
2393
  return;
2390
2394
  }
@@ -2456,7 +2460,7 @@ var no_unstable_default_props_default = createRule({
2456
2460
  initialScope,
2457
2461
  VAR__namespace.ValueConstructionHint.StrictCallExpression
2458
2462
  );
2459
- if (construction === eff._) {
2463
+ if (construction == null) {
2460
2464
  continue;
2461
2465
  }
2462
2466
  if (core.isReactHookCall(construction.node)) {
@@ -2475,7 +2479,7 @@ var no_unstable_default_props_default = createRule({
2475
2479
  },
2476
2480
  "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node) {
2477
2481
  const functionEntry = ctx.getCurrentEntry();
2478
- if (!functionEntry) return;
2482
+ if (functionEntry == null) return;
2479
2483
  const prevs = declarators.get(functionEntry.node) ?? [];
2480
2484
  declarators.set(functionEntry.node, [...prevs, node]);
2481
2485
  }
@@ -2703,8 +2707,8 @@ var no_unused_state_default = createRule({
2703
2707
  return;
2704
2708
  }
2705
2709
  const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
2706
- const { node: defNode, isUsed } = stateDefs.get(currentClass) ?? {};
2707
- if (!defNode || isUsed) {
2710
+ const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
2711
+ if (defNode == null || isUsed) {
2708
2712
  return;
2709
2713
  }
2710
2714
  context.report({
@@ -2947,7 +2951,7 @@ var prefer_destructuring_assignment_default = createRule({
2947
2951
  return false;
2948
2952
  }
2949
2953
  const id = AST11__namespace.getFunctionIdentifier(block);
2950
- return !!id && core.isComponentName(id.name) && components.some((component) => component.node === block);
2954
+ return id != null && core.isComponentName(id.name) && components.some((component) => component.node === block);
2951
2955
  }
2952
2956
  for (const [initialScope, memberExpression] of memberExpressionWithNames) {
2953
2957
  let scope = initialScope;
package/dist/index.mjs CHANGED
@@ -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-next.0";
18
+ var version = "1.24.0-next.2";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -194,15 +194,15 @@ var no_access_state_in_setstate_default = createRule({
194
194
  if (!AST11.isThisExpression(node.object)) {
195
195
  return;
196
196
  }
197
- const [currClass, isComponent] = classEntries.at(-1) ?? [];
197
+ const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
198
198
  if (currClass == null || !isComponent) {
199
199
  return;
200
200
  }
201
- const [currMethod, isStatic] = methodEntries.at(-1) ?? [];
201
+ const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
202
202
  if (currMethod == null || isStatic) {
203
203
  return;
204
204
  }
205
- const [setState, hasThisState] = setStateEntries.at(-1) ?? [];
205
+ const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
206
206
  if (setState == null || hasThisState) {
207
207
  return;
208
208
  }
@@ -224,15 +224,15 @@ var no_access_state_in_setstate_default = createRule({
224
224
  methodEntries.pop();
225
225
  },
226
226
  VariableDeclarator(node) {
227
- const [currClass, isComponent] = classEntries.at(-1) ?? [];
227
+ const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
228
228
  if (currClass == null || !isComponent) {
229
229
  return;
230
230
  }
231
- const [currMethod, isStatic] = methodEntries.at(-1) ?? [];
231
+ const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
232
232
  if (currMethod == null || isStatic) {
233
233
  return;
234
234
  }
235
- const [setState, hasThisState] = setStateEntries.at(-1) ?? [];
235
+ const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
236
236
  if (setState == null || hasThisState) {
237
237
  return;
238
238
  }
@@ -588,7 +588,7 @@ var no_children_prop_default = createRule({
588
588
  context.sourceCode.getScope(node),
589
589
  node.openingElement.attributes
590
590
  );
591
- if (prop) {
591
+ if (prop != null) {
592
592
  context.report({
593
593
  messageId: "noChildrenProp",
594
594
  node: prop
@@ -1036,7 +1036,7 @@ var no_create_ref_default = createRule({
1036
1036
  create(context) {
1037
1037
  return {
1038
1038
  CallExpression(node) {
1039
- if (isCreateRefCall(node, context) && !AST11.findParentNode(node, isClassComponent)) {
1039
+ if (isCreateRefCall(node, context) && AST11.findParentNode(node, isClassComponent) == null) {
1040
1040
  context.report({ messageId: "noCreateRef", node });
1041
1041
  }
1042
1042
  }
@@ -1082,7 +1082,7 @@ var no_default_props_default = createRule({
1082
1082
  }
1083
1083
  const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
1084
1084
  const variableNode = VAR.getVariableNode(variable, 0);
1085
- if (variableNode === _) return;
1085
+ if (variableNode == null) return;
1086
1086
  if (!AST11.isFunction(variableNode) && !isClassComponent(variableNode)) return;
1087
1087
  context.report({ messageId: "noDefaultProps", node: property });
1088
1088
  },
@@ -1144,15 +1144,15 @@ 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,
1151
1151
  AST_NODE_TYPES.ClassExpression
1152
1152
  ])
1153
1153
  );
1154
- if (!parentClass) return;
1155
- if (isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11.findParentNodeGuard(node, isConstructorFunction)) {
1154
+ if (parentClass == null) return;
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,10 +1253,11 @@ var no_duplicate_key_default = createRule({
1253
1253
  break;
1254
1254
  }
1255
1255
  default: {
1256
- const call = AST11.findParentNodeGuard(jsxElement, AST11.isMapCallLoose);
1257
- const iter = call && AST11.findParentNodeStop(jsxElement, call, AST11.isFunction);
1256
+ const call = AST11.findParentNode(jsxElement, AST11.isMapCallLoose);
1257
+ const iter = AST11.findParentNode(jsxElement, (n) => n === call || AST11.isFunction(n));
1258
+ if (!AST11.isFunction(iter)) return;
1258
1259
  const arg0 = call?.arguments[0];
1259
- if (!call || !iter || !arg0) return;
1260
+ if (call == null || arg0 == null) return;
1260
1261
  if (AST11.unwrapTypeExpression(arg0) !== iter) {
1261
1262
  return;
1262
1263
  }
@@ -1420,7 +1421,7 @@ var no_implicit_key_default = createRule({
1420
1421
  const keyPropOnElement = node.attributes.some(
1421
1422
  (n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
1422
1423
  );
1423
- if (keyPropFound && !keyPropOnElement) {
1424
+ if (keyPropFound != null && !keyPropOnElement) {
1424
1425
  context.report({ messageId: "noImplicitKey", node: keyPropFound });
1425
1426
  }
1426
1427
  }
@@ -1517,7 +1518,7 @@ function isInitExpression(node) {
1517
1518
  }
1518
1519
  function getVariableInitExpression(variable, at) {
1519
1520
  const def = variable?.defs[at];
1520
- if (def?.node === _ || !("init" in def.node)) {
1521
+ if (def?.node == null || !("init" in def.node)) {
1521
1522
  return _;
1522
1523
  }
1523
1524
  return isInitExpression(def.node.init) ? def.node.init : _;
@@ -1554,7 +1555,7 @@ var no_leaked_conditional_rendering_default = createRule({
1554
1555
  ];
1555
1556
  const services = ESLintUtils.getParserServices(context, false);
1556
1557
  function getReportDescriptor(node) {
1557
- if (node === _) return _;
1558
+ if (node == null) return _;
1558
1559
  return match(node).when(AST11.isJSX, () => _).with({ type: AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1559
1560
  const isLeftUnaryNot = left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!";
1560
1561
  if (isLeftUnaryNot) {
@@ -1590,7 +1591,7 @@ var no_leaked_conditional_rendering_default = createRule({
1590
1591
  }
1591
1592
  const visitorFunction = (node) => {
1592
1593
  const descriptor = getReportDescriptor(node);
1593
- if (descriptor === _) return;
1594
+ if (descriptor == null) return;
1594
1595
  context.report(descriptor);
1595
1596
  };
1596
1597
  return {
@@ -1628,13 +1629,13 @@ var no_missing_component_display_name_default = createRule({
1628
1629
  const components = ctx.getAllComponents(node);
1629
1630
  for (const { node: node2, displayName, flag } of components.values()) {
1630
1631
  const isMemoOrForwardRef = (flag & (ERFunctionComponentFlag.ForwardRef | ERFunctionComponentFlag.Memo)) > 0n;
1631
- if (AST11.getFunctionIdentifier(node2)) {
1632
+ if (AST11.getFunctionIdentifier(node2) != null) {
1632
1633
  continue;
1633
1634
  }
1634
1635
  if (!isMemoOrForwardRef) {
1635
1636
  continue;
1636
1637
  }
1637
- if (!displayName) {
1638
+ if (displayName == null) {
1638
1639
  context.report({
1639
1640
  messageId: "noMissingComponentDisplayName",
1640
1641
  node: node2
@@ -1833,7 +1834,7 @@ var no_nested_components_default = createRule({
1833
1834
  continue;
1834
1835
  }
1835
1836
  const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
1836
- const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || !!JSX7.findParentProp(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer);
1837
+ const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.findParentProp(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
1837
1838
  if (isInsideJSXPropValue) {
1838
1839
  if (!isDeclaredInRenderPropLoose(component)) {
1839
1840
  context.report({
@@ -1856,8 +1857,8 @@ var no_nested_components_default = createRule({
1856
1857
  });
1857
1858
  continue;
1858
1859
  }
1859
- const parentComponent = AST11.findParentNodeGuard(component, isFunctionComponent);
1860
- const isParnetComponentNotDirectValueOfRenderProperty = !!parentComponent && !isDirectValueOfRenderPropertyLoose(parentComponent);
1860
+ const parentComponent = AST11.findParentNode(component, isFunctionComponent);
1861
+ const isParnetComponentNotDirectValueOfRenderProperty = parentComponent != null && !isDirectValueOfRenderPropertyLoose(parentComponent);
1861
1862
  if (isParnetComponentNotDirectValueOfRenderProperty) {
1862
1863
  context.report({
1863
1864
  messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
@@ -1879,7 +1880,7 @@ var no_nested_components_default = createRule({
1879
1880
  }
1880
1881
  }
1881
1882
  for (const { name: name2 = "unknown", node: component } of classComponents) {
1882
- if (!AST11.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n))) {
1883
+ if (AST11.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
1883
1884
  continue;
1884
1885
  }
1885
1886
  context.report({
@@ -1932,8 +1933,8 @@ var no_prop_types_default = createRule({
1932
1933
  return;
1933
1934
  }
1934
1935
  const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
1935
- const variableNode = variable && VAR.getVariableNode(variable, 0);
1936
- if (variableNode && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
1936
+ const variableNode = VAR.getVariableNode(variable, 0);
1937
+ if (variableNode != null && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
1937
1938
  context.report({ messageId: "noPropTypes", node: property });
1938
1939
  }
1939
1940
  },
@@ -2030,11 +2031,12 @@ var no_set_state_in_component_did_mount_default = createRule({
2030
2031
  if (!isThisSetState(node)) {
2031
2032
  return;
2032
2033
  }
2033
- const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2034
- const method = clazz && AST11.findParentNodeStop(node, clazz, isComponentDidMount);
2035
- const methodScope = method && context.sourceCode.getScope(method);
2034
+ const clazz = AST11.findParentNode(node, isClassComponent);
2035
+ const method = AST11.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
2036
+ if (clazz == null || method == null || method === clazz) return;
2037
+ const methodScope = context.sourceCode.getScope(method);
2036
2038
  const upperScope = context.sourceCode.getScope(node).upper;
2037
- if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2039
+ if (method.parent === clazz.body && upperScope === methodScope) {
2038
2040
  context.report({
2039
2041
  messageId: "noSetStateInComponentDidMount",
2040
2042
  node
@@ -2074,11 +2076,12 @@ var no_set_state_in_component_did_update_default = createRule({
2074
2076
  if (!isThisSetState(node)) {
2075
2077
  return;
2076
2078
  }
2077
- const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2078
- const method = clazz && AST11.findParentNodeStop(node, clazz, isComponentDidUpdate);
2079
- const methodScope = method && context.sourceCode.getScope(method);
2079
+ const clazz = AST11.findParentNode(node, isClassComponent);
2080
+ const method = AST11.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
2081
+ if (clazz == null || method == null || method === clazz) return;
2082
+ const methodScope = context.sourceCode.getScope(method);
2080
2083
  const upperScope = context.sourceCode.getScope(node).upper;
2081
- if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2084
+ if (method.parent === clazz.body && upperScope === methodScope) {
2082
2085
  context.report({
2083
2086
  messageId: "noSetStateInComponentDidUpdate",
2084
2087
  node
@@ -2118,11 +2121,12 @@ var no_set_state_in_component_will_update_default = createRule({
2118
2121
  if (!isThisSetState(node)) {
2119
2122
  return;
2120
2123
  }
2121
- const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2122
- const method = clazz && AST11.findParentNodeStop(node, clazz, isComponentWillUpdate3);
2123
- const methodScope = method && context.sourceCode.getScope(method);
2124
+ const clazz = AST11.findParentNode(node, isClassComponent);
2125
+ const method = AST11.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
2126
+ if (clazz == null || method == null || method === clazz) return;
2127
+ const methodScope = context.sourceCode.getScope(method);
2124
2128
  const upperScope = context.sourceCode.getScope(node).upper;
2125
- if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2129
+ if (method.parent === clazz.body && upperScope === methodScope) {
2126
2130
  context.report({
2127
2131
  messageId: "noSetStateInComponentWillUpdate",
2128
2132
  node
@@ -2347,17 +2351,17 @@ var no_unstable_context_value_default = createRule({
2347
2351
  return;
2348
2352
  }
2349
2353
  const functionEntry = ctx.getCurrentEntry();
2350
- if (functionEntry === _) return;
2354
+ if (functionEntry == null) return;
2351
2355
  const attribute = node.attributes.find(
2352
2356
  (attribute2) => attribute2.type === AST_NODE_TYPES.JSXAttribute && attribute2.name.name === "value"
2353
2357
  );
2354
- if (attribute === _ || !("value" in attribute)) return;
2358
+ if (attribute == null || !("value" in attribute)) return;
2355
2359
  const value = attribute.value;
2356
2360
  if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
2357
2361
  const valueExpression = value.expression;
2358
2362
  const initialScope = context.sourceCode.getScope(valueExpression);
2359
2363
  const construction = VAR.getValueConstruction(valueExpression, initialScope);
2360
- if (construction === _) return;
2364
+ if (construction == null) return;
2361
2365
  if (isReactHookCall(construction.node)) {
2362
2366
  return;
2363
2367
  }
@@ -2429,7 +2433,7 @@ var no_unstable_default_props_default = createRule({
2429
2433
  initialScope,
2430
2434
  VAR.ValueConstructionHint.StrictCallExpression
2431
2435
  );
2432
- if (construction === _) {
2436
+ if (construction == null) {
2433
2437
  continue;
2434
2438
  }
2435
2439
  if (isReactHookCall(construction.node)) {
@@ -2448,7 +2452,7 @@ var no_unstable_default_props_default = createRule({
2448
2452
  },
2449
2453
  "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node) {
2450
2454
  const functionEntry = ctx.getCurrentEntry();
2451
- if (!functionEntry) return;
2455
+ if (functionEntry == null) return;
2452
2456
  const prevs = declarators.get(functionEntry.node) ?? [];
2453
2457
  declarators.set(functionEntry.node, [...prevs, node]);
2454
2458
  }
@@ -2676,8 +2680,8 @@ var no_unused_state_default = createRule({
2676
2680
  return;
2677
2681
  }
2678
2682
  const className = AST11.getClassIdentifier(currentClass)?.name;
2679
- const { node: defNode, isUsed } = stateDefs.get(currentClass) ?? {};
2680
- if (!defNode || isUsed) {
2683
+ const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
2684
+ if (defNode == null || isUsed) {
2681
2685
  return;
2682
2686
  }
2683
2687
  context.report({
@@ -2920,7 +2924,7 @@ var prefer_destructuring_assignment_default = createRule({
2920
2924
  return false;
2921
2925
  }
2922
2926
  const id = AST11.getFunctionIdentifier(block);
2923
- return !!id && isComponentName(id.name) && components.some((component) => component.node === block);
2927
+ return id != null && isComponentName(id.name) && components.some((component) => component.node === block);
2924
2928
  }
2925
2929
  for (const [initialScope, memberExpression] of memberExpressionWithNames) {
2926
2930
  let scope = initialScope;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.24.0-next.0",
3
+ "version": "1.24.0-next.2",
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,17 +48,17 @@
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-next.0",
52
- "@eslint-react/core": "1.24.0-next.0",
53
- "@eslint-react/eff": "1.24.0-next.0",
54
- "@eslint-react/shared": "1.24.0-next.0",
55
- "@eslint-react/jsx": "1.24.0-next.0",
56
- "@eslint-react/types": "1.24.0-next.0",
57
- "@eslint-react/var": "1.24.0-next.0"
51
+ "@eslint-react/ast": "1.24.0-next.2",
52
+ "@eslint-react/core": "1.24.0-next.2",
53
+ "@eslint-react/eff": "1.24.0-next.2",
54
+ "@eslint-react/jsx": "1.24.0-next.2",
55
+ "@eslint-react/shared": "1.24.0-next.2",
56
+ "@eslint-react/var": "1.24.0-next.2",
57
+ "@eslint-react/types": "1.24.0-next.2"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/react": "^19.0.4",
61
- "@types/react-dom": "^19.0.2",
60
+ "@types/react": "^19.0.6",
61
+ "@types/react-dom": "^19.0.3",
62
62
  "ts-api-utils": "^2.0.0",
63
63
  "tsup": "^8.3.5",
64
64
  "@workspace/configs": "0.0.0"