eslint-plugin-react-hooks-extra 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 +15 -21
  2. package/dist/index.mjs +15 -21
  3. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var VAR5__namespace = /*#__PURE__*/_interopNamespace(VAR5);
31
31
 
32
32
  // package.json
33
33
  var name = "eslint-plugin-react-hooks-extra";
34
- var version = "1.24.0-next.0";
34
+ var version = "1.24.0-next.2";
35
35
  var createRule = shared.createRuleForPlugin("hooks-extra");
36
36
  function isFromHookCall(name2, context, settings, predicate = eff.returnTrue) {
37
37
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -203,13 +203,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
203
203
  CallExpression(node) {
204
204
  const setupFunction = setupFunctionRef.current;
205
205
  const pEntry = functionEntries.at(-1);
206
- if (pEntry?.node.async) {
206
+ if (pEntry == null || pEntry.node.async) {
207
207
  return;
208
208
  }
209
209
  tsPattern.match(getCallKind(node)).with("setState", () => {
210
- if (pEntry == null) {
211
- return;
212
- }
213
210
  switch (true) {
214
211
  case (pEntry.node === setupFunction || pEntry.kind === "immediate"): {
215
212
  context.report({
@@ -222,8 +219,8 @@ var no_direct_set_state_in_use_effect_default = createRule({
222
219
  return;
223
220
  }
224
221
  default: {
225
- const variableDeclarator = AST__namespace.findParentNodeGuard(node, isVariableDeclaratorFromHookCall);
226
- if (variableDeclarator === eff._) {
222
+ const variableDeclarator = AST__namespace.findParentNode(node, isVariableDeclaratorFromHookCall);
223
+ if (variableDeclarator == null) {
227
224
  const calls = indSetStateCalls.get(pEntry.node) ?? [];
228
225
  indSetStateCalls.set(pEntry.node, [...calls, node]);
229
226
  return;
@@ -239,7 +236,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
239
236
  }
240
237
  setupFunctionIdentifiers.push(...AST__namespace.getNestedIdentifiers(node));
241
238
  }).with("other", () => {
242
- if (pEntry?.node !== setupFunction) {
239
+ if (pEntry.node !== setupFunction) {
243
240
  return;
244
241
  }
245
242
  indFunctionCalls.push(node);
@@ -261,7 +258,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
261
258
  if (!isUseMemoCall2(parent)) {
262
259
  break;
263
260
  }
264
- const variableDeclarator = AST__namespace.findParentNodeGuard(parent, isVariableDeclaratorFromHookCall);
261
+ const variableDeclarator = AST__namespace.findParentNode(parent, isVariableDeclaratorFromHookCall);
265
262
  if (variableDeclarator == null) {
266
263
  break;
267
264
  }
@@ -274,7 +271,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
274
271
  break;
275
272
  }
276
273
  if (isUseCallbackCall2(node.parent)) {
277
- const variableDeclarator = AST__namespace.findParentNodeGuard(node.parent, isVariableDeclaratorFromHookCall);
274
+ const variableDeclarator = AST__namespace.findParentNode(node.parent, isVariableDeclaratorFromHookCall);
278
275
  if (variableDeclarator == null) {
279
276
  break;
280
277
  }
@@ -420,13 +417,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
420
417
  CallExpression(node) {
421
418
  const setupFunction = setupFunctionRef.current;
422
419
  const pEntry = functionEntries.at(-1);
423
- if (pEntry?.node.async) {
420
+ if (pEntry == null || pEntry.node.async) {
424
421
  return;
425
422
  }
426
423
  tsPattern.match(getCallKind(node)).with("setState", () => {
427
- if (pEntry == null) {
428
- return;
429
- }
430
424
  switch (true) {
431
425
  case (pEntry.node === setupFunction || pEntry.kind === "immediate"): {
432
426
  context.report({
@@ -439,8 +433,8 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
439
433
  return;
440
434
  }
441
435
  default: {
442
- const variableDeclarator = AST__namespace.findParentNodeGuard(node, isVariableDeclaratorFromHookCall);
443
- if (variableDeclarator === eff._) {
436
+ const variableDeclarator = AST__namespace.findParentNode(node, isVariableDeclaratorFromHookCall);
437
+ if (variableDeclarator == null) {
444
438
  const calls = indSetStateCalls.get(pEntry.node) ?? [];
445
439
  indSetStateCalls.set(pEntry.node, [...calls, node]);
446
440
  return;
@@ -456,7 +450,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
456
450
  }
457
451
  setupFunctionIdentifiers.push(...AST__namespace.getNestedIdentifiers(node));
458
452
  }).with("other", () => {
459
- if (pEntry?.node !== setupFunction) {
453
+ if (pEntry.node !== setupFunction) {
460
454
  return;
461
455
  }
462
456
  indFunctionCalls.push(node);
@@ -478,7 +472,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
478
472
  if (!isUseMemoCall2(parent)) {
479
473
  break;
480
474
  }
481
- const variableDeclarator = AST__namespace.findParentNodeGuard(parent, isVariableDeclaratorFromHookCall);
475
+ const variableDeclarator = AST__namespace.findParentNode(parent, isVariableDeclaratorFromHookCall);
482
476
  if (variableDeclarator == null) {
483
477
  break;
484
478
  }
@@ -491,7 +485,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
491
485
  break;
492
486
  }
493
487
  if (isUseCallbackCall2(node.parent)) {
494
- const variableDeclarator = AST__namespace.findParentNodeGuard(node.parent, isVariableDeclaratorFromHookCall);
488
+ const variableDeclarator = AST__namespace.findParentNode(node.parent, isVariableDeclaratorFromHookCall);
495
489
  if (variableDeclarator == null) {
496
490
  break;
497
491
  }
@@ -625,7 +619,7 @@ var no_unnecessary_use_callback_default = createRule({
625
619
  }
626
620
  return variableNode;
627
621
  }).otherwise(() => eff._);
628
- if (arg0Node === eff._) return;
622
+ if (arg0Node == null) return;
629
623
  const arg0NodeScope = context.sourceCode.getScope(arg0Node);
630
624
  const arg0NodeReferences = VAR5__namespace.getChidScopes(arg0NodeScope).flatMap((x) => x.references);
631
625
  const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
@@ -708,7 +702,7 @@ var no_unnecessary_use_memo_default = createRule({
708
702
  }
709
703
  return variableNode;
710
704
  }).otherwise(() => eff._);
711
- if (arg0Node === eff._) return;
705
+ if (arg0Node == null) return;
712
706
  const arg0NodeScope = context.sourceCode.getScope(arg0Node);
713
707
  const arg0NodeReferences = VAR5__namespace.getChidScopes(arg0NodeScope).flatMap((x) => x.references);
714
708
  const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { match } from 'ts-pattern';
8
8
 
9
9
  // package.json
10
10
  var name = "eslint-plugin-react-hooks-extra";
11
- var version = "1.24.0-next.0";
11
+ var version = "1.24.0-next.2";
12
12
  var createRule = createRuleForPlugin("hooks-extra");
13
13
  function isFromHookCall(name2, context, settings, predicate = returnTrue) {
14
14
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -180,13 +180,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
180
180
  CallExpression(node) {
181
181
  const setupFunction = setupFunctionRef.current;
182
182
  const pEntry = functionEntries.at(-1);
183
- if (pEntry?.node.async) {
183
+ if (pEntry == null || pEntry.node.async) {
184
184
  return;
185
185
  }
186
186
  match(getCallKind(node)).with("setState", () => {
187
- if (pEntry == null) {
188
- return;
189
- }
190
187
  switch (true) {
191
188
  case (pEntry.node === setupFunction || pEntry.kind === "immediate"): {
192
189
  context.report({
@@ -199,8 +196,8 @@ var no_direct_set_state_in_use_effect_default = createRule({
199
196
  return;
200
197
  }
201
198
  default: {
202
- const variableDeclarator = AST.findParentNodeGuard(node, isVariableDeclaratorFromHookCall);
203
- if (variableDeclarator === _) {
199
+ const variableDeclarator = AST.findParentNode(node, isVariableDeclaratorFromHookCall);
200
+ if (variableDeclarator == null) {
204
201
  const calls = indSetStateCalls.get(pEntry.node) ?? [];
205
202
  indSetStateCalls.set(pEntry.node, [...calls, node]);
206
203
  return;
@@ -216,7 +213,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
216
213
  }
217
214
  setupFunctionIdentifiers.push(...AST.getNestedIdentifiers(node));
218
215
  }).with("other", () => {
219
- if (pEntry?.node !== setupFunction) {
216
+ if (pEntry.node !== setupFunction) {
220
217
  return;
221
218
  }
222
219
  indFunctionCalls.push(node);
@@ -238,7 +235,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
238
235
  if (!isUseMemoCall2(parent)) {
239
236
  break;
240
237
  }
241
- const variableDeclarator = AST.findParentNodeGuard(parent, isVariableDeclaratorFromHookCall);
238
+ const variableDeclarator = AST.findParentNode(parent, isVariableDeclaratorFromHookCall);
242
239
  if (variableDeclarator == null) {
243
240
  break;
244
241
  }
@@ -251,7 +248,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
251
248
  break;
252
249
  }
253
250
  if (isUseCallbackCall2(node.parent)) {
254
- const variableDeclarator = AST.findParentNodeGuard(node.parent, isVariableDeclaratorFromHookCall);
251
+ const variableDeclarator = AST.findParentNode(node.parent, isVariableDeclaratorFromHookCall);
255
252
  if (variableDeclarator == null) {
256
253
  break;
257
254
  }
@@ -397,13 +394,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
397
394
  CallExpression(node) {
398
395
  const setupFunction = setupFunctionRef.current;
399
396
  const pEntry = functionEntries.at(-1);
400
- if (pEntry?.node.async) {
397
+ if (pEntry == null || pEntry.node.async) {
401
398
  return;
402
399
  }
403
400
  match(getCallKind(node)).with("setState", () => {
404
- if (pEntry == null) {
405
- return;
406
- }
407
401
  switch (true) {
408
402
  case (pEntry.node === setupFunction || pEntry.kind === "immediate"): {
409
403
  context.report({
@@ -416,8 +410,8 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
416
410
  return;
417
411
  }
418
412
  default: {
419
- const variableDeclarator = AST.findParentNodeGuard(node, isVariableDeclaratorFromHookCall);
420
- if (variableDeclarator === _) {
413
+ const variableDeclarator = AST.findParentNode(node, isVariableDeclaratorFromHookCall);
414
+ if (variableDeclarator == null) {
421
415
  const calls = indSetStateCalls.get(pEntry.node) ?? [];
422
416
  indSetStateCalls.set(pEntry.node, [...calls, node]);
423
417
  return;
@@ -433,7 +427,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
433
427
  }
434
428
  setupFunctionIdentifiers.push(...AST.getNestedIdentifiers(node));
435
429
  }).with("other", () => {
436
- if (pEntry?.node !== setupFunction) {
430
+ if (pEntry.node !== setupFunction) {
437
431
  return;
438
432
  }
439
433
  indFunctionCalls.push(node);
@@ -455,7 +449,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
455
449
  if (!isUseMemoCall2(parent)) {
456
450
  break;
457
451
  }
458
- const variableDeclarator = AST.findParentNodeGuard(parent, isVariableDeclaratorFromHookCall);
452
+ const variableDeclarator = AST.findParentNode(parent, isVariableDeclaratorFromHookCall);
459
453
  if (variableDeclarator == null) {
460
454
  break;
461
455
  }
@@ -468,7 +462,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
468
462
  break;
469
463
  }
470
464
  if (isUseCallbackCall2(node.parent)) {
471
- const variableDeclarator = AST.findParentNodeGuard(node.parent, isVariableDeclaratorFromHookCall);
465
+ const variableDeclarator = AST.findParentNode(node.parent, isVariableDeclaratorFromHookCall);
472
466
  if (variableDeclarator == null) {
473
467
  break;
474
468
  }
@@ -602,7 +596,7 @@ var no_unnecessary_use_callback_default = createRule({
602
596
  }
603
597
  return variableNode;
604
598
  }).otherwise(() => _);
605
- if (arg0Node === _) return;
599
+ if (arg0Node == null) return;
606
600
  const arg0NodeScope = context.sourceCode.getScope(arg0Node);
607
601
  const arg0NodeReferences = VAR5.getChidScopes(arg0NodeScope).flatMap((x) => x.references);
608
602
  const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
@@ -685,7 +679,7 @@ var no_unnecessary_use_memo_default = createRule({
685
679
  }
686
680
  return variableNode;
687
681
  }).otherwise(() => _);
688
- if (arg0Node === _) return;
682
+ if (arg0Node == null) return;
689
683
  const arg0NodeScope = context.sourceCode.getScope(arg0Node);
690
684
  const arg0NodeReferences = VAR5.getChidScopes(arg0NodeScope).flatMap((x) => x.references);
691
685
  const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "1.24.0-next.0",
3
+ "version": "1.24.0-next.2",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -48,17 +48,17 @@
48
48
  "@typescript-eslint/utils": "^8.19.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/eff": "1.24.0-next.0",
53
- "@eslint-react/core": "1.24.0-next.0",
54
- "@eslint-react/jsx": "1.24.0-next.0",
55
- "@eslint-react/shared": "1.24.0-next.0",
56
- "@eslint-react/var": "1.24.0-next.0",
57
- "@eslint-react/types": "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/jsx": "1.24.0-next.2",
54
+ "@eslint-react/eff": "1.24.0-next.2",
55
+ "@eslint-react/shared": "1.24.0-next.2",
56
+ "@eslint-react/types": "1.24.0-next.2",
57
+ "@eslint-react/var": "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
  "tsup": "^8.3.5",
63
63
  "@workspace/configs": "0.0.0"
64
64
  },