eslint-plugin-react-hooks-extra 1.5.28-beta.2 → 1.5.28-beta.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 +7 -25
- package/dist/index.mjs +7 -25
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var astUtils = require('@typescript-eslint/utils/ast-utils');
|
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
11
|
var name = "eslint-plugin-react-hooks-extra";
|
|
12
|
-
var version = "1.5.28-beta.
|
|
12
|
+
var version = "1.5.28-beta.3";
|
|
13
13
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
14
14
|
|
|
15
15
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -467,14 +467,11 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
467
467
|
return $(node).when(isEffectFunction, () => "effect").when(isCleanUpFunction, () => "cleanup").when(ast.isIIFE, () => "immediate").otherwise(() => "other");
|
|
468
468
|
}
|
|
469
469
|
const useEffectCallRef = tools.MutRef.make(null);
|
|
470
|
-
const callStack = tools.MutList.make();
|
|
471
470
|
const functionStack = tools.MutList.make();
|
|
472
471
|
const effectFunctionRef = tools.MutRef.make(null);
|
|
473
472
|
const cleanUpFunctionRef = tools.MutRef.make(null);
|
|
474
473
|
const indirectFunctionCalls = [];
|
|
475
474
|
const indirectSetStateCalls = /* @__PURE__ */ new Map();
|
|
476
|
-
const onUseEffectCallEnter = (node) => void tools.MutRef.set(useEffectCallRef, node);
|
|
477
|
-
const onUseEffectCallExit = () => void tools.MutRef.set(useEffectCallRef, null);
|
|
478
475
|
return {
|
|
479
476
|
Identifier(node) {
|
|
480
477
|
const isInUseEffectCall = tools.MutRef.get(useEffectCallRef) !== null;
|
|
@@ -489,7 +486,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
489
486
|
}
|
|
490
487
|
},
|
|
491
488
|
CallExpression(node) {
|
|
492
|
-
tools.MutList.append(callStack, node);
|
|
493
489
|
const effectFn = tools.MutRef.get(effectFunctionRef);
|
|
494
490
|
const [parentFn, parentFnKind] = tools.MutList.tail(functionStack) ?? [];
|
|
495
491
|
if (parentFn?.async) return;
|
|
@@ -505,12 +501,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
505
501
|
messageId: "NO_DIRECT_SET_STATE_IN_USE_EFFECT"
|
|
506
502
|
});
|
|
507
503
|
}).with("useEffect", () => {
|
|
508
|
-
|
|
509
|
-
}).with("useState", () => {
|
|
510
|
-
}).with("then", () => {
|
|
504
|
+
tools.MutRef.set(useEffectCallRef, node);
|
|
511
505
|
}).with("other", () => {
|
|
512
506
|
indirectFunctionCalls.push(node);
|
|
513
|
-
}).
|
|
507
|
+
}).otherwise(tools.F.constVoid);
|
|
514
508
|
},
|
|
515
509
|
":function"(node) {
|
|
516
510
|
const functionKind = getFunctionKind(node);
|
|
@@ -519,8 +513,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
519
513
|
tools.MutRef.set(effectFunctionRef, node);
|
|
520
514
|
}).with("cleanup", () => {
|
|
521
515
|
tools.MutRef.set(cleanUpFunctionRef, node);
|
|
522
|
-
}).otherwise(
|
|
523
|
-
});
|
|
516
|
+
}).otherwise(tools.F.constVoid);
|
|
524
517
|
},
|
|
525
518
|
":function:exit"(node) {
|
|
526
519
|
const effectFn = tools.MutRef.get(effectFunctionRef);
|
|
@@ -530,9 +523,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
530
523
|
tools.MutList.pop(functionStack);
|
|
531
524
|
},
|
|
532
525
|
"CallExpression:exit"(node) {
|
|
533
|
-
tools.MutList.pop(callStack);
|
|
534
526
|
if (tools.MutRef.get(useEffectCallRef) === node) {
|
|
535
|
-
onUseEffectCallExit();
|
|
536
527
|
tools.MutRef.set(useEffectCallRef, null);
|
|
537
528
|
}
|
|
538
529
|
},
|
|
@@ -641,14 +632,11 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
641
632
|
return $(node).when(isEffectFunction, () => "effect").when(isCleanUpFunction, () => "cleanup").when(ast.isIIFE, () => "immediate").otherwise(() => "other");
|
|
642
633
|
}
|
|
643
634
|
const useLayoutEffectCallRef = tools.MutRef.make(null);
|
|
644
|
-
const callStack = tools.MutList.make();
|
|
645
635
|
const functionStack = tools.MutList.make();
|
|
646
636
|
const effectFunctionRef = tools.MutRef.make(null);
|
|
647
637
|
const cleanUpFunctionRef = tools.MutRef.make(null);
|
|
648
638
|
const indirectFunctionCalls = [];
|
|
649
639
|
const indirectSetStateCalls = /* @__PURE__ */ new Map();
|
|
650
|
-
const onUseLayoutEffectCallEnter = (node) => void tools.MutRef.set(useLayoutEffectCallRef, node);
|
|
651
|
-
const onUseLayoutEffectCallExit = () => void tools.MutRef.set(useLayoutEffectCallRef, null);
|
|
652
640
|
return {
|
|
653
641
|
Identifier(node) {
|
|
654
642
|
const isInUseLayoutEffectCall = tools.MutRef.get(useLayoutEffectCallRef) !== null;
|
|
@@ -663,7 +651,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
663
651
|
}
|
|
664
652
|
},
|
|
665
653
|
CallExpression(node) {
|
|
666
|
-
tools.MutList.append(callStack, node);
|
|
667
654
|
const effectFn = tools.MutRef.get(effectFunctionRef);
|
|
668
655
|
const [parentFn, parentFnKind] = tools.MutList.tail(functionStack) ?? [];
|
|
669
656
|
if (parentFn?.async) return;
|
|
@@ -679,12 +666,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
679
666
|
messageId: "NO_DIRECT_SET_STATE_IN_USE_LAYOUT_EFFECT"
|
|
680
667
|
});
|
|
681
668
|
}).with("useLayoutEffect", () => {
|
|
682
|
-
|
|
683
|
-
}).with("useState", () => {
|
|
684
|
-
}).with("then", () => {
|
|
669
|
+
tools.MutRef.set(useLayoutEffectCallRef, node);
|
|
685
670
|
}).with("other", () => {
|
|
686
671
|
indirectFunctionCalls.push(node);
|
|
687
|
-
}).
|
|
672
|
+
}).otherwise(tools.F.constVoid);
|
|
688
673
|
},
|
|
689
674
|
":function"(node) {
|
|
690
675
|
const functionKind = getFunctionKind(node);
|
|
@@ -693,8 +678,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
693
678
|
tools.MutRef.set(effectFunctionRef, node);
|
|
694
679
|
}).with("cleanup", () => {
|
|
695
680
|
tools.MutRef.set(cleanUpFunctionRef, node);
|
|
696
|
-
}).otherwise(
|
|
697
|
-
});
|
|
681
|
+
}).otherwise(tools.F.constVoid);
|
|
698
682
|
},
|
|
699
683
|
":function:exit"(node) {
|
|
700
684
|
const effectFn = tools.MutRef.get(effectFunctionRef);
|
|
@@ -704,9 +688,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
704
688
|
tools.MutList.pop(functionStack);
|
|
705
689
|
},
|
|
706
690
|
"CallExpression:exit"(node) {
|
|
707
|
-
tools.MutList.pop(callStack);
|
|
708
691
|
if (tools.MutRef.get(useLayoutEffectCallRef) === node) {
|
|
709
|
-
onUseLayoutEffectCallExit();
|
|
710
692
|
tools.MutRef.set(useLayoutEffectCallRef, null);
|
|
711
693
|
}
|
|
712
694
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
|
|
|
7
7
|
|
|
8
8
|
// package.json
|
|
9
9
|
var name = "eslint-plugin-react-hooks-extra";
|
|
10
|
-
var version = "1.5.28-beta.
|
|
10
|
+
var version = "1.5.28-beta.3";
|
|
11
11
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
12
12
|
|
|
13
13
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -465,14 +465,11 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
465
465
|
return $(node).when(isEffectFunction, () => "effect").when(isCleanUpFunction, () => "cleanup").when(isIIFE, () => "immediate").otherwise(() => "other");
|
|
466
466
|
}
|
|
467
467
|
const useEffectCallRef = MutRef.make(null);
|
|
468
|
-
const callStack = MutList.make();
|
|
469
468
|
const functionStack = MutList.make();
|
|
470
469
|
const effectFunctionRef = MutRef.make(null);
|
|
471
470
|
const cleanUpFunctionRef = MutRef.make(null);
|
|
472
471
|
const indirectFunctionCalls = [];
|
|
473
472
|
const indirectSetStateCalls = /* @__PURE__ */ new Map();
|
|
474
|
-
const onUseEffectCallEnter = (node) => void MutRef.set(useEffectCallRef, node);
|
|
475
|
-
const onUseEffectCallExit = () => void MutRef.set(useEffectCallRef, null);
|
|
476
473
|
return {
|
|
477
474
|
Identifier(node) {
|
|
478
475
|
const isInUseEffectCall = MutRef.get(useEffectCallRef) !== null;
|
|
@@ -487,7 +484,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
487
484
|
}
|
|
488
485
|
},
|
|
489
486
|
CallExpression(node) {
|
|
490
|
-
MutList.append(callStack, node);
|
|
491
487
|
const effectFn = MutRef.get(effectFunctionRef);
|
|
492
488
|
const [parentFn, parentFnKind] = MutList.tail(functionStack) ?? [];
|
|
493
489
|
if (parentFn?.async) return;
|
|
@@ -503,12 +499,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
503
499
|
messageId: "NO_DIRECT_SET_STATE_IN_USE_EFFECT"
|
|
504
500
|
});
|
|
505
501
|
}).with("useEffect", () => {
|
|
506
|
-
|
|
507
|
-
}).with("useState", () => {
|
|
508
|
-
}).with("then", () => {
|
|
502
|
+
MutRef.set(useEffectCallRef, node);
|
|
509
503
|
}).with("other", () => {
|
|
510
504
|
indirectFunctionCalls.push(node);
|
|
511
|
-
}).
|
|
505
|
+
}).otherwise(F.constVoid);
|
|
512
506
|
},
|
|
513
507
|
":function"(node) {
|
|
514
508
|
const functionKind = getFunctionKind(node);
|
|
@@ -517,8 +511,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
517
511
|
MutRef.set(effectFunctionRef, node);
|
|
518
512
|
}).with("cleanup", () => {
|
|
519
513
|
MutRef.set(cleanUpFunctionRef, node);
|
|
520
|
-
}).otherwise(
|
|
521
|
-
});
|
|
514
|
+
}).otherwise(F.constVoid);
|
|
522
515
|
},
|
|
523
516
|
":function:exit"(node) {
|
|
524
517
|
const effectFn = MutRef.get(effectFunctionRef);
|
|
@@ -528,9 +521,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
528
521
|
MutList.pop(functionStack);
|
|
529
522
|
},
|
|
530
523
|
"CallExpression:exit"(node) {
|
|
531
|
-
MutList.pop(callStack);
|
|
532
524
|
if (MutRef.get(useEffectCallRef) === node) {
|
|
533
|
-
onUseEffectCallExit();
|
|
534
525
|
MutRef.set(useEffectCallRef, null);
|
|
535
526
|
}
|
|
536
527
|
},
|
|
@@ -639,14 +630,11 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
639
630
|
return $(node).when(isEffectFunction, () => "effect").when(isCleanUpFunction, () => "cleanup").when(isIIFE, () => "immediate").otherwise(() => "other");
|
|
640
631
|
}
|
|
641
632
|
const useLayoutEffectCallRef = MutRef.make(null);
|
|
642
|
-
const callStack = MutList.make();
|
|
643
633
|
const functionStack = MutList.make();
|
|
644
634
|
const effectFunctionRef = MutRef.make(null);
|
|
645
635
|
const cleanUpFunctionRef = MutRef.make(null);
|
|
646
636
|
const indirectFunctionCalls = [];
|
|
647
637
|
const indirectSetStateCalls = /* @__PURE__ */ new Map();
|
|
648
|
-
const onUseLayoutEffectCallEnter = (node) => void MutRef.set(useLayoutEffectCallRef, node);
|
|
649
|
-
const onUseLayoutEffectCallExit = () => void MutRef.set(useLayoutEffectCallRef, null);
|
|
650
638
|
return {
|
|
651
639
|
Identifier(node) {
|
|
652
640
|
const isInUseLayoutEffectCall = MutRef.get(useLayoutEffectCallRef) !== null;
|
|
@@ -661,7 +649,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
661
649
|
}
|
|
662
650
|
},
|
|
663
651
|
CallExpression(node) {
|
|
664
|
-
MutList.append(callStack, node);
|
|
665
652
|
const effectFn = MutRef.get(effectFunctionRef);
|
|
666
653
|
const [parentFn, parentFnKind] = MutList.tail(functionStack) ?? [];
|
|
667
654
|
if (parentFn?.async) return;
|
|
@@ -677,12 +664,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
677
664
|
messageId: "NO_DIRECT_SET_STATE_IN_USE_LAYOUT_EFFECT"
|
|
678
665
|
});
|
|
679
666
|
}).with("useLayoutEffect", () => {
|
|
680
|
-
|
|
681
|
-
}).with("useState", () => {
|
|
682
|
-
}).with("then", () => {
|
|
667
|
+
MutRef.set(useLayoutEffectCallRef, node);
|
|
683
668
|
}).with("other", () => {
|
|
684
669
|
indirectFunctionCalls.push(node);
|
|
685
|
-
}).
|
|
670
|
+
}).otherwise(F.constVoid);
|
|
686
671
|
},
|
|
687
672
|
":function"(node) {
|
|
688
673
|
const functionKind = getFunctionKind(node);
|
|
@@ -691,8 +676,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
691
676
|
MutRef.set(effectFunctionRef, node);
|
|
692
677
|
}).with("cleanup", () => {
|
|
693
678
|
MutRef.set(cleanUpFunctionRef, node);
|
|
694
|
-
}).otherwise(
|
|
695
|
-
});
|
|
679
|
+
}).otherwise(F.constVoid);
|
|
696
680
|
},
|
|
697
681
|
":function:exit"(node) {
|
|
698
682
|
const effectFn = MutRef.get(effectFunctionRef);
|
|
@@ -702,9 +686,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
702
686
|
MutList.pop(functionStack);
|
|
703
687
|
},
|
|
704
688
|
"CallExpression:exit"(node) {
|
|
705
|
-
MutList.pop(callStack);
|
|
706
689
|
if (MutRef.get(useLayoutEffectCallRef) === node) {
|
|
707
|
-
onUseLayoutEffectCallExit();
|
|
708
690
|
MutRef.set(useLayoutEffectCallRef, null);
|
|
709
691
|
}
|
|
710
692
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "1.5.28-beta.
|
|
3
|
+
"version": "1.5.28-beta.3",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"@typescript-eslint/type-utils": "^7.16.1",
|
|
40
40
|
"@typescript-eslint/types": "^7.16.1",
|
|
41
41
|
"@typescript-eslint/utils": "^7.16.1",
|
|
42
|
-
"@eslint-react/ast": "1.5.28-beta.
|
|
43
|
-
"@eslint-react/core": "1.5.28-beta.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/shared": "1.5.28-beta.
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/ast": "1.5.28-beta.3",
|
|
43
|
+
"@eslint-react/core": "1.5.28-beta.3",
|
|
44
|
+
"@eslint-react/jsx": "1.5.28-beta.3",
|
|
45
|
+
"@eslint-react/shared": "1.5.28-beta.3",
|
|
46
|
+
"@eslint-react/tools": "1.5.28-beta.3",
|
|
47
|
+
"@eslint-react/types": "1.5.28-beta.3",
|
|
48
|
+
"@eslint-react/var": "1.5.28-beta.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"string-ts": "2.2.0",
|