eslint-plugin-react-hooks-extra 1.28.0-next.1 → 1.28.0-next.2
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 +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var rules = {
|
|
|
50
50
|
|
|
51
51
|
// package.json
|
|
52
52
|
var name2 = "eslint-plugin-react-hooks-extra";
|
|
53
|
-
var version = "1.28.0-next.
|
|
53
|
+
var version = "1.28.0-next.2";
|
|
54
54
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
55
55
|
function isFromHookCall(name3, context, settings, predicate = eff.constTrue) {
|
|
56
56
|
const hookAlias = settings.additionalHooks[name3] ?? [];
|
|
@@ -73,6 +73,9 @@ function isFromUseStateCall(context, settings) {
|
|
|
73
73
|
};
|
|
74
74
|
return isFromHookCall("useState", context, settings, predicate);
|
|
75
75
|
}
|
|
76
|
+
function isFunctionOfImmediatelyInvoked(node) {
|
|
77
|
+
return node.type !== types.AST_NODE_TYPES.FunctionDeclaration && node.parent.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee === node;
|
|
78
|
+
}
|
|
76
79
|
function isSetFunctionCall(context, settings) {
|
|
77
80
|
const isIdFromUseStateCall = isFromUseStateCall(context, settings);
|
|
78
81
|
return (node) => {
|
|
@@ -202,7 +205,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
202
205
|
return tsPattern.match(node).when(isUseStateCall2, () => "useState").when(isUseEffectLikeCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
203
206
|
}
|
|
204
207
|
function getFunctionKind(node) {
|
|
205
|
-
return tsPattern.match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(
|
|
208
|
+
return tsPattern.match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
|
|
206
209
|
}
|
|
207
210
|
return {
|
|
208
211
|
":function"(node) {
|
|
@@ -401,7 +404,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
401
404
|
return tsPattern.match(node).when(isUseStateCall2, () => "useState").when(isUseLayoutEffectLikeCall, () => "useLayoutEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
402
405
|
}
|
|
403
406
|
function getFunctionKind(node) {
|
|
404
|
-
return tsPattern.match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(
|
|
407
|
+
return tsPattern.match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
|
|
405
408
|
}
|
|
406
409
|
return {
|
|
407
410
|
":function"(node) {
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ var rules = {
|
|
|
27
27
|
|
|
28
28
|
// package.json
|
|
29
29
|
var name2 = "eslint-plugin-react-hooks-extra";
|
|
30
|
-
var version = "1.28.0-next.
|
|
30
|
+
var version = "1.28.0-next.2";
|
|
31
31
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
32
32
|
function isFromHookCall(name3, context, settings, predicate = constTrue) {
|
|
33
33
|
const hookAlias = settings.additionalHooks[name3] ?? [];
|
|
@@ -50,6 +50,9 @@ function isFromUseStateCall(context, settings) {
|
|
|
50
50
|
};
|
|
51
51
|
return isFromHookCall("useState", context, settings, predicate);
|
|
52
52
|
}
|
|
53
|
+
function isFunctionOfImmediatelyInvoked(node) {
|
|
54
|
+
return node.type !== AST_NODE_TYPES.FunctionDeclaration && node.parent.type === AST_NODE_TYPES.CallExpression && node.parent.callee === node;
|
|
55
|
+
}
|
|
53
56
|
function isSetFunctionCall(context, settings) {
|
|
54
57
|
const isIdFromUseStateCall = isFromUseStateCall(context, settings);
|
|
55
58
|
return (node) => {
|
|
@@ -179,7 +182,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
179
182
|
return match(node).when(isUseStateCall2, () => "useState").when(isUseEffectLikeCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
180
183
|
}
|
|
181
184
|
function getFunctionKind(node) {
|
|
182
|
-
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(
|
|
185
|
+
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
|
|
183
186
|
}
|
|
184
187
|
return {
|
|
185
188
|
":function"(node) {
|
|
@@ -378,7 +381,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
378
381
|
return match(node).when(isUseStateCall2, () => "useState").when(isUseLayoutEffectLikeCall, () => "useLayoutEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
379
382
|
}
|
|
380
383
|
function getFunctionKind(node) {
|
|
381
|
-
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(
|
|
384
|
+
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfImmediatelyInvoked, () => "immediate").otherwise(() => "other");
|
|
382
385
|
}
|
|
383
386
|
return {
|
|
384
387
|
":function"(node) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "1.28.0-next.
|
|
3
|
+
"version": "1.28.0-next.2",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"@typescript-eslint/utils": "^8.25.0",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.6.2",
|
|
53
|
-
"@eslint-react/ast": "1.28.0-next.
|
|
54
|
-
"@eslint-react/core": "1.28.0-next.
|
|
55
|
-
"@eslint-react/eff": "1.28.0-next.
|
|
56
|
-
"@eslint-react/jsx": "1.28.0-next.
|
|
57
|
-
"@eslint-react/shared": "1.28.0-next.
|
|
58
|
-
"@eslint-react/var": "1.28.0-next.
|
|
53
|
+
"@eslint-react/ast": "1.28.0-next.2",
|
|
54
|
+
"@eslint-react/core": "1.28.0-next.2",
|
|
55
|
+
"@eslint-react/eff": "1.28.0-next.2",
|
|
56
|
+
"@eslint-react/jsx": "1.28.0-next.2",
|
|
57
|
+
"@eslint-react/shared": "1.28.0-next.2",
|
|
58
|
+
"@eslint-react/var": "1.28.0-next.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.0.10",
|