eslint-plugin-react-web-api 5.3.0-next.2 → 5.3.1-beta.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 +28 -18
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region package.json
|
|
30
30
|
var name$1 = "eslint-plugin-react-web-api";
|
|
31
|
-
var version = "5.3.
|
|
31
|
+
var version = "5.3.1-beta.0";
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/types/component-phase.ts
|
|
@@ -110,9 +110,10 @@ function getOptions(context, node) {
|
|
|
110
110
|
//#region src/rules/no-leaked-event-listener/no-leaked-event-listener.ts
|
|
111
111
|
const RULE_NAME$4 = "no-leaked-event-listener";
|
|
112
112
|
function getCallKind$4(node) {
|
|
113
|
+
const callee = Extract.unwrap(node.callee);
|
|
113
114
|
switch (true) {
|
|
114
|
-
case
|
|
115
|
-
case
|
|
115
|
+
case callee.type === AST_NODE_TYPES.Identifier && isMatching(P.union("addEventListener", "removeEventListener", "abort"))(callee.name): return callee.name;
|
|
116
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && isMatching(P.union("addEventListener", "removeEventListener", "abort"))(callee.property.name): return callee.property.name;
|
|
116
117
|
default: return "other";
|
|
117
118
|
}
|
|
118
119
|
}
|
|
@@ -177,8 +178,9 @@ function create$4(context) {
|
|
|
177
178
|
const fKind = fEntries.findLast((x) => x.kind !== "other")?.kind;
|
|
178
179
|
if (fKind == null) return;
|
|
179
180
|
if (!ComponentPhaseRelevance.has(fKind)) return;
|
|
181
|
+
const unwrappedCallee = Extract.unwrap(node.callee);
|
|
180
182
|
match(getCallKind$4(node)).with("addEventListener", (callKind) => {
|
|
181
|
-
if (
|
|
183
|
+
if (unwrappedCallee.type === AST_NODE_TYPES.MemberExpression && unwrappedCallee.object.type === AST_NODE_TYPES.Identifier && core.isAPIFromReactNative(unwrappedCallee.object.name, context.sourceCode.getScope(node))) return;
|
|
182
184
|
const [type, listener, options] = node.arguments;
|
|
183
185
|
if (type == null || listener == null) return;
|
|
184
186
|
const opts = options == null ? defaultOptions : getOptions(context, options);
|
|
@@ -261,11 +263,12 @@ function resolveToObjectExpression(context, node) {
|
|
|
261
263
|
//#region src/rules/no-leaked-fetch/no-leaked-fetch.ts
|
|
262
264
|
const RULE_NAME$3 = "no-leaked-fetch";
|
|
263
265
|
function getCallKind$3(node) {
|
|
266
|
+
const callee = Extract.unwrap(node.callee);
|
|
264
267
|
switch (true) {
|
|
265
|
-
case
|
|
266
|
-
case
|
|
267
|
-
case
|
|
268
|
-
case
|
|
268
|
+
case callee.type === AST_NODE_TYPES.Identifier && callee.name === "fetch": return "fetch";
|
|
269
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "fetch": return "fetch";
|
|
270
|
+
case callee.type === AST_NODE_TYPES.Identifier && callee.name === "abort": return "abort";
|
|
271
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "abort": return "abort";
|
|
269
272
|
default: return "other";
|
|
270
273
|
}
|
|
271
274
|
}
|
|
@@ -317,7 +320,8 @@ function getFetchController(context, node) {
|
|
|
317
320
|
return getControllerFromSignal(context, signalProp.value);
|
|
318
321
|
}
|
|
319
322
|
function getAbortController(node) {
|
|
320
|
-
|
|
323
|
+
const callee = Extract.unwrap(node.callee);
|
|
324
|
+
if (callee.type === AST_NODE_TYPES.MemberExpression) return callee.object;
|
|
321
325
|
return null;
|
|
322
326
|
}
|
|
323
327
|
var no_leaked_fetch_default = createRule({
|
|
@@ -403,9 +407,10 @@ function create$3(context) {
|
|
|
403
407
|
//#region src/rules/no-leaked-interval/no-leaked-interval.ts
|
|
404
408
|
const RULE_NAME$2 = "no-leaked-interval";
|
|
405
409
|
function getCallKind$2(node) {
|
|
410
|
+
const callee = Extract.unwrap(node.callee);
|
|
406
411
|
switch (true) {
|
|
407
|
-
case
|
|
408
|
-
case
|
|
412
|
+
case callee.type === AST_NODE_TYPES.Identifier && isMatching(P.union("setInterval", "clearInterval"))(callee.name): return callee.name;
|
|
413
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && isMatching(P.union("setInterval", "clearInterval"))(callee.property.name): return callee.property.name;
|
|
409
414
|
default: return "other";
|
|
410
415
|
}
|
|
411
416
|
}
|
|
@@ -652,7 +657,9 @@ const isConditional = isOneOf([
|
|
|
652
657
|
AST_NODE_TYPES.ConditionalExpression
|
|
653
658
|
]);
|
|
654
659
|
function isNewResizeObserver(node) {
|
|
655
|
-
|
|
660
|
+
if (node?.type !== AST_NODE_TYPES.NewExpression) return false;
|
|
661
|
+
const callee = Extract.unwrap(node.callee);
|
|
662
|
+
return callee.type === AST_NODE_TYPES.Identifier && callee.name === "ResizeObserver";
|
|
656
663
|
}
|
|
657
664
|
function isFromObserver(context, node) {
|
|
658
665
|
switch (true) {
|
|
@@ -669,9 +676,10 @@ function isFromObserver(context, node) {
|
|
|
669
676
|
//#region src/rules/no-leaked-resize-observer/no-leaked-resize-observer.ts
|
|
670
677
|
const RULE_NAME$1 = "no-leaked-resize-observer";
|
|
671
678
|
function getCallKind$1(context, node) {
|
|
679
|
+
const callee = Extract.unwrap(node.callee);
|
|
672
680
|
switch (true) {
|
|
673
|
-
case
|
|
674
|
-
case
|
|
681
|
+
case callee.type === AST_NODE_TYPES.Identifier && isMatching(P.union("observe", "unobserve", "disconnect"))(callee.name) && isFromObserver(context, callee): return callee.name;
|
|
682
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && isMatching(P.union("observe", "unobserve", "disconnect"))(callee.property.name) && isFromObserver(context, callee): return callee.property.name;
|
|
675
683
|
default: return "other";
|
|
676
684
|
}
|
|
677
685
|
}
|
|
@@ -712,10 +720,11 @@ function create$1(context) {
|
|
|
712
720
|
fEntries.pop();
|
|
713
721
|
},
|
|
714
722
|
["CallExpression"](node) {
|
|
715
|
-
|
|
723
|
+
const unwrappedCallee = Extract.unwrap(node.callee);
|
|
724
|
+
if (unwrappedCallee.type !== AST_NODE_TYPES.MemberExpression) return;
|
|
716
725
|
const fKind = fEntries.findLast((x) => x.kind !== "other")?.kind;
|
|
717
726
|
if (fKind == null || !ComponentPhaseRelevance.has(fKind)) return;
|
|
718
|
-
const { object } =
|
|
727
|
+
const { object } = unwrappedCallee;
|
|
719
728
|
match(getCallKind$1(context, node)).with("disconnect", () => {
|
|
720
729
|
dEntries.push({
|
|
721
730
|
kind: "ResizeObserver",
|
|
@@ -801,9 +810,10 @@ function create$1(context) {
|
|
|
801
810
|
//#region src/rules/no-leaked-timeout/no-leaked-timeout.ts
|
|
802
811
|
const RULE_NAME = "no-leaked-timeout";
|
|
803
812
|
function getCallKind(node) {
|
|
813
|
+
const callee = Extract.unwrap(node.callee);
|
|
804
814
|
switch (true) {
|
|
805
|
-
case
|
|
806
|
-
case
|
|
815
|
+
case callee.type === AST_NODE_TYPES.Identifier && isMatching(P.union("setTimeout", "clearTimeout"))(callee.name): return callee.name;
|
|
816
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.property.type === AST_NODE_TYPES.Identifier && isMatching(P.union("setTimeout", "clearTimeout"))(callee.property.name): return callee.property.name;
|
|
807
817
|
default: return "other";
|
|
808
818
|
}
|
|
809
819
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.1-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@typescript-eslint/utils": "^8.58.2",
|
|
44
44
|
"birecord": "^0.1.1",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/ast": "5.3.
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/var": "5.3.
|
|
50
|
-
"@eslint-react/
|
|
46
|
+
"@eslint-react/ast": "5.3.1-beta.0",
|
|
47
|
+
"@eslint-react/eslint": "5.3.1-beta.0",
|
|
48
|
+
"@eslint-react/shared": "5.3.1-beta.0",
|
|
49
|
+
"@eslint-react/var": "5.3.1-beta.0",
|
|
50
|
+
"@eslint-react/core": "5.3.1-beta.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|