eslint-plugin-react-hooks-extra 1.30.1-next.1 → 1.30.2-beta.1
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/LICENSE +1 -1
- package/dist/index.js +9 -8
- package/dist/index.mjs +9 -8
- package/package.json +7 -7
package/LICENSE
CHANGED
package/dist/index.js
CHANGED
|
@@ -50,13 +50,13 @@ var rules = {
|
|
|
50
50
|
|
|
51
51
|
// package.json
|
|
52
52
|
var name2 = "eslint-plugin-react-hooks-extra";
|
|
53
|
-
var version = "1.30.
|
|
53
|
+
var version = "1.30.2-beta.1";
|
|
54
54
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
55
55
|
function isFromHookCall(context, name3, settings, predicate = eff.constTrue) {
|
|
56
56
|
const hookAlias = settings.additionalHooks[name3] ?? [];
|
|
57
57
|
return (topLevelId) => {
|
|
58
58
|
const variable = VAR4__namespace.findVariable(topLevelId, context.sourceCode.getScope(topLevelId));
|
|
59
|
-
const variableNode = VAR4__namespace.
|
|
59
|
+
const variableNode = VAR4__namespace.getVariableInitNode(variable, 0);
|
|
60
60
|
if (variableNode == null) return false;
|
|
61
61
|
if (variableNode.type !== types.AST_NODE_TYPES.CallExpression) return false;
|
|
62
62
|
if (!core.isReactHookCallWithNameAlias(context, name3, hookAlias)(variableNode)) return false;
|
|
@@ -211,7 +211,8 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
211
211
|
}
|
|
212
212
|
tsPattern.match(getCallKind(node)).with("setState", () => {
|
|
213
213
|
switch (true) {
|
|
214
|
-
case
|
|
214
|
+
case pEntry.node === setupFunction:
|
|
215
|
+
case (pEntry.kind === "immediate" && AST__namespace.findParentNode(pEntry.node, AST__namespace.isFunction) === setupFunction): {
|
|
215
216
|
onViolation(context, node, {
|
|
216
217
|
name: context.sourceCode.getText(node.callee)
|
|
217
218
|
});
|
|
@@ -272,7 +273,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
272
273
|
},
|
|
273
274
|
"Program:exit"() {
|
|
274
275
|
const getSetStateCalls = (id, initialScope) => {
|
|
275
|
-
const node = VAR4__namespace.
|
|
276
|
+
const node = VAR4__namespace.getVariableInitNode(VAR4__namespace.findVariable(id, initialScope), 0);
|
|
276
277
|
switch (node?.type) {
|
|
277
278
|
case types.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
278
279
|
case types.AST_NODE_TYPES.FunctionDeclaration:
|
|
@@ -413,7 +414,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
413
414
|
}
|
|
414
415
|
const hasEmptyDeps = tsPattern.match(arg1).with({ type: types.AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
|
|
415
416
|
const variable = VAR4__namespace.findVariable(n.name, initialScope);
|
|
416
|
-
const variableNode = VAR4__namespace.
|
|
417
|
+
const variableNode = VAR4__namespace.getVariableInitNode(variable, 0);
|
|
417
418
|
if (variableNode?.type !== types.AST_NODE_TYPES.ArrayExpression) {
|
|
418
419
|
return false;
|
|
419
420
|
}
|
|
@@ -429,7 +430,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
429
430
|
return n;
|
|
430
431
|
}).with({ type: types.AST_NODE_TYPES.FunctionExpression }, eff.identity).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
|
|
431
432
|
const variable = VAR4__namespace.findVariable(n.name, initialScope);
|
|
432
|
-
const variableNode = VAR4__namespace.
|
|
433
|
+
const variableNode = VAR4__namespace.getVariableInitNode(variable, 0);
|
|
433
434
|
if (variableNode?.type !== types.AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== types.AST_NODE_TYPES.FunctionExpression) {
|
|
434
435
|
return eff._;
|
|
435
436
|
}
|
|
@@ -496,7 +497,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
496
497
|
}
|
|
497
498
|
const hasEmptyDeps = tsPattern.match(arg1).with({ type: types.AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
|
|
498
499
|
const variable = VAR4__namespace.findVariable(n.name, initialScope);
|
|
499
|
-
const variableNode = VAR4__namespace.
|
|
500
|
+
const variableNode = VAR4__namespace.getVariableInitNode(variable, 0);
|
|
500
501
|
if (variableNode?.type !== types.AST_NODE_TYPES.ArrayExpression) {
|
|
501
502
|
return false;
|
|
502
503
|
}
|
|
@@ -512,7 +513,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
512
513
|
return n;
|
|
513
514
|
}).with({ type: types.AST_NODE_TYPES.FunctionExpression }, eff.identity).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
|
|
514
515
|
const variable = VAR4__namespace.findVariable(n.name, initialScope);
|
|
515
|
-
const variableNode = VAR4__namespace.
|
|
516
|
+
const variableNode = VAR4__namespace.getVariableInitNode(variable, 0);
|
|
516
517
|
if (variableNode?.type !== types.AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== types.AST_NODE_TYPES.FunctionExpression) {
|
|
517
518
|
return eff._;
|
|
518
519
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -27,13 +27,13 @@ var rules = {
|
|
|
27
27
|
|
|
28
28
|
// package.json
|
|
29
29
|
var name2 = "eslint-plugin-react-hooks-extra";
|
|
30
|
-
var version = "1.30.
|
|
30
|
+
var version = "1.30.2-beta.1";
|
|
31
31
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
32
32
|
function isFromHookCall(context, name3, settings, predicate = constTrue) {
|
|
33
33
|
const hookAlias = settings.additionalHooks[name3] ?? [];
|
|
34
34
|
return (topLevelId) => {
|
|
35
35
|
const variable = VAR4.findVariable(topLevelId, context.sourceCode.getScope(topLevelId));
|
|
36
|
-
const variableNode = VAR4.
|
|
36
|
+
const variableNode = VAR4.getVariableInitNode(variable, 0);
|
|
37
37
|
if (variableNode == null) return false;
|
|
38
38
|
if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
39
39
|
if (!isReactHookCallWithNameAlias(context, name3, hookAlias)(variableNode)) return false;
|
|
@@ -188,7 +188,8 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
188
188
|
}
|
|
189
189
|
match(getCallKind(node)).with("setState", () => {
|
|
190
190
|
switch (true) {
|
|
191
|
-
case
|
|
191
|
+
case pEntry.node === setupFunction:
|
|
192
|
+
case (pEntry.kind === "immediate" && AST.findParentNode(pEntry.node, AST.isFunction) === setupFunction): {
|
|
192
193
|
onViolation(context, node, {
|
|
193
194
|
name: context.sourceCode.getText(node.callee)
|
|
194
195
|
});
|
|
@@ -249,7 +250,7 @@ function useNoDirectSetStateInUseEffect(context, options) {
|
|
|
249
250
|
},
|
|
250
251
|
"Program:exit"() {
|
|
251
252
|
const getSetStateCalls = (id, initialScope) => {
|
|
252
|
-
const node = VAR4.
|
|
253
|
+
const node = VAR4.getVariableInitNode(VAR4.findVariable(id, initialScope), 0);
|
|
253
254
|
switch (node?.type) {
|
|
254
255
|
case AST_NODE_TYPES.ArrowFunctionExpression:
|
|
255
256
|
case AST_NODE_TYPES.FunctionDeclaration:
|
|
@@ -390,7 +391,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
390
391
|
}
|
|
391
392
|
const hasEmptyDeps = match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
392
393
|
const variable = VAR4.findVariable(n.name, initialScope);
|
|
393
|
-
const variableNode = VAR4.
|
|
394
|
+
const variableNode = VAR4.getVariableInitNode(variable, 0);
|
|
394
395
|
if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) {
|
|
395
396
|
return false;
|
|
396
397
|
}
|
|
@@ -406,7 +407,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
406
407
|
return n;
|
|
407
408
|
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
408
409
|
const variable = VAR4.findVariable(n.name, initialScope);
|
|
409
|
-
const variableNode = VAR4.
|
|
410
|
+
const variableNode = VAR4.getVariableInitNode(variable, 0);
|
|
410
411
|
if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) {
|
|
411
412
|
return _;
|
|
412
413
|
}
|
|
@@ -473,7 +474,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
473
474
|
}
|
|
474
475
|
const hasEmptyDeps = match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
475
476
|
const variable = VAR4.findVariable(n.name, initialScope);
|
|
476
|
-
const variableNode = VAR4.
|
|
477
|
+
const variableNode = VAR4.getVariableInitNode(variable, 0);
|
|
477
478
|
if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) {
|
|
478
479
|
return false;
|
|
479
480
|
}
|
|
@@ -489,7 +490,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
489
490
|
return n;
|
|
490
491
|
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
491
492
|
const variable = VAR4.findVariable(n.name, initialScope);
|
|
492
|
-
const variableNode = VAR4.
|
|
493
|
+
const variableNode = VAR4.getVariableInitNode(variable, 0);
|
|
493
494
|
if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) {
|
|
494
495
|
return _;
|
|
495
496
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.2-beta.1",
|
|
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.26.0",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.6.2",
|
|
53
|
-
"@eslint-react/ast": "1.30.
|
|
54
|
-
"@eslint-react/core": "1.30.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/ast": "1.30.2-beta.1",
|
|
54
|
+
"@eslint-react/core": "1.30.2-beta.1",
|
|
55
|
+
"@eslint-react/jsx": "1.30.2-beta.1",
|
|
56
|
+
"@eslint-react/shared": "1.30.2-beta.1",
|
|
57
|
+
"@eslint-react/var": "1.30.2-beta.1",
|
|
58
|
+
"@eslint-react/eff": "1.30.2-beta.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.0.10",
|