eslint-plugin-react-hooks-extra 2.8.2-beta.0 → 2.8.2-beta.4
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 -8
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WEBSITE_URL, getConfigAdapters, getSettingsFromContext } from "@eslint-react/shared";
|
|
2
2
|
import * as ast from "@eslint-react/ast";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
|
-
import { isUseCallbackCall, isUseEffectLikeCall, isUseMemoCall, isUseStateLikeCall } from "@eslint-react/core";
|
|
5
4
|
import { constVoid, getOrElseUpdate, not } from "@eslint-react/eff";
|
|
6
5
|
import { findVariable, getVariableDefinitionNode } from "@eslint-react/var";
|
|
7
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
@@ -37,7 +36,7 @@ const rules = { "react-hooks-extra/no-direct-set-state-in-use-effect": "warn" };
|
|
|
37
36
|
//#endregion
|
|
38
37
|
//#region package.json
|
|
39
38
|
var name = "eslint-plugin-react-hooks-extra";
|
|
40
|
-
var version = "2.8.2-beta.
|
|
39
|
+
var version = "2.8.2-beta.4";
|
|
41
40
|
|
|
42
41
|
//#endregion
|
|
43
42
|
//#region src/utils/create-rule.ts
|
|
@@ -98,17 +97,17 @@ function create(context) {
|
|
|
98
97
|
return node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "then";
|
|
99
98
|
}
|
|
100
99
|
function isUseStateCall(node) {
|
|
101
|
-
return isUseStateLikeCall(node, additionalStateHooks);
|
|
100
|
+
return core.isUseStateLikeCall(node, additionalStateHooks);
|
|
102
101
|
}
|
|
103
102
|
function isUseEffectSetupCallback(node) {
|
|
104
|
-
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
103
|
+
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && core.isUseEffectLikeCall(node.parent);
|
|
105
104
|
}
|
|
106
105
|
function getCallName(node) {
|
|
107
106
|
if (node.type === AST_NODE_TYPES.CallExpression) return ast.toStringFormat(node.callee, getText);
|
|
108
107
|
return ast.toStringFormat(node, getText);
|
|
109
108
|
}
|
|
110
109
|
function getCallKind(node) {
|
|
111
|
-
return match(node).when(isUseStateCall, () => "useState").when(isUseEffectLikeCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
110
|
+
return match(node).when(isUseStateCall, () => "useState").when(core.isUseEffectLikeCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
112
111
|
}
|
|
113
112
|
function getFunctionKind(node) {
|
|
114
113
|
const parent = ast.findParentNode(node, not(ast.isTypeExpression)) ?? node.parent;
|
|
@@ -200,19 +199,19 @@ function create(context) {
|
|
|
200
199
|
case AST_NODE_TYPES.ArrowFunctionExpression: {
|
|
201
200
|
const parent = node.parent.parent;
|
|
202
201
|
if (parent.type !== AST_NODE_TYPES.CallExpression) break;
|
|
203
|
-
if (!isUseMemoCall(parent)) break;
|
|
202
|
+
if (!core.isUseMemoCall(parent)) break;
|
|
204
203
|
const init = ast.findParentNode(parent, isVariableDeclaratorFromHookCall)?.init;
|
|
205
204
|
if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
|
|
206
205
|
break;
|
|
207
206
|
}
|
|
208
207
|
case AST_NODE_TYPES.CallExpression:
|
|
209
208
|
if (node !== node.parent.arguments.at(0)) break;
|
|
210
|
-
if (isUseCallbackCall(node.parent)) {
|
|
209
|
+
if (core.isUseCallbackCall(node.parent)) {
|
|
211
210
|
const init = ast.findParentNode(node.parent, isVariableDeclaratorFromHookCall)?.init;
|
|
212
211
|
if (init != null) getOrElseUpdate(setStateInEffectArg, init, () => []).push(node);
|
|
213
212
|
break;
|
|
214
213
|
}
|
|
215
|
-
if (isUseEffectLikeCall(node.parent)) getOrElseUpdate(setStateInEffectSetup, node.parent, () => []).push(node);
|
|
214
|
+
if (core.isUseEffectLikeCall(node.parent)) getOrElseUpdate(setStateInEffectSetup, node.parent, () => []).push(node);
|
|
216
215
|
}
|
|
217
216
|
},
|
|
218
217
|
"Program:exit"() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "2.8.2-beta.
|
|
3
|
+
"version": "2.8.2-beta.4",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@typescript-eslint/utils": "^8.54.0",
|
|
46
46
|
"string-ts": "^2.3.1",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "2.8.2-beta.
|
|
49
|
-
"@eslint-react/core": "2.8.2-beta.
|
|
50
|
-
"@eslint-react/eff": "2.8.2-beta.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "2.8.2-beta.4",
|
|
49
|
+
"@eslint-react/core": "2.8.2-beta.4",
|
|
50
|
+
"@eslint-react/eff": "2.8.2-beta.4",
|
|
51
|
+
"@eslint-react/shared": "2.8.2-beta.4",
|
|
52
|
+
"@eslint-react/var": "2.8.2-beta.4"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.10",
|