eslint-plugin-react-hooks-extra 1.8.3-beta.2 → 1.8.3-beta.6

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
@@ -30,7 +30,7 @@ var R__namespace = /*#__PURE__*/_interopNamespace(R);
30
30
 
31
31
  // package.json
32
32
  var name = "eslint-plugin-react-hooks-extra";
33
- var version = "1.8.3-beta.2";
33
+ var version = "1.8.3-beta.6";
34
34
  var createRule = shared.createRuleForPlugin("hooks-extra");
35
35
  function isFromHookCall(name2, context, settings, predicate = tools.F.constTrue) {
36
36
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -284,7 +284,7 @@ function isVariableDeclaratorFromHookCall(node) {
284
284
  case ast.NodeType.Identifier:
285
285
  return core.isReactHookName(node.init.callee.name);
286
286
  case ast.NodeType.MemberExpression:
287
- return node.init.callee.property?.type === ast.NodeType.Identifier && core.isReactHookName(node.init.callee.property.name);
287
+ return node.init.callee.property.type === ast.NodeType.Identifier && core.isReactHookName(node.init.callee.property.name);
288
288
  default:
289
289
  return false;
290
290
  }
@@ -339,7 +339,7 @@ var ensure_use_callback_has_non_empty_deps_default = createRule({
339
339
  },
340
340
  name: RULE_NAME2,
341
341
  create(context) {
342
- const alias = shared.decodeSettings(context.settings)?.additionalHooks?.useCallback ?? [];
342
+ const alias = shared.decodeSettings(context.settings).additionalHooks?.useCallback ?? [];
343
343
  return {
344
344
  CallExpression(node) {
345
345
  if (!core.isReactHookCall(node)) return;
@@ -417,7 +417,7 @@ var ensure_use_memo_has_non_empty_deps_default = createRule({
417
417
  },
418
418
  name: RULE_NAME3,
419
419
  create(context) {
420
- const alias = shared.decodeSettings(context.settings)?.additionalHooks?.useMemo ?? [];
420
+ const alias = shared.decodeSettings(context.settings).additionalHooks?.useMemo ?? [];
421
421
  return {
422
422
  CallExpression(node) {
423
423
  if (!core.isReactHookCall(node)) return;
@@ -530,13 +530,12 @@ var no_direct_set_state_in_use_effect_default = createRule({
530
530
  ":function"(node) {
531
531
  const functionKind = getFunctionKind(node);
532
532
  functionStack.push([node, functionKind]);
533
- $(functionKind).with("effect", () => {
534
- onEffectFunctionEnter(node);
535
- }).otherwise(tools.F.constVoid);
533
+ if (functionKind === "effect") onEffectFunctionEnter(node);
536
534
  },
537
535
  ":function:exit"(node) {
538
- onEffectFunctionExit(node);
536
+ const [_2, functionKind] = R__namespace.last(functionStack) ?? [];
539
537
  functionStack.pop();
538
+ if (functionKind === "effect") onEffectFunctionExit(node);
540
539
  },
541
540
  CallExpression(node) {
542
541
  const effectFn = tools.MutRef.get(effectFunctionRef);
@@ -572,7 +571,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
572
571
  }).otherwise(tools.F.constVoid);
573
572
  },
574
573
  Identifier(node) {
575
- if (!node.parent) return;
576
574
  if (node.parent.type === ast.NodeType.CallExpression && node.parent.callee === node) return;
577
575
  if (!isIdFromUseStateCall(node)) return;
578
576
  switch (node.parent.type) {
@@ -594,7 +592,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
594
592
  }
595
593
  case ast.NodeType.ArrowFunctionExpression: {
596
594
  const parent = node.parent.parent;
597
- if (parent?.type !== ast.NodeType.CallExpression) break;
595
+ if (parent.type !== ast.NodeType.CallExpression) break;
598
596
  if (!isUseMemoCall2(parent)) break;
599
597
  const maybeVd = ast.traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
600
598
  if (tools.O.isNone(maybeVd)) break;
@@ -706,13 +704,12 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
706
704
  ":function"(node) {
707
705
  const functionKind = getFunctionKind(node);
708
706
  functionStack.push([node, functionKind]);
709
- $(functionKind).with("effect", () => {
710
- onEffectFunctionEnter(node);
711
- }).otherwise(tools.F.constVoid);
707
+ if (functionKind === "effect") onEffectFunctionEnter(node);
712
708
  },
713
709
  ":function:exit"(node) {
714
- onEffectFunctionExit(node);
710
+ const [_2, functionKind] = R__namespace.last(functionStack) ?? [];
715
711
  functionStack.pop();
712
+ if (functionKind === "effect") onEffectFunctionExit(node);
716
713
  },
717
714
  CallExpression(node) {
718
715
  const effectFn = tools.MutRef.get(effectFunctionRef);
@@ -748,7 +745,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
748
745
  }).otherwise(tools.F.constVoid);
749
746
  },
750
747
  Identifier(node) {
751
- if (!node.parent) return;
752
748
  if (node.parent.type === ast.NodeType.CallExpression && node.parent.callee === node) return;
753
749
  if (!isIdFromUseStateCall(node)) return;
754
750
  switch (node.parent.type) {
@@ -770,7 +766,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
770
766
  }
771
767
  case ast.NodeType.ArrowFunctionExpression: {
772
768
  const parent = node.parent.parent;
773
- if (parent?.type !== ast.NodeType.CallExpression) break;
769
+ if (parent.type !== ast.NodeType.CallExpression) break;
774
770
  if (!isUseMemoCall2(parent)) break;
775
771
  const maybeVd = ast.traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
776
772
  if (tools.O.isNone(maybeVd)) break;
@@ -844,7 +840,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
844
840
  },
845
841
  name: RULE_NAME6,
846
842
  create(context) {
847
- const alias = shared.decodeSettings(context.settings)?.additionalHooks?.useState ?? [];
843
+ const alias = shared.decodeSettings(context.settings).additionalHooks?.useState ?? [];
848
844
  return {
849
845
  CallExpression(node) {
850
846
  if (!core.isReactHookCall(node)) return;
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import * as R from 'remeda';
8
8
 
9
9
  // package.json
10
10
  var name = "eslint-plugin-react-hooks-extra";
11
- var version = "1.8.3-beta.2";
11
+ var version = "1.8.3-beta.6";
12
12
  var createRule = createRuleForPlugin("hooks-extra");
13
13
  function isFromHookCall(name2, context, settings, predicate = F.constTrue) {
14
14
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -262,7 +262,7 @@ function isVariableDeclaratorFromHookCall(node) {
262
262
  case NodeType.Identifier:
263
263
  return isReactHookName(node.init.callee.name);
264
264
  case NodeType.MemberExpression:
265
- return node.init.callee.property?.type === NodeType.Identifier && isReactHookName(node.init.callee.property.name);
265
+ return node.init.callee.property.type === NodeType.Identifier && isReactHookName(node.init.callee.property.name);
266
266
  default:
267
267
  return false;
268
268
  }
@@ -317,7 +317,7 @@ var ensure_use_callback_has_non_empty_deps_default = createRule({
317
317
  },
318
318
  name: RULE_NAME2,
319
319
  create(context) {
320
- const alias = decodeSettings(context.settings)?.additionalHooks?.useCallback ?? [];
320
+ const alias = decodeSettings(context.settings).additionalHooks?.useCallback ?? [];
321
321
  return {
322
322
  CallExpression(node) {
323
323
  if (!isReactHookCall(node)) return;
@@ -395,7 +395,7 @@ var ensure_use_memo_has_non_empty_deps_default = createRule({
395
395
  },
396
396
  name: RULE_NAME3,
397
397
  create(context) {
398
- const alias = decodeSettings(context.settings)?.additionalHooks?.useMemo ?? [];
398
+ const alias = decodeSettings(context.settings).additionalHooks?.useMemo ?? [];
399
399
  return {
400
400
  CallExpression(node) {
401
401
  if (!isReactHookCall(node)) return;
@@ -508,13 +508,12 @@ var no_direct_set_state_in_use_effect_default = createRule({
508
508
  ":function"(node) {
509
509
  const functionKind = getFunctionKind(node);
510
510
  functionStack.push([node, functionKind]);
511
- $(functionKind).with("effect", () => {
512
- onEffectFunctionEnter(node);
513
- }).otherwise(F.constVoid);
511
+ if (functionKind === "effect") onEffectFunctionEnter(node);
514
512
  },
515
513
  ":function:exit"(node) {
516
- onEffectFunctionExit(node);
514
+ const [_2, functionKind] = R.last(functionStack) ?? [];
517
515
  functionStack.pop();
516
+ if (functionKind === "effect") onEffectFunctionExit(node);
518
517
  },
519
518
  CallExpression(node) {
520
519
  const effectFn = MutRef.get(effectFunctionRef);
@@ -550,7 +549,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
550
549
  }).otherwise(F.constVoid);
551
550
  },
552
551
  Identifier(node) {
553
- if (!node.parent) return;
554
552
  if (node.parent.type === NodeType.CallExpression && node.parent.callee === node) return;
555
553
  if (!isIdFromUseStateCall(node)) return;
556
554
  switch (node.parent.type) {
@@ -572,7 +570,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
572
570
  }
573
571
  case NodeType.ArrowFunctionExpression: {
574
572
  const parent = node.parent.parent;
575
- if (parent?.type !== NodeType.CallExpression) break;
573
+ if (parent.type !== NodeType.CallExpression) break;
576
574
  if (!isUseMemoCall2(parent)) break;
577
575
  const maybeVd = traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
578
576
  if (O.isNone(maybeVd)) break;
@@ -684,13 +682,12 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
684
682
  ":function"(node) {
685
683
  const functionKind = getFunctionKind(node);
686
684
  functionStack.push([node, functionKind]);
687
- $(functionKind).with("effect", () => {
688
- onEffectFunctionEnter(node);
689
- }).otherwise(F.constVoid);
685
+ if (functionKind === "effect") onEffectFunctionEnter(node);
690
686
  },
691
687
  ":function:exit"(node) {
692
- onEffectFunctionExit(node);
688
+ const [_2, functionKind] = R.last(functionStack) ?? [];
693
689
  functionStack.pop();
690
+ if (functionKind === "effect") onEffectFunctionExit(node);
694
691
  },
695
692
  CallExpression(node) {
696
693
  const effectFn = MutRef.get(effectFunctionRef);
@@ -726,7 +723,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
726
723
  }).otherwise(F.constVoid);
727
724
  },
728
725
  Identifier(node) {
729
- if (!node.parent) return;
730
726
  if (node.parent.type === NodeType.CallExpression && node.parent.callee === node) return;
731
727
  if (!isIdFromUseStateCall(node)) return;
732
728
  switch (node.parent.type) {
@@ -748,7 +744,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
748
744
  }
749
745
  case NodeType.ArrowFunctionExpression: {
750
746
  const parent = node.parent.parent;
751
- if (parent?.type !== NodeType.CallExpression) break;
747
+ if (parent.type !== NodeType.CallExpression) break;
752
748
  if (!isUseMemoCall2(parent)) break;
753
749
  const maybeVd = traverseUpGuard(parent, isVariableDeclaratorFromHookCall);
754
750
  if (O.isNone(maybeVd)) break;
@@ -822,7 +818,7 @@ var prefer_use_state_lazy_initialization_default = createRule({
822
818
  },
823
819
  name: RULE_NAME6,
824
820
  create(context) {
825
- const alias = decodeSettings(context.settings)?.additionalHooks?.useState ?? [];
821
+ const alias = decodeSettings(context.settings).additionalHooks?.useState ?? [];
826
822
  return {
827
823
  CallExpression(node) {
828
824
  if (!isReactHookCall(node)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "1.8.3-beta.2",
3
+ "version": "1.8.3-beta.6",
4
4
  "description": "ESLint React's ESLint plugin for React Hooks related rules.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -46,13 +46,13 @@
46
46
  "@typescript-eslint/types": "^8.0.0",
47
47
  "@typescript-eslint/utils": "^8.0.0",
48
48
  "remeda": "^2.7.0",
49
- "@eslint-react/ast": "1.8.3-beta.2",
50
- "@eslint-react/jsx": "1.8.3-beta.2",
51
- "@eslint-react/shared": "1.8.3-beta.2",
52
- "@eslint-react/core": "1.8.3-beta.2",
53
- "@eslint-react/types": "1.8.3-beta.2",
54
- "@eslint-react/var": "1.8.3-beta.2",
55
- "@eslint-react/tools": "1.8.3-beta.2"
49
+ "@eslint-react/ast": "1.8.3-beta.6",
50
+ "@eslint-react/core": "1.8.3-beta.6",
51
+ "@eslint-react/shared": "1.8.3-beta.6",
52
+ "@eslint-react/jsx": "1.8.3-beta.6",
53
+ "@eslint-react/tools": "1.8.3-beta.6",
54
+ "@eslint-react/types": "1.8.3-beta.6",
55
+ "@eslint-react/var": "1.8.3-beta.6"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/react": "^18.3.3",