eslint-plugin-react-hooks-extra 1.5.28-beta.4 → 1.5.28-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 +5 -25
- package/dist/index.mjs +6 -26
- 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.6";
|
|
13
13
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
14
14
|
|
|
15
15
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -508,6 +508,8 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
508
508
|
}).with("useEffect", () => {
|
|
509
509
|
tools.MutRef.set(useEffectCallRef, node);
|
|
510
510
|
}).with("other", () => {
|
|
511
|
+
const isInEffectFunction = effectFn === parentFn;
|
|
512
|
+
if (!isInEffectFunction) return;
|
|
511
513
|
tools.MutRef.update(indirectFunctionCalls, tools.Chunk.append(node));
|
|
512
514
|
}).otherwise(tools.F.constVoid);
|
|
513
515
|
},
|
|
@@ -516,18 +518,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
516
518
|
tools.MutRef.set(useEffectCallRef, null);
|
|
517
519
|
}
|
|
518
520
|
},
|
|
519
|
-
Identifier(node) {
|
|
520
|
-
const isInUseEffectCall = tools.MutRef.get(useEffectCallRef) !== null;
|
|
521
|
-
const parentFn = tools.MutList.tail(functionStack)?.[0];
|
|
522
|
-
const useEffectCall = tools.MutRef.get(useEffectCallRef);
|
|
523
|
-
const isEffectFunction2 = useEffectCall && tools.O.isSome(ast.traverseUp(useEffectCall, (n2) => n2 === parentFn));
|
|
524
|
-
if (isFromUseStateCall(node) && isInUseEffectCall && isEffectFunction2) {
|
|
525
|
-
context.report({
|
|
526
|
-
messageId: "NO_DIRECT_SET_STATE_IN_USE_EFFECT",
|
|
527
|
-
node
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
},
|
|
531
521
|
"Program:exit"() {
|
|
532
522
|
for (const call of tools.Chunk.toReadonlyArray(tools.MutRef.get(indirectFunctionCalls))) {
|
|
533
523
|
if (!("name" in call.callee)) continue;
|
|
@@ -675,6 +665,8 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
675
665
|
}).with("useLayoutEffect", () => {
|
|
676
666
|
tools.MutRef.set(useLayoutEffectCallRef, node);
|
|
677
667
|
}).with("other", () => {
|
|
668
|
+
const isInEffectFunction = effectFn === parentFn;
|
|
669
|
+
if (!isInEffectFunction) return;
|
|
678
670
|
tools.MutRef.update(indirectFunctionCalls, tools.Chunk.append(node));
|
|
679
671
|
}).otherwise(tools.F.constVoid);
|
|
680
672
|
},
|
|
@@ -683,18 +675,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
683
675
|
tools.MutRef.set(useLayoutEffectCallRef, null);
|
|
684
676
|
}
|
|
685
677
|
},
|
|
686
|
-
Identifier(node) {
|
|
687
|
-
const isInUseLayoutEffectCall = tools.MutRef.get(useLayoutEffectCallRef) !== null;
|
|
688
|
-
const parentFn = tools.MutList.tail(functionStack)?.[0];
|
|
689
|
-
const useLayoutEffectCall = tools.MutRef.get(useLayoutEffectCallRef);
|
|
690
|
-
const isEffectFunction2 = useLayoutEffectCall && tools.O.isSome(ast.traverseUp(useLayoutEffectCall, (n2) => n2 === parentFn));
|
|
691
|
-
if (isFromUseStateCall(node) && isInUseLayoutEffectCall && isEffectFunction2) {
|
|
692
|
-
context.report({
|
|
693
|
-
messageId: "NO_DIRECT_SET_STATE_IN_USE_LAYOUT_EFFECT",
|
|
694
|
-
node
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
},
|
|
698
678
|
"Program:exit"() {
|
|
699
679
|
for (const call of tools.Chunk.toReadonlyArray(tools.MutRef.get(indirectFunctionCalls))) {
|
|
700
680
|
if (!("name" in call.callee)) continue;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useHookCollector, isReactHookCall, isUseCallbackCall, isReactHookCallWithNameLoose, isUseMemoCall, isUseStateCall, isUseEffectCall, isUseLayoutEffectCall } from '@eslint-react/core';
|
|
2
2
|
import { createRuleForPlugin, getESLintReactSettings } from '@eslint-react/shared';
|
|
3
|
-
import { isFunction, NodeType, is,
|
|
3
|
+
import { isFunction, NodeType, is, getNestedCallExpressions, isIIFE } from '@eslint-react/ast';
|
|
4
4
|
import { F, O, MutRef, MutList, Chunk } from '@eslint-react/tools';
|
|
5
5
|
import { findVariable, getVariableInit } from '@eslint-react/var';
|
|
6
6
|
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.6";
|
|
11
11
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
12
12
|
|
|
13
13
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -506,6 +506,8 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
506
506
|
}).with("useEffect", () => {
|
|
507
507
|
MutRef.set(useEffectCallRef, node);
|
|
508
508
|
}).with("other", () => {
|
|
509
|
+
const isInEffectFunction = effectFn === parentFn;
|
|
510
|
+
if (!isInEffectFunction) return;
|
|
509
511
|
MutRef.update(indirectFunctionCalls, Chunk.append(node));
|
|
510
512
|
}).otherwise(F.constVoid);
|
|
511
513
|
},
|
|
@@ -514,18 +516,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
514
516
|
MutRef.set(useEffectCallRef, null);
|
|
515
517
|
}
|
|
516
518
|
},
|
|
517
|
-
Identifier(node) {
|
|
518
|
-
const isInUseEffectCall = MutRef.get(useEffectCallRef) !== null;
|
|
519
|
-
const parentFn = MutList.tail(functionStack)?.[0];
|
|
520
|
-
const useEffectCall = MutRef.get(useEffectCallRef);
|
|
521
|
-
const isEffectFunction2 = useEffectCall && O.isSome(traverseUp(useEffectCall, (n2) => n2 === parentFn));
|
|
522
|
-
if (isFromUseStateCall(node) && isInUseEffectCall && isEffectFunction2) {
|
|
523
|
-
context.report({
|
|
524
|
-
messageId: "NO_DIRECT_SET_STATE_IN_USE_EFFECT",
|
|
525
|
-
node
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
},
|
|
529
519
|
"Program:exit"() {
|
|
530
520
|
for (const call of Chunk.toReadonlyArray(MutRef.get(indirectFunctionCalls))) {
|
|
531
521
|
if (!("name" in call.callee)) continue;
|
|
@@ -673,6 +663,8 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
673
663
|
}).with("useLayoutEffect", () => {
|
|
674
664
|
MutRef.set(useLayoutEffectCallRef, node);
|
|
675
665
|
}).with("other", () => {
|
|
666
|
+
const isInEffectFunction = effectFn === parentFn;
|
|
667
|
+
if (!isInEffectFunction) return;
|
|
676
668
|
MutRef.update(indirectFunctionCalls, Chunk.append(node));
|
|
677
669
|
}).otherwise(F.constVoid);
|
|
678
670
|
},
|
|
@@ -681,18 +673,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
681
673
|
MutRef.set(useLayoutEffectCallRef, null);
|
|
682
674
|
}
|
|
683
675
|
},
|
|
684
|
-
Identifier(node) {
|
|
685
|
-
const isInUseLayoutEffectCall = MutRef.get(useLayoutEffectCallRef) !== null;
|
|
686
|
-
const parentFn = MutList.tail(functionStack)?.[0];
|
|
687
|
-
const useLayoutEffectCall = MutRef.get(useLayoutEffectCallRef);
|
|
688
|
-
const isEffectFunction2 = useLayoutEffectCall && O.isSome(traverseUp(useLayoutEffectCall, (n2) => n2 === parentFn));
|
|
689
|
-
if (isFromUseStateCall(node) && isInUseLayoutEffectCall && isEffectFunction2) {
|
|
690
|
-
context.report({
|
|
691
|
-
messageId: "NO_DIRECT_SET_STATE_IN_USE_LAYOUT_EFFECT",
|
|
692
|
-
node
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
},
|
|
696
676
|
"Program:exit"() {
|
|
697
677
|
for (const call of Chunk.toReadonlyArray(MutRef.get(indirectFunctionCalls))) {
|
|
698
678
|
if (!("name" in call.callee)) continue;
|
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.6",
|
|
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/
|
|
44
|
-
"@eslint-react/shared": "1.5.28-beta.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/ast": "1.5.28-beta.6",
|
|
43
|
+
"@eslint-react/jsx": "1.5.28-beta.6",
|
|
44
|
+
"@eslint-react/shared": "1.5.28-beta.6",
|
|
45
|
+
"@eslint-react/tools": "1.5.28-beta.6",
|
|
46
|
+
"@eslint-react/types": "1.5.28-beta.6",
|
|
47
|
+
"@eslint-react/core": "1.5.28-beta.6",
|
|
48
|
+
"@eslint-react/var": "1.5.28-beta.6"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"string-ts": "2.2.0",
|