eslint-plugin-react-hooks-extra 1.48.2 → 1.48.3-next.0
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 +10 -3
- package/dist/index.mjs +10 -3
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -52,7 +52,7 @@ var rules = {
|
|
|
52
52
|
|
|
53
53
|
// package.json
|
|
54
54
|
var name2 = "eslint-plugin-react-hooks-extra";
|
|
55
|
-
var version = "1.48.
|
|
55
|
+
var version = "1.48.3-next.0";
|
|
56
56
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("hooks-extra"));
|
|
57
57
|
function isFromHookCall(context, name3, settings, predicate = eff.constTrue) {
|
|
58
58
|
const hookAlias = settings.additionalHooks[name3] ?? [];
|
|
@@ -159,6 +159,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
159
159
|
const { onViolation, useEffectKind } = options;
|
|
160
160
|
const settings = shared.getSettingsFromContext(context);
|
|
161
161
|
const additionalHooks = settings.additionalHooks;
|
|
162
|
+
const getText = (n) => context.sourceCode.getText(n);
|
|
162
163
|
const isUseEffectLikeCall = ER7__namespace.isReactHookCallWithNameAlias(context, useEffectKind, additionalHooks[useEffectKind]);
|
|
163
164
|
const isUseStateCall = ER7__namespace.isReactHookCallWithNameAlias(context, "useState", additionalHooks.useState);
|
|
164
165
|
const isUseMemoCall = ER7__namespace.isReactHookCallWithNameAlias(context, "useMemo", additionalHooks.useMemo);
|
|
@@ -184,6 +185,12 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
184
185
|
function isFunctionOfUseEffectSetup(node) {
|
|
185
186
|
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
186
187
|
}
|
|
188
|
+
function getCallName(node) {
|
|
189
|
+
if (node.type === types.AST_NODE_TYPES.CallExpression) {
|
|
190
|
+
return AST__namespace.toString(node.callee, getText);
|
|
191
|
+
}
|
|
192
|
+
return AST__namespace.toString(node, getText);
|
|
193
|
+
}
|
|
187
194
|
function getCallKind(node) {
|
|
188
195
|
return tsPattern.match(node).when(isUseStateCall, () => "useState").when(isUseEffectLikeCall, () => useEffectKind).when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
189
196
|
}
|
|
@@ -299,7 +306,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
299
306
|
const setStateCalls = getSetStateCalls(name3, context.sourceCode.getScope(callee));
|
|
300
307
|
for (const setStateCall of setStateCalls) {
|
|
301
308
|
onViolation(context, setStateCall, {
|
|
302
|
-
name:
|
|
309
|
+
name: getCallName(setStateCall)
|
|
303
310
|
});
|
|
304
311
|
}
|
|
305
312
|
}
|
|
@@ -307,7 +314,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
307
314
|
const setStateCalls = getSetStateCalls(id.name, context.sourceCode.getScope(id));
|
|
308
315
|
for (const setStateCall of setStateCalls) {
|
|
309
316
|
onViolation(context, setStateCall, {
|
|
310
|
-
name:
|
|
317
|
+
name: getCallName(setStateCall)
|
|
311
318
|
});
|
|
312
319
|
}
|
|
313
320
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -28,7 +28,7 @@ var rules = {
|
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var name2 = "eslint-plugin-react-hooks-extra";
|
|
31
|
-
var version = "1.48.
|
|
31
|
+
var version = "1.48.3-next.0";
|
|
32
32
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("hooks-extra"));
|
|
33
33
|
function isFromHookCall(context, name3, settings, predicate = constTrue) {
|
|
34
34
|
const hookAlias = settings.additionalHooks[name3] ?? [];
|
|
@@ -135,6 +135,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
135
135
|
const { onViolation, useEffectKind } = options;
|
|
136
136
|
const settings = getSettingsFromContext(context);
|
|
137
137
|
const additionalHooks = settings.additionalHooks;
|
|
138
|
+
const getText = (n) => context.sourceCode.getText(n);
|
|
138
139
|
const isUseEffectLikeCall = ER7.isReactHookCallWithNameAlias(context, useEffectKind, additionalHooks[useEffectKind]);
|
|
139
140
|
const isUseStateCall = ER7.isReactHookCallWithNameAlias(context, "useState", additionalHooks.useState);
|
|
140
141
|
const isUseMemoCall = ER7.isReactHookCallWithNameAlias(context, "useMemo", additionalHooks.useMemo);
|
|
@@ -160,6 +161,12 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
160
161
|
function isFunctionOfUseEffectSetup(node) {
|
|
161
162
|
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
162
163
|
}
|
|
164
|
+
function getCallName(node) {
|
|
165
|
+
if (node.type === AST_NODE_TYPES.CallExpression) {
|
|
166
|
+
return AST.toString(node.callee, getText);
|
|
167
|
+
}
|
|
168
|
+
return AST.toString(node, getText);
|
|
169
|
+
}
|
|
163
170
|
function getCallKind(node) {
|
|
164
171
|
return match(node).when(isUseStateCall, () => "useState").when(isUseEffectLikeCall, () => useEffectKind).when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
|
|
165
172
|
}
|
|
@@ -275,7 +282,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
275
282
|
const setStateCalls = getSetStateCalls(name3, context.sourceCode.getScope(callee));
|
|
276
283
|
for (const setStateCall of setStateCalls) {
|
|
277
284
|
onViolation(context, setStateCall, {
|
|
278
|
-
name:
|
|
285
|
+
name: getCallName(setStateCall)
|
|
279
286
|
});
|
|
280
287
|
}
|
|
281
288
|
}
|
|
@@ -283,7 +290,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
283
290
|
const setStateCalls = getSetStateCalls(id.name, context.sourceCode.getScope(id));
|
|
284
291
|
for (const setStateCall of setStateCalls) {
|
|
285
292
|
onViolation(context, setStateCall, {
|
|
286
|
-
name:
|
|
293
|
+
name: getCallName(setStateCall)
|
|
287
294
|
});
|
|
288
295
|
}
|
|
289
296
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "1.48.
|
|
3
|
+
"version": "1.48.3-next.0",
|
|
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.30.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.7.0",
|
|
53
|
-
"@eslint-react/ast": "1.48.
|
|
54
|
-
"@eslint-react/core": "1.48.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/shared": "1.48.
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/ast": "1.48.3-next.0",
|
|
54
|
+
"@eslint-react/core": "1.48.3-next.0",
|
|
55
|
+
"@eslint-react/kit": "1.48.3-next.0",
|
|
56
|
+
"@eslint-react/shared": "1.48.3-next.0",
|
|
57
|
+
"@eslint-react/var": "1.48.3-next.0",
|
|
58
|
+
"@eslint-react/eff": "1.48.3-next.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.1.2",
|