eslint-plugin-react-web-api 1.17.2-next.5 → 1.17.2-next.7
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 +14 -11
- package/dist/index.mjs +11 -8
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
|
35
35
|
|
|
36
36
|
// package.json
|
|
37
37
|
var name = "eslint-plugin-react-web-api";
|
|
38
|
-
var version = "1.17.2-next.
|
|
38
|
+
var version = "1.17.2-next.7";
|
|
39
39
|
var createRule = shared.createRuleForPlugin("web-api");
|
|
40
40
|
function getInstanceID(node, prev) {
|
|
41
41
|
switch (true) {
|
|
@@ -51,6 +51,9 @@ function getInstanceID(node, prev) {
|
|
|
51
51
|
return getInstanceID(node.parent, node);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
function getPhaseKindOfFunction(node) {
|
|
55
|
+
return tsPattern.match(node).when(core.isSetupFunction, () => tools.O.some("setup")).when(core.isCleanupFunction, () => tools.O.some("cleanup")).when(core.isComponentDidMountFunction, () => tools.O.some("mount")).when(core.isComponentWillUnmountFunction, () => tools.O.some("unmount")).otherwise(tools.O.none);
|
|
56
|
+
}
|
|
54
57
|
function isInstanceIDEqual(a, b, context) {
|
|
55
58
|
return AST2__namespace.isNodeEqual(a, b) || VAR2__namespace.isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
|
|
56
59
|
}
|
|
@@ -75,7 +78,7 @@ function getCallKind(node) {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
function getFunctionKind(node) {
|
|
78
|
-
return tools.O.getOrElse(
|
|
81
|
+
return tools.O.getOrElse(getPhaseKindOfFunction(node), tools.F.constant("other"));
|
|
79
82
|
}
|
|
80
83
|
function getOptions(node, initialScope) {
|
|
81
84
|
const findProp = (properties, propName) => {
|
|
@@ -201,7 +204,7 @@ var no_leaked_event_listener_default = createRule({
|
|
|
201
204
|
["CallExpression"](node) {
|
|
202
205
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
203
206
|
if (!fNode || !fKind) return;
|
|
204
|
-
if (!core.
|
|
207
|
+
if (!core.ERPhaseRelevance.has(fKind)) return;
|
|
205
208
|
tsPattern.match(getCallKind(node)).with("addEventListener", (callKind) => {
|
|
206
209
|
const [type, listener, options] = node.arguments;
|
|
207
210
|
if (!type || !listener) return;
|
|
@@ -298,7 +301,7 @@ var no_leaked_interval_default = createRule({
|
|
|
298
301
|
});
|
|
299
302
|
return {
|
|
300
303
|
[":function"](node) {
|
|
301
|
-
const fKind = tools.O.getOrElse(
|
|
304
|
+
const fKind = tools.O.getOrElse(getPhaseKindOfFunction(node), () => "other");
|
|
302
305
|
fStack.push([node, fKind]);
|
|
303
306
|
},
|
|
304
307
|
[":function:exit"]() {
|
|
@@ -309,7 +312,7 @@ var no_leaked_interval_default = createRule({
|
|
|
309
312
|
case "clearInterval": {
|
|
310
313
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
311
314
|
if (!fNode || !fKind) break;
|
|
312
|
-
if (!core.
|
|
315
|
+
if (!core.ERPhaseRelevance.has(fKind)) break;
|
|
313
316
|
const [intervalIdNode] = node.arguments;
|
|
314
317
|
if (!intervalIdNode) break;
|
|
315
318
|
cEntries.push({
|
|
@@ -324,7 +327,7 @@ var no_leaked_interval_default = createRule({
|
|
|
324
327
|
case "setInterval": {
|
|
325
328
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
326
329
|
if (!fNode || !fKind) break;
|
|
327
|
-
if (!core.
|
|
330
|
+
if (!core.ERPhaseRelevance.has(fKind)) break;
|
|
328
331
|
const intervalIdNode = tools.O.getOrNull(VAR2__namespace.getVariableDeclaratorID(node));
|
|
329
332
|
if (!intervalIdNode) {
|
|
330
333
|
context.report({
|
|
@@ -404,7 +407,7 @@ function getCallKind3(node, context) {
|
|
|
404
407
|
}
|
|
405
408
|
}
|
|
406
409
|
function getFunctionKind2(node) {
|
|
407
|
-
return tools.O.getOrElse(
|
|
410
|
+
return tools.O.getOrElse(getPhaseKindOfFunction(node), tools.F.constant("other"));
|
|
408
411
|
}
|
|
409
412
|
var no_leaked_resize_observer_default = createRule({
|
|
410
413
|
meta: {
|
|
@@ -438,7 +441,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
438
441
|
["CallExpression"](node) {
|
|
439
442
|
const [_, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
440
443
|
if (node.callee.type !== utils.AST_NODE_TYPES.MemberExpression) return;
|
|
441
|
-
if (!core.
|
|
444
|
+
if (!core.ERPhaseRelevance.has(fKind)) return;
|
|
442
445
|
const { object } = node.callee;
|
|
443
446
|
tsPattern.match(getCallKind3(node, context)).with("disconnect", () => {
|
|
444
447
|
dEntries.push(
|
|
@@ -480,7 +483,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
480
483
|
},
|
|
481
484
|
["NewExpression"](node) {
|
|
482
485
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
483
|
-
if (!fNode || !core.
|
|
486
|
+
if (!fNode || !core.ERPhaseRelevance.has(fKind)) return;
|
|
484
487
|
if (!isNewResizeObserver(node)) return;
|
|
485
488
|
const id = getInstanceID(node);
|
|
486
489
|
if (tools.O.isNone(id)) {
|
|
@@ -549,7 +552,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
549
552
|
});
|
|
550
553
|
return {
|
|
551
554
|
[":function"](node) {
|
|
552
|
-
const fKind = tools.O.getOrElse(
|
|
555
|
+
const fKind = tools.O.getOrElse(getPhaseKindOfFunction(node), () => "other");
|
|
553
556
|
fStack.push([node, fKind]);
|
|
554
557
|
},
|
|
555
558
|
[":function:exit"]() {
|
|
@@ -558,7 +561,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
558
561
|
["CallExpression"](node) {
|
|
559
562
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
560
563
|
if (!fNode || !fKind) return;
|
|
561
|
-
if (!core.
|
|
564
|
+
if (!core.ERPhaseRelevance.has(fKind)) return;
|
|
562
565
|
switch (getCallKind4(node)) {
|
|
563
566
|
case "clearTimeout": {
|
|
564
567
|
const [timeoutIdNode] = node.arguments;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AST2 from '@eslint-react/ast';
|
|
2
|
-
import { isInversePhase,
|
|
2
|
+
import { isInversePhase, ERPhaseRelevance, isSetupFunction, isCleanupFunction, isComponentDidMountFunction, isComponentWillUnmountFunction } from '@eslint-react/core';
|
|
3
3
|
import * as JSX from '@eslint-react/jsx';
|
|
4
4
|
import { Data, O, F, or, not, isBoolean } from '@eslint-react/tools';
|
|
5
5
|
import * as VAR2 from '@eslint-react/var';
|
|
@@ -11,7 +11,7 @@ import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/types';
|
|
|
11
11
|
|
|
12
12
|
// package.json
|
|
13
13
|
var name = "eslint-plugin-react-web-api";
|
|
14
|
-
var version = "1.17.2-next.
|
|
14
|
+
var version = "1.17.2-next.7";
|
|
15
15
|
var createRule = createRuleForPlugin("web-api");
|
|
16
16
|
function getInstanceID(node, prev) {
|
|
17
17
|
switch (true) {
|
|
@@ -27,6 +27,9 @@ function getInstanceID(node, prev) {
|
|
|
27
27
|
return getInstanceID(node.parent, node);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
function getPhaseKindOfFunction(node) {
|
|
31
|
+
return match(node).when(isSetupFunction, () => O.some("setup")).when(isCleanupFunction, () => O.some("cleanup")).when(isComponentDidMountFunction, () => O.some("mount")).when(isComponentWillUnmountFunction, () => O.some("unmount")).otherwise(O.none);
|
|
32
|
+
}
|
|
30
33
|
function isInstanceIDEqual(a, b, context) {
|
|
31
34
|
return AST2.isNodeEqual(a, b) || VAR2.isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
|
|
32
35
|
}
|
|
@@ -177,7 +180,7 @@ var no_leaked_event_listener_default = createRule({
|
|
|
177
180
|
["CallExpression"](node) {
|
|
178
181
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
179
182
|
if (!fNode || !fKind) return;
|
|
180
|
-
if (!
|
|
183
|
+
if (!ERPhaseRelevance.has(fKind)) return;
|
|
181
184
|
match(getCallKind(node)).with("addEventListener", (callKind) => {
|
|
182
185
|
const [type, listener, options] = node.arguments;
|
|
183
186
|
if (!type || !listener) return;
|
|
@@ -285,7 +288,7 @@ var no_leaked_interval_default = createRule({
|
|
|
285
288
|
case "clearInterval": {
|
|
286
289
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
287
290
|
if (!fNode || !fKind) break;
|
|
288
|
-
if (!
|
|
291
|
+
if (!ERPhaseRelevance.has(fKind)) break;
|
|
289
292
|
const [intervalIdNode] = node.arguments;
|
|
290
293
|
if (!intervalIdNode) break;
|
|
291
294
|
cEntries.push({
|
|
@@ -300,7 +303,7 @@ var no_leaked_interval_default = createRule({
|
|
|
300
303
|
case "setInterval": {
|
|
301
304
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
302
305
|
if (!fNode || !fKind) break;
|
|
303
|
-
if (!
|
|
306
|
+
if (!ERPhaseRelevance.has(fKind)) break;
|
|
304
307
|
const intervalIdNode = O.getOrNull(VAR2.getVariableDeclaratorID(node));
|
|
305
308
|
if (!intervalIdNode) {
|
|
306
309
|
context.report({
|
|
@@ -414,7 +417,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
414
417
|
["CallExpression"](node) {
|
|
415
418
|
const [_, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
416
419
|
if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
417
|
-
if (!
|
|
420
|
+
if (!ERPhaseRelevance.has(fKind)) return;
|
|
418
421
|
const { object } = node.callee;
|
|
419
422
|
match(getCallKind3(node, context)).with("disconnect", () => {
|
|
420
423
|
dEntries.push(
|
|
@@ -456,7 +459,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
456
459
|
},
|
|
457
460
|
["NewExpression"](node) {
|
|
458
461
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
459
|
-
if (!fNode || !
|
|
462
|
+
if (!fNode || !ERPhaseRelevance.has(fKind)) return;
|
|
460
463
|
if (!isNewResizeObserver(node)) return;
|
|
461
464
|
const id = getInstanceID(node);
|
|
462
465
|
if (O.isNone(id)) {
|
|
@@ -534,7 +537,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
534
537
|
["CallExpression"](node) {
|
|
535
538
|
const [fNode, fKind] = fStack.findLast((f) => f.at(1) !== "other") ?? [];
|
|
536
539
|
if (!fNode || !fKind) return;
|
|
537
|
-
if (!
|
|
540
|
+
if (!ERPhaseRelevance.has(fKind)) return;
|
|
538
541
|
switch (getCallKind4(node)) {
|
|
539
542
|
case "clearTimeout": {
|
|
540
543
|
const [timeoutIdNode] = node.arguments;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "1.17.2-next.
|
|
3
|
+
"version": "1.17.2-next.7",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@typescript-eslint/utils": "^8.16.0",
|
|
48
48
|
"birecord": "^0.1.1",
|
|
49
49
|
"ts-pattern": "^5.5.0",
|
|
50
|
-
"@eslint-react/ast": "1.17.2-next.
|
|
51
|
-
"@eslint-react/core": "1.17.2-next.
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/var": "1.17.2-next.
|
|
50
|
+
"@eslint-react/ast": "1.17.2-next.7",
|
|
51
|
+
"@eslint-react/core": "1.17.2-next.7",
|
|
52
|
+
"@eslint-react/tools": "1.17.2-next.7",
|
|
53
|
+
"@eslint-react/jsx": "1.17.2-next.7",
|
|
54
|
+
"@eslint-react/types": "1.17.2-next.7",
|
|
55
|
+
"@eslint-react/shared": "1.17.2-next.7",
|
|
56
|
+
"@eslint-react/var": "1.17.2-next.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^18.3.12",
|