eslint-plugin-react-hooks-extra 1.22.1 → 1.22.2-beta.11
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 +11 -15
- package/dist/index.mjs +12 -16
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var VAR5__namespace = /*#__PURE__*/_interopNamespace(VAR5);
|
|
|
31
31
|
|
|
32
32
|
// package.json
|
|
33
33
|
var name = "eslint-plugin-react-hooks-extra";
|
|
34
|
-
var version = "1.22.
|
|
34
|
+
var version = "1.22.2-beta.11";
|
|
35
35
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
36
36
|
function isFromHookCall(name2, context, settings, predicate = eff.F.constTrue) {
|
|
37
37
|
const hookAlias = settings.additionalHooks?.[name2] ?? [];
|
|
@@ -137,7 +137,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
137
137
|
const isSetStateCall = isSetFunctionCall(context, settings);
|
|
138
138
|
const isIdFromUseStateCall = isFromUseStateCall(context, settings);
|
|
139
139
|
const functionStack = [];
|
|
140
|
-
const setupFunctionRef = eff.
|
|
140
|
+
const setupFunctionRef = { current: eff.O.none() };
|
|
141
141
|
const setupFunctionIdentifiers = [];
|
|
142
142
|
const indirectFunctionCalls = [];
|
|
143
143
|
const indirectSetStateCalls = /* @__PURE__ */ new WeakMap();
|
|
@@ -145,10 +145,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
145
145
|
const indirectSetStateCallsAsSetups = /* @__PURE__ */ new Map();
|
|
146
146
|
const indirectSetStateCallsInHooks = /* @__PURE__ */ new WeakMap();
|
|
147
147
|
const onSetupFunctionEnter = (node) => {
|
|
148
|
-
eff.
|
|
148
|
+
setupFunctionRef.current = eff.O.some(node);
|
|
149
149
|
};
|
|
150
150
|
const onSetupFunctionExit = (node) => {
|
|
151
|
-
eff.
|
|
151
|
+
setupFunctionRef.current = eff.O.filter(setupFunctionRef.current, (current) => current !== node);
|
|
152
152
|
};
|
|
153
153
|
function isSetupFunction(node) {
|
|
154
154
|
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
@@ -171,7 +171,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
171
171
|
if (functionKind === "setup") onSetupFunctionExit(node);
|
|
172
172
|
},
|
|
173
173
|
CallExpression(node) {
|
|
174
|
-
const effectFn = eff.
|
|
174
|
+
const effectFn = eff.O.getOrNull(setupFunctionRef.current);
|
|
175
175
|
const [parentFn, parentFnKind] = functionStack.at(-1) ?? [];
|
|
176
176
|
if (parentFn?.async) return;
|
|
177
177
|
tsPattern.match(getCallKind(node)).with("setState", () => {
|
|
@@ -322,7 +322,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
322
322
|
const isSetStateCall = isSetFunctionCall(context, settings);
|
|
323
323
|
const isIdFromUseStateCall = isFromUseStateCall(context, settings);
|
|
324
324
|
const functionStack = [];
|
|
325
|
-
const setupFunctionRef = eff.
|
|
325
|
+
const setupFunctionRef = { current: eff.O.none() };
|
|
326
326
|
const setupFunctionIdentifiers = [];
|
|
327
327
|
const indirectFunctionCalls = [];
|
|
328
328
|
const indirectSetStateCalls = /* @__PURE__ */ new WeakMap();
|
|
@@ -330,10 +330,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
330
330
|
const indirectSetStateCallsAsSetups = /* @__PURE__ */ new Map();
|
|
331
331
|
const indirectSetStateCallsInHooks = /* @__PURE__ */ new WeakMap();
|
|
332
332
|
const onSetupFunctionEnter = (node) => {
|
|
333
|
-
eff.
|
|
333
|
+
setupFunctionRef.current = eff.O.some(node);
|
|
334
334
|
};
|
|
335
335
|
const onSetupFunctionExit = (node) => {
|
|
336
|
-
eff.
|
|
336
|
+
setupFunctionRef.current = eff.O.filter(setupFunctionRef.current, (current) => current !== node);
|
|
337
337
|
};
|
|
338
338
|
function isSetupFunction(node) {
|
|
339
339
|
return node.parent?.type === types.AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
@@ -356,7 +356,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
356
356
|
if (functionKind === "setup") onSetupFunctionExit(node);
|
|
357
357
|
},
|
|
358
358
|
CallExpression(node) {
|
|
359
|
-
const effectFn = eff.
|
|
359
|
+
const effectFn = eff.O.getOrNull(setupFunctionRef.current);
|
|
360
360
|
const [parentFn, parentFnKind] = functionStack.at(-1) ?? [];
|
|
361
361
|
if (parentFn?.async) return;
|
|
362
362
|
tsPattern.match(getCallKind(node)).with("setState", () => {
|
|
@@ -499,9 +499,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
499
499
|
CallExpression(node) {
|
|
500
500
|
if (!core.isReactHookCall(node)) return;
|
|
501
501
|
const initialScope = context.sourceCode.getScope(node);
|
|
502
|
-
if (!core.isUseCallbackCall(node, context) && !alias.some(core.isReactHookCallWithNameLoose(node)))
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
502
|
+
if (!core.isUseCallbackCall(node, context) && !alias.some(core.isReactHookCallWithNameLoose(node))) return;
|
|
505
503
|
const scope = context.sourceCode.getScope(node);
|
|
506
504
|
const component = scope.block;
|
|
507
505
|
if (!AST2__namespace.isFunction(component)) return;
|
|
@@ -582,9 +580,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
582
580
|
CallExpression(node) {
|
|
583
581
|
if (!core.isReactHookCall(node)) return;
|
|
584
582
|
const initialScope = context.sourceCode.getScope(node);
|
|
585
|
-
if (!core.isUseMemoCall(node, context) && !alias.some(core.isReactHookCallWithNameLoose(node)))
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
583
|
+
if (!core.isUseMemoCall(node, context) && !alias.some(core.isReactHookCallWithNameLoose(node))) return;
|
|
588
584
|
const scope = context.sourceCode.getScope(node);
|
|
589
585
|
const component = scope.block;
|
|
590
586
|
if (!AST2__namespace.isFunction(component)) return;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AST2 from '@eslint-react/ast';
|
|
2
2
|
import { isReactHookCallWithNameAlias, isReactHookCall, isUseCallbackCall, isReactHookCallWithNameLoose, isUseMemoCall, useHookCollector, isUseStateCall, isReactHookName } from '@eslint-react/core';
|
|
3
|
-
import {
|
|
3
|
+
import { O, F } from '@eslint-react/eff';
|
|
4
4
|
import { createRuleForPlugin, decodeSettings } from '@eslint-react/shared';
|
|
5
5
|
import * as VAR5 from '@eslint-react/var';
|
|
6
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
@@ -8,7 +8,7 @@ import { match, isMatching } from 'ts-pattern';
|
|
|
8
8
|
|
|
9
9
|
// package.json
|
|
10
10
|
var name = "eslint-plugin-react-hooks-extra";
|
|
11
|
-
var version = "1.22.
|
|
11
|
+
var version = "1.22.2-beta.11";
|
|
12
12
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
13
13
|
function isFromHookCall(name2, context, settings, predicate = F.constTrue) {
|
|
14
14
|
const hookAlias = settings.additionalHooks?.[name2] ?? [];
|
|
@@ -114,7 +114,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
114
114
|
const isSetStateCall = isSetFunctionCall(context, settings);
|
|
115
115
|
const isIdFromUseStateCall = isFromUseStateCall(context, settings);
|
|
116
116
|
const functionStack = [];
|
|
117
|
-
const setupFunctionRef =
|
|
117
|
+
const setupFunctionRef = { current: O.none() };
|
|
118
118
|
const setupFunctionIdentifiers = [];
|
|
119
119
|
const indirectFunctionCalls = [];
|
|
120
120
|
const indirectSetStateCalls = /* @__PURE__ */ new WeakMap();
|
|
@@ -122,10 +122,10 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
122
122
|
const indirectSetStateCallsAsSetups = /* @__PURE__ */ new Map();
|
|
123
123
|
const indirectSetStateCallsInHooks = /* @__PURE__ */ new WeakMap();
|
|
124
124
|
const onSetupFunctionEnter = (node) => {
|
|
125
|
-
|
|
125
|
+
setupFunctionRef.current = O.some(node);
|
|
126
126
|
};
|
|
127
127
|
const onSetupFunctionExit = (node) => {
|
|
128
|
-
|
|
128
|
+
setupFunctionRef.current = O.filter(setupFunctionRef.current, (current) => current !== node);
|
|
129
129
|
};
|
|
130
130
|
function isSetupFunction(node) {
|
|
131
131
|
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
@@ -148,7 +148,7 @@ var no_direct_set_state_in_use_effect_default = createRule({
|
|
|
148
148
|
if (functionKind === "setup") onSetupFunctionExit(node);
|
|
149
149
|
},
|
|
150
150
|
CallExpression(node) {
|
|
151
|
-
const effectFn =
|
|
151
|
+
const effectFn = O.getOrNull(setupFunctionRef.current);
|
|
152
152
|
const [parentFn, parentFnKind] = functionStack.at(-1) ?? [];
|
|
153
153
|
if (parentFn?.async) return;
|
|
154
154
|
match(getCallKind(node)).with("setState", () => {
|
|
@@ -299,7 +299,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
299
299
|
const isSetStateCall = isSetFunctionCall(context, settings);
|
|
300
300
|
const isIdFromUseStateCall = isFromUseStateCall(context, settings);
|
|
301
301
|
const functionStack = [];
|
|
302
|
-
const setupFunctionRef =
|
|
302
|
+
const setupFunctionRef = { current: O.none() };
|
|
303
303
|
const setupFunctionIdentifiers = [];
|
|
304
304
|
const indirectFunctionCalls = [];
|
|
305
305
|
const indirectSetStateCalls = /* @__PURE__ */ new WeakMap();
|
|
@@ -307,10 +307,10 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
307
307
|
const indirectSetStateCallsAsSetups = /* @__PURE__ */ new Map();
|
|
308
308
|
const indirectSetStateCallsInHooks = /* @__PURE__ */ new WeakMap();
|
|
309
309
|
const onSetupFunctionEnter = (node) => {
|
|
310
|
-
|
|
310
|
+
setupFunctionRef.current = O.some(node);
|
|
311
311
|
};
|
|
312
312
|
const onSetupFunctionExit = (node) => {
|
|
313
|
-
|
|
313
|
+
setupFunctionRef.current = O.filter(setupFunctionRef.current, (current) => current !== node);
|
|
314
314
|
};
|
|
315
315
|
function isSetupFunction(node) {
|
|
316
316
|
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectLikeCall(node.parent);
|
|
@@ -333,7 +333,7 @@ var no_direct_set_state_in_use_layout_effect_default = createRule({
|
|
|
333
333
|
if (functionKind === "setup") onSetupFunctionExit(node);
|
|
334
334
|
},
|
|
335
335
|
CallExpression(node) {
|
|
336
|
-
const effectFn =
|
|
336
|
+
const effectFn = O.getOrNull(setupFunctionRef.current);
|
|
337
337
|
const [parentFn, parentFnKind] = functionStack.at(-1) ?? [];
|
|
338
338
|
if (parentFn?.async) return;
|
|
339
339
|
match(getCallKind(node)).with("setState", () => {
|
|
@@ -476,9 +476,7 @@ var no_unnecessary_use_callback_default = createRule({
|
|
|
476
476
|
CallExpression(node) {
|
|
477
477
|
if (!isReactHookCall(node)) return;
|
|
478
478
|
const initialScope = context.sourceCode.getScope(node);
|
|
479
|
-
if (!isUseCallbackCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node)))
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
479
|
+
if (!isUseCallbackCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) return;
|
|
482
480
|
const scope = context.sourceCode.getScope(node);
|
|
483
481
|
const component = scope.block;
|
|
484
482
|
if (!AST2.isFunction(component)) return;
|
|
@@ -559,9 +557,7 @@ var no_unnecessary_use_memo_default = createRule({
|
|
|
559
557
|
CallExpression(node) {
|
|
560
558
|
if (!isReactHookCall(node)) return;
|
|
561
559
|
const initialScope = context.sourceCode.getScope(node);
|
|
562
|
-
if (!isUseMemoCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node)))
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
560
|
+
if (!isUseMemoCall(node, context) && !alias.some(isReactHookCallWithNameLoose(node))) return;
|
|
565
561
|
const scope = context.sourceCode.getScope(node);
|
|
566
562
|
const component = scope.block;
|
|
567
563
|
if (!AST2.isFunction(component)) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.2-beta.11",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -11,18 +11,17 @@
|
|
|
11
11
|
"eslint-plugin",
|
|
12
12
|
"eslint-plugin-react-hooks-extra"
|
|
13
13
|
],
|
|
14
|
-
"homepage": "https://github.com/
|
|
14
|
+
"homepage": "https://github.com/rEl1cx/eslint-react",
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/rEl1cx/eslint-react/issues"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "git+https://github.com/rEl1cx/eslint-react.git",
|
|
21
21
|
"directory": "packages/plugins/eslint-plugin-react-hooks-extra"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Eva1ent<rel1cx@proton.me>",
|
|
25
|
-
"sideEffects": false,
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"import": {
|
|
@@ -37,7 +36,6 @@
|
|
|
37
36
|
"./package.json": "./package.json"
|
|
38
37
|
},
|
|
39
38
|
"main": "dist/index.js",
|
|
40
|
-
"module": "dist/index.mjs",
|
|
41
39
|
"types": "dist/index.d.ts",
|
|
42
40
|
"files": [
|
|
43
41
|
"dist",
|
|
@@ -50,13 +48,13 @@
|
|
|
50
48
|
"@typescript-eslint/utils": "^8.18.2",
|
|
51
49
|
"string-ts": "^2.2.0",
|
|
52
50
|
"ts-pattern": "^5.6.0",
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/
|
|
59
|
-
"@eslint-react/
|
|
51
|
+
"@eslint-react/ast": "1.22.2-beta.11",
|
|
52
|
+
"@eslint-react/core": "1.22.2-beta.11",
|
|
53
|
+
"@eslint-react/eff": "1.22.2-beta.11",
|
|
54
|
+
"@eslint-react/shared": "1.22.2-beta.11",
|
|
55
|
+
"@eslint-react/var": "1.22.2-beta.11",
|
|
56
|
+
"@eslint-react/jsx": "1.22.2-beta.11",
|
|
57
|
+
"@eslint-react/types": "1.22.2-beta.11"
|
|
60
58
|
},
|
|
61
59
|
"devDependencies": {
|
|
62
60
|
"@types/react": "^19.0.2",
|
|
@@ -83,6 +81,8 @@
|
|
|
83
81
|
"publishConfig": {
|
|
84
82
|
"access": "public"
|
|
85
83
|
},
|
|
84
|
+
"sideEffects": false,
|
|
85
|
+
"module": "dist/index.mjs",
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build": "tsup --dts-resolve",
|
|
88
88
|
"lint:publish": "publint",
|