eslint-plugin-react-hooks-extra 1.5.26-beta.2 → 1.5.26-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 +17 -5
- package/dist/index.mjs +17 -5
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var astUtils = require('@typescript-eslint/utils/ast-utils');
|
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
11
|
var name = "eslint-plugin-react-hooks-extra";
|
|
12
|
-
var version = "1.5.26-beta.
|
|
12
|
+
var version = "1.5.26-beta.4";
|
|
13
13
|
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
14
14
|
|
|
15
15
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -271,14 +271,20 @@ var ensure_use_callback_has_non_empty_deps_default = createRule({
|
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
const isReferencedToComponentScope = tools.F.pipe(
|
|
274
|
-
$(cb).with({ type: ast.NodeType.ArrowFunctionExpression },
|
|
274
|
+
$(cb).with({ type: ast.NodeType.ArrowFunctionExpression }, (n2) => {
|
|
275
|
+
if (n2.body.type === ast.NodeType.ArrowFunctionExpression) {
|
|
276
|
+
return tools.O.some(n2.body);
|
|
277
|
+
}
|
|
278
|
+
return tools.O.some(n2);
|
|
279
|
+
}).with({ type: ast.NodeType.FunctionExpression }, tools.O.some).with({ type: ast.NodeType.Identifier }, (n2) => {
|
|
275
280
|
return tools.F.pipe(
|
|
276
281
|
_var.findVariable(n2.name, initialScope),
|
|
277
282
|
tools.O.flatMap(_var.getVariableInit(0)),
|
|
278
283
|
tools.O.filter(ast.isFunction)
|
|
279
284
|
);
|
|
280
285
|
}).otherwise(tools.O.none),
|
|
281
|
-
tools.O.map((n2) => context.sourceCode.getScope(n2)
|
|
286
|
+
tools.O.map((n2) => context.sourceCode.getScope(n2)),
|
|
287
|
+
tools.O.map((s2) => [...s2.childScopes, s2].flatMap((x2) => x2.references)),
|
|
282
288
|
tools.O.exists((refs) => refs.some((x2) => x2.resolved?.scope.block === component))
|
|
283
289
|
);
|
|
284
290
|
if (isReferencedToComponentScope) return;
|
|
@@ -343,14 +349,20 @@ var ensure_use_memo_has_non_empty_deps_default = createRule({
|
|
|
343
349
|
return;
|
|
344
350
|
}
|
|
345
351
|
const isReferencedToComponentScope = tools.F.pipe(
|
|
346
|
-
$(cb).with({ type: ast.NodeType.ArrowFunctionExpression },
|
|
352
|
+
$(cb).with({ type: ast.NodeType.ArrowFunctionExpression }, (n2) => {
|
|
353
|
+
if (n2.body.type === ast.NodeType.ArrowFunctionExpression) {
|
|
354
|
+
return tools.O.some(n2.body);
|
|
355
|
+
}
|
|
356
|
+
return tools.O.some(n2);
|
|
357
|
+
}).with({ type: ast.NodeType.FunctionExpression }, tools.O.some).with({ type: ast.NodeType.Identifier }, (n2) => {
|
|
347
358
|
return tools.F.pipe(
|
|
348
359
|
_var.findVariable(n2.name, initialScope),
|
|
349
360
|
tools.O.flatMap(_var.getVariableInit(0)),
|
|
350
361
|
tools.O.filter(ast.isFunction)
|
|
351
362
|
);
|
|
352
363
|
}).otherwise(tools.O.none),
|
|
353
|
-
tools.O.map((n2) => context.sourceCode.getScope(n2)
|
|
364
|
+
tools.O.map((n2) => context.sourceCode.getScope(n2)),
|
|
365
|
+
tools.O.map((s2) => [...s2.childScopes, s2].flatMap((x2) => x2.references)),
|
|
354
366
|
tools.O.exists((refs) => refs.some((x2) => x2.resolved?.scope.block === component))
|
|
355
367
|
);
|
|
356
368
|
if (isReferencedToComponentScope) return;
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { getStaticValue } from '@typescript-eslint/utils/ast-utils';
|
|
|
7
7
|
|
|
8
8
|
// package.json
|
|
9
9
|
var name = "eslint-plugin-react-hooks-extra";
|
|
10
|
-
var version = "1.5.26-beta.
|
|
10
|
+
var version = "1.5.26-beta.4";
|
|
11
11
|
var createRule = createRuleForPlugin("hooks-extra");
|
|
12
12
|
|
|
13
13
|
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
@@ -269,14 +269,20 @@ var ensure_use_callback_has_non_empty_deps_default = createRule({
|
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
const isReferencedToComponentScope = F.pipe(
|
|
272
|
-
$(cb).with({ type: NodeType.ArrowFunctionExpression },
|
|
272
|
+
$(cb).with({ type: NodeType.ArrowFunctionExpression }, (n2) => {
|
|
273
|
+
if (n2.body.type === NodeType.ArrowFunctionExpression) {
|
|
274
|
+
return O.some(n2.body);
|
|
275
|
+
}
|
|
276
|
+
return O.some(n2);
|
|
277
|
+
}).with({ type: NodeType.FunctionExpression }, O.some).with({ type: NodeType.Identifier }, (n2) => {
|
|
273
278
|
return F.pipe(
|
|
274
279
|
findVariable(n2.name, initialScope),
|
|
275
280
|
O.flatMap(getVariableInit(0)),
|
|
276
281
|
O.filter(isFunction)
|
|
277
282
|
);
|
|
278
283
|
}).otherwise(O.none),
|
|
279
|
-
O.map((n2) => context.sourceCode.getScope(n2)
|
|
284
|
+
O.map((n2) => context.sourceCode.getScope(n2)),
|
|
285
|
+
O.map((s2) => [...s2.childScopes, s2].flatMap((x2) => x2.references)),
|
|
280
286
|
O.exists((refs) => refs.some((x2) => x2.resolved?.scope.block === component))
|
|
281
287
|
);
|
|
282
288
|
if (isReferencedToComponentScope) return;
|
|
@@ -341,14 +347,20 @@ var ensure_use_memo_has_non_empty_deps_default = createRule({
|
|
|
341
347
|
return;
|
|
342
348
|
}
|
|
343
349
|
const isReferencedToComponentScope = F.pipe(
|
|
344
|
-
$(cb).with({ type: NodeType.ArrowFunctionExpression },
|
|
350
|
+
$(cb).with({ type: NodeType.ArrowFunctionExpression }, (n2) => {
|
|
351
|
+
if (n2.body.type === NodeType.ArrowFunctionExpression) {
|
|
352
|
+
return O.some(n2.body);
|
|
353
|
+
}
|
|
354
|
+
return O.some(n2);
|
|
355
|
+
}).with({ type: NodeType.FunctionExpression }, O.some).with({ type: NodeType.Identifier }, (n2) => {
|
|
345
356
|
return F.pipe(
|
|
346
357
|
findVariable(n2.name, initialScope),
|
|
347
358
|
O.flatMap(getVariableInit(0)),
|
|
348
359
|
O.filter(isFunction)
|
|
349
360
|
);
|
|
350
361
|
}).otherwise(O.none),
|
|
351
|
-
O.map((n2) => context.sourceCode.getScope(n2)
|
|
362
|
+
O.map((n2) => context.sourceCode.getScope(n2)),
|
|
363
|
+
O.map((s2) => [...s2.childScopes, s2].flatMap((x2) => x2.references)),
|
|
352
364
|
O.exists((refs) => refs.some((x2) => x2.resolved?.scope.block === component))
|
|
353
365
|
);
|
|
354
366
|
if (isReferencedToComponentScope) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks-extra",
|
|
3
|
-
"version": "1.5.26-beta.
|
|
3
|
+
"version": "1.5.26-beta.4",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"@typescript-eslint/type-utils": "^7.16.0",
|
|
40
40
|
"@typescript-eslint/types": "^7.16.0",
|
|
41
41
|
"@typescript-eslint/utils": "^7.16.0",
|
|
42
|
-
"@eslint-react/ast": "1.5.26-beta.
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/types": "1.5.26-beta.
|
|
48
|
-
"@eslint-react/var": "1.5.26-beta.
|
|
42
|
+
"@eslint-react/ast": "1.5.26-beta.4",
|
|
43
|
+
"@eslint-react/core": "1.5.26-beta.4",
|
|
44
|
+
"@eslint-react/shared": "1.5.26-beta.4",
|
|
45
|
+
"@eslint-react/tools": "1.5.26-beta.4",
|
|
46
|
+
"@eslint-react/jsx": "1.5.26-beta.4",
|
|
47
|
+
"@eslint-react/types": "1.5.26-beta.4",
|
|
48
|
+
"@eslint-react/var": "1.5.26-beta.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"string-ts": "2.2.0",
|