eslint-plugin-react-hooks-extra 1.8.3-next.1 → 1.8.3-next.3

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-next.1";
33
+ var version = "1.8.3-next.3";
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] ?? [];
@@ -43,11 +43,12 @@ function isFromHookCall(name2, context, settings, predicate = tools.F.constTrue)
43
43
  );
44
44
  }
45
45
  function isFromUseStateCall(context, settings) {
46
- return (toplevelId) => isFromHookCall("useState", context, settings, (topLevelId, call) => {
46
+ const predicate = (topLevelId, call) => {
47
47
  const { parent } = call;
48
48
  if (!("id" in parent && parent.id?.type === ast.NodeType.ArrayPattern)) return true;
49
49
  return parent.id.elements.findIndex((e2) => e2?.type === ast.NodeType.Identifier && e2.name === topLevelId.name) === 1;
50
- })(toplevelId);
50
+ };
51
+ return isFromHookCall("useState", context, settings, predicate);
51
52
  }
52
53
 
53
54
  // ../../../node_modules/.pnpm/ts-pattern@5.2.0/node_modules/ts-pattern/dist/index.js
@@ -529,13 +530,12 @@ var no_direct_set_state_in_use_effect_default = createRule({
529
530
  ":function"(node) {
530
531
  const functionKind = getFunctionKind(node);
531
532
  functionStack.push([node, functionKind]);
532
- $(functionKind).with("effect", () => {
533
- onEffectFunctionEnter(node);
534
- }).otherwise(tools.F.constVoid);
533
+ if (functionKind === "effect") onEffectFunctionEnter(node);
535
534
  },
536
535
  ":function:exit"(node) {
537
- onEffectFunctionExit(node);
536
+ const [_2, functionKind] = R__namespace.last(functionStack) ?? [];
538
537
  functionStack.pop();
538
+ if (functionKind === "effect") onEffectFunctionExit(node);
539
539
  },
540
540
  CallExpression(node) {
541
541
  const effectFn = tools.MutRef.get(effectFunctionRef);
@@ -705,13 +705,12 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
705
705
  ":function"(node) {
706
706
  const functionKind = getFunctionKind(node);
707
707
  functionStack.push([node, functionKind]);
708
- $(functionKind).with("effect", () => {
709
- onEffectFunctionEnter(node);
710
- }).otherwise(tools.F.constVoid);
708
+ if (functionKind === "effect") onEffectFunctionEnter(node);
711
709
  },
712
710
  ":function:exit"(node) {
713
- onEffectFunctionExit(node);
711
+ const [_2, functionKind] = R__namespace.last(functionStack) ?? [];
714
712
  functionStack.pop();
713
+ if (functionKind === "effect") onEffectFunctionExit(node);
715
714
  },
716
715
  CallExpression(node) {
717
716
  const effectFn = tools.MutRef.get(effectFunctionRef);
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-next.1";
11
+ var version = "1.8.3-next.3";
12
12
  var createRule = createRuleForPlugin("hooks-extra");
13
13
  function isFromHookCall(name2, context, settings, predicate = F.constTrue) {
14
14
  const hookAlias = settings.additionalHooks?.[name2] ?? [];
@@ -21,11 +21,12 @@ function isFromHookCall(name2, context, settings, predicate = F.constTrue) {
21
21
  );
22
22
  }
23
23
  function isFromUseStateCall(context, settings) {
24
- return (toplevelId) => isFromHookCall("useState", context, settings, (topLevelId, call) => {
24
+ const predicate = (topLevelId, call) => {
25
25
  const { parent } = call;
26
26
  if (!("id" in parent && parent.id?.type === NodeType.ArrayPattern)) return true;
27
27
  return parent.id.elements.findIndex((e2) => e2?.type === NodeType.Identifier && e2.name === topLevelId.name) === 1;
28
- })(toplevelId);
28
+ };
29
+ return isFromHookCall("useState", context, settings, predicate);
29
30
  }
30
31
 
31
32
  // ../../../node_modules/.pnpm/ts-pattern@5.2.0/node_modules/ts-pattern/dist/index.js
@@ -507,13 +508,12 @@ var no_direct_set_state_in_use_effect_default = createRule({
507
508
  ":function"(node) {
508
509
  const functionKind = getFunctionKind(node);
509
510
  functionStack.push([node, functionKind]);
510
- $(functionKind).with("effect", () => {
511
- onEffectFunctionEnter(node);
512
- }).otherwise(F.constVoid);
511
+ if (functionKind === "effect") onEffectFunctionEnter(node);
513
512
  },
514
513
  ":function:exit"(node) {
515
- onEffectFunctionExit(node);
514
+ const [_2, functionKind] = R.last(functionStack) ?? [];
516
515
  functionStack.pop();
516
+ if (functionKind === "effect") onEffectFunctionExit(node);
517
517
  },
518
518
  CallExpression(node) {
519
519
  const effectFn = MutRef.get(effectFunctionRef);
@@ -683,13 +683,12 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
683
683
  ":function"(node) {
684
684
  const functionKind = getFunctionKind(node);
685
685
  functionStack.push([node, functionKind]);
686
- $(functionKind).with("effect", () => {
687
- onEffectFunctionEnter(node);
688
- }).otherwise(F.constVoid);
686
+ if (functionKind === "effect") onEffectFunctionEnter(node);
689
687
  },
690
688
  ":function:exit"(node) {
691
- onEffectFunctionExit(node);
689
+ const [_2, functionKind] = R.last(functionStack) ?? [];
692
690
  functionStack.pop();
691
+ if (functionKind === "effect") onEffectFunctionExit(node);
693
692
  },
694
693
  CallExpression(node) {
695
694
  const effectFn = MutRef.get(effectFunctionRef);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-hooks-extra",
3
- "version": "1.8.3-next.1",
3
+ "version": "1.8.3-next.3",
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-next.1",
50
- "@eslint-react/core": "1.8.3-next.1",
51
- "@eslint-react/shared": "1.8.3-next.1",
52
- "@eslint-react/jsx": "1.8.3-next.1",
53
- "@eslint-react/tools": "1.8.3-next.1",
54
- "@eslint-react/var": "1.8.3-next.1",
55
- "@eslint-react/types": "1.8.3-next.1"
49
+ "@eslint-react/ast": "1.8.3-next.3",
50
+ "@eslint-react/jsx": "1.8.3-next.3",
51
+ "@eslint-react/shared": "1.8.3-next.3",
52
+ "@eslint-react/core": "1.8.3-next.3",
53
+ "@eslint-react/types": "1.8.3-next.3",
54
+ "@eslint-react/tools": "1.8.3-next.3",
55
+ "@eslint-react/var": "1.8.3-next.3"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/react": "^18.3.3",