eslint-plugin-react-hooks-extra 1.5.28-beta.4 → 1.5.28-beta.5
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 +1 -25
- package/dist/index.mjs +2 -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.5";
|
|
13
13
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
14
14
|
|
|
15
15
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -516,18 +516,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
516
516
|
tools.MutRef.set(useEffectCallRef, null);
|
|
517
517
|
}
|
|
518
518
|
},
|
|
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
519
|
"Program:exit"() {
|
|
532
520
|
for (const call of tools.Chunk.toReadonlyArray(tools.MutRef.get(indirectFunctionCalls))) {
|
|
533
521
|
if (!("name" in call.callee)) continue;
|
|
@@ -683,18 +671,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
683
671
|
tools.MutRef.set(useLayoutEffectCallRef, null);
|
|
684
672
|
}
|
|
685
673
|
},
|
|
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
674
|
"Program:exit"() {
|
|
699
675
|
for (const call of tools.Chunk.toReadonlyArray(tools.MutRef.get(indirectFunctionCalls))) {
|
|
700
676
|
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.5";
|
|
11
11
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
12
12
|
|
|
13
13
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -514,18 +514,6 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
514
514
|
MutRef.set(useEffectCallRef, null);
|
|
515
515
|
}
|
|
516
516
|
},
|
|
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
517
|
"Program:exit"() {
|
|
530
518
|
for (const call of Chunk.toReadonlyArray(MutRef.get(indirectFunctionCalls))) {
|
|
531
519
|
if (!("name" in call.callee)) continue;
|
|
@@ -681,18 +669,6 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
681
669
|
MutRef.set(useLayoutEffectCallRef, null);
|
|
682
670
|
}
|
|
683
671
|
},
|
|
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
672
|
"Program:exit"() {
|
|
697
673
|
for (const call of Chunk.toReadonlyArray(MutRef.get(indirectFunctionCalls))) {
|
|
698
674
|
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.5",
|
|
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/
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/shared": "1.5.28-beta.
|
|
45
|
-
"@eslint-react/jsx": "1.5.28-beta.
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/var": "1.5.28-beta.
|
|
48
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/core": "1.5.28-beta.5",
|
|
43
|
+
"@eslint-react/ast": "1.5.28-beta.5",
|
|
44
|
+
"@eslint-react/shared": "1.5.28-beta.5",
|
|
45
|
+
"@eslint-react/jsx": "1.5.28-beta.5",
|
|
46
|
+
"@eslint-react/types": "1.5.28-beta.5",
|
|
47
|
+
"@eslint-react/var": "1.5.28-beta.5",
|
|
48
|
+
"@eslint-react/tools": "1.5.28-beta.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"string-ts": "2.2.0",
|