eslint-plugin-react-web-api 5.23.5 → 5.24.0-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 +29 -29
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region package.json
|
|
29
29
|
var name$1 = "eslint-plugin-react-web-api";
|
|
30
|
-
var version = "5.
|
|
30
|
+
var version = "5.24.0-beta.0";
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/utils/create-rule.ts
|
|
@@ -633,8 +633,8 @@ var no_leaked_event_listener_default = createRule({
|
|
|
633
633
|
type: "problem",
|
|
634
634
|
docs: { description: "Enforces that every 'addEventListener' in a component or custom hook has a corresponding 'removeEventListener'." },
|
|
635
635
|
messages: {
|
|
636
|
-
|
|
637
|
-
|
|
636
|
+
"expected-remove-event-listener-in-cleanup": "An 'addEventListener' in '{{effectMethodKind}}' should have a corresponding 'removeEventListener' in its cleanup function.",
|
|
637
|
+
"unexpected-inline-function": "A/an '{{eventMethodKind}}' should not have an inline listener function."
|
|
638
638
|
},
|
|
639
639
|
schema: []
|
|
640
640
|
},
|
|
@@ -675,7 +675,7 @@ function create$5(context) {
|
|
|
675
675
|
if (options.signal != null) return;
|
|
676
676
|
context.report({
|
|
677
677
|
data: { eventMethodKind: callKind },
|
|
678
|
-
messageId: "
|
|
678
|
+
messageId: "unexpected-inline-function",
|
|
679
679
|
node: listener
|
|
680
680
|
});
|
|
681
681
|
}
|
|
@@ -736,7 +736,7 @@ function create$5(context) {
|
|
|
736
736
|
if (rEntries.some((rEntry) => isInverseEntry(aEntry, rEntry))) continue;
|
|
737
737
|
context.report({
|
|
738
738
|
data: { effectMethodKind: "useEffect" },
|
|
739
|
-
messageId: "
|
|
739
|
+
messageId: "expected-remove-event-listener-in-cleanup",
|
|
740
740
|
node: aEntry.node
|
|
741
741
|
});
|
|
742
742
|
}
|
|
@@ -825,8 +825,8 @@ var no_leaked_fetch_default = createRule({
|
|
|
825
825
|
type: "problem",
|
|
826
826
|
docs: { description: "Enforces that every 'fetch' in a component or custom hook has a corresponding 'AbortController' abort in the cleanup function." },
|
|
827
827
|
messages: {
|
|
828
|
-
|
|
829
|
-
|
|
828
|
+
"expected-abort-controller": "A 'fetch' must be provided with an 'AbortController' for proper cleanup.",
|
|
829
|
+
"expected-abort-in-cleanup": "A 'fetch' started in effect must be aborted with 'AbortController.abort' in the cleanup function."
|
|
830
830
|
},
|
|
831
831
|
schema: []
|
|
832
832
|
},
|
|
@@ -866,14 +866,14 @@ function create$4(context) {
|
|
|
866
866
|
const controller = fEntry.controller;
|
|
867
867
|
if (controller == null) {
|
|
868
868
|
context.report({
|
|
869
|
-
messageId: "
|
|
869
|
+
messageId: "expected-abort-controller",
|
|
870
870
|
node: fEntry.node
|
|
871
871
|
});
|
|
872
872
|
continue;
|
|
873
873
|
}
|
|
874
874
|
if (fEntry.isParamSignal) continue;
|
|
875
875
|
if (!abortEntries.some((aEntry) => isAssignmentTargetEqual(context, aEntry.controller, controller))) context.report({
|
|
876
|
-
messageId: "
|
|
876
|
+
messageId: "expected-abort-in-cleanup",
|
|
877
877
|
node: fEntry.node
|
|
878
878
|
});
|
|
879
879
|
}
|
|
@@ -914,9 +914,9 @@ var no_leaked_intersection_observer_default = createRule({
|
|
|
914
914
|
type: "problem",
|
|
915
915
|
docs: { description: "Enforces that every 'IntersectionObserver' created in a component or custom hook has a corresponding 'IntersectionObserver.disconnect()'." },
|
|
916
916
|
messages: {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
917
|
+
"expected-disconnect-in-control-flow": "Dynamically added 'IntersectionObserver.observe' should be cleared all at once using 'IntersectionObserver.disconnect' in the cleanup function.",
|
|
918
|
+
"expected-disconnect-or-unobserve-in-cleanup": "An 'IntersectionObserver' instance created in 'useEffect' must be disconnected in the cleanup function.",
|
|
919
|
+
"unexpected-floating-instance": "An 'IntersectionObserver' instance created in component or custom hook must be assigned to a variable for proper cleanup."
|
|
920
920
|
},
|
|
921
921
|
schema: []
|
|
922
922
|
},
|
|
@@ -969,7 +969,7 @@ function create$3(context) {
|
|
|
969
969
|
const id = resolveEnclosingAssignmentTarget(node);
|
|
970
970
|
if (id == null) {
|
|
971
971
|
context.report({
|
|
972
|
-
messageId: "
|
|
972
|
+
messageId: "unexpected-floating-instance",
|
|
973
973
|
node
|
|
974
974
|
});
|
|
975
975
|
return;
|
|
@@ -990,7 +990,7 @@ function create$3(context) {
|
|
|
990
990
|
const isPhaseNode = (node) => node === phaseNode;
|
|
991
991
|
if (matchedOEntries.some((e) => !isPhaseNode(Traverse.findParent(e.node, or(isDynamic, isPhaseNode))))) {
|
|
992
992
|
context.report({
|
|
993
|
-
messageId: "
|
|
993
|
+
messageId: "expected-disconnect-in-control-flow",
|
|
994
994
|
node
|
|
995
995
|
});
|
|
996
996
|
continue;
|
|
@@ -998,7 +998,7 @@ function create$3(context) {
|
|
|
998
998
|
for (const oEntry of matchedOEntries) {
|
|
999
999
|
if (matchedUEntries.some((uEntry) => isAssignmentTargetEqual(context, uEntry.element, oEntry.element))) continue;
|
|
1000
1000
|
context.report({
|
|
1001
|
-
messageId: "
|
|
1001
|
+
messageId: "expected-disconnect-or-unobserve-in-cleanup",
|
|
1002
1002
|
node: oEntry.node
|
|
1003
1003
|
});
|
|
1004
1004
|
}
|
|
@@ -1020,8 +1020,8 @@ var no_leaked_interval_default = createRule({
|
|
|
1020
1020
|
type: "problem",
|
|
1021
1021
|
docs: { description: "Enforces that every 'setInterval' in a component or custom hook has a corresponding 'clearInterval'." },
|
|
1022
1022
|
messages: {
|
|
1023
|
-
|
|
1024
|
-
|
|
1023
|
+
"expected-clear-interval-in-cleanup": "A 'setInterval' created in '{{ kind }}' must be cleared with 'clearInterval' in the cleanup function.",
|
|
1024
|
+
"expected-interval-id": "A 'setInterval' must be assigned to a variable for proper cleanup."
|
|
1025
1025
|
},
|
|
1026
1026
|
schema: []
|
|
1027
1027
|
},
|
|
@@ -1043,7 +1043,7 @@ function create$2(context) {
|
|
|
1043
1043
|
const intervalIdNode = resolveEnclosingAssignmentTarget(node);
|
|
1044
1044
|
if (intervalIdNode == null) {
|
|
1045
1045
|
context.report({
|
|
1046
|
-
messageId: "
|
|
1046
|
+
messageId: "expected-interval-id",
|
|
1047
1047
|
node
|
|
1048
1048
|
});
|
|
1049
1049
|
return;
|
|
@@ -1066,7 +1066,7 @@ function create$2(context) {
|
|
|
1066
1066
|
if (cEntries.some((cEntry) => isInverseEntry(sEntry, cEntry))) continue;
|
|
1067
1067
|
context.report({
|
|
1068
1068
|
data: { kind: "useEffect" },
|
|
1069
|
-
messageId: "
|
|
1069
|
+
messageId: "expected-clear-interval-in-cleanup",
|
|
1070
1070
|
node: sEntry.node
|
|
1071
1071
|
});
|
|
1072
1072
|
}
|
|
@@ -1107,9 +1107,9 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
1107
1107
|
type: "problem",
|
|
1108
1108
|
docs: { description: "Enforces that every 'ResizeObserver' created in a component or custom hook has a corresponding 'ResizeObserver.disconnect()'." },
|
|
1109
1109
|
messages: {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1110
|
+
"expected-disconnect-in-control-flow": "Dynamically added 'ResizeObserver.observe' should be cleared all at once using 'ResizeObserver.disconnect' in the cleanup function.",
|
|
1111
|
+
"expected-disconnect-or-unobserve-in-cleanup": "A 'ResizeObserver' instance created in 'useEffect' must be disconnected in the cleanup function.",
|
|
1112
|
+
"unexpected-floating-instance": "A 'ResizeObserver' instance created in component or custom hook must be assigned to a variable for proper cleanup."
|
|
1113
1113
|
},
|
|
1114
1114
|
schema: []
|
|
1115
1115
|
},
|
|
@@ -1162,7 +1162,7 @@ function create$1(context) {
|
|
|
1162
1162
|
const id = resolveEnclosingAssignmentTarget(node);
|
|
1163
1163
|
if (id == null) {
|
|
1164
1164
|
context.report({
|
|
1165
|
-
messageId: "
|
|
1165
|
+
messageId: "unexpected-floating-instance",
|
|
1166
1166
|
node
|
|
1167
1167
|
});
|
|
1168
1168
|
return;
|
|
@@ -1183,7 +1183,7 @@ function create$1(context) {
|
|
|
1183
1183
|
const isPhaseNode = (node) => node === phaseNode;
|
|
1184
1184
|
if (matchedOEntries.some((e) => !isPhaseNode(Traverse.findParent(e.node, or(isDynamic, isPhaseNode))))) {
|
|
1185
1185
|
context.report({
|
|
1186
|
-
messageId: "
|
|
1186
|
+
messageId: "expected-disconnect-in-control-flow",
|
|
1187
1187
|
node
|
|
1188
1188
|
});
|
|
1189
1189
|
continue;
|
|
@@ -1191,7 +1191,7 @@ function create$1(context) {
|
|
|
1191
1191
|
for (const oEntry of matchedOEntries) {
|
|
1192
1192
|
if (matchedUEntries.some((uEntry) => isAssignmentTargetEqual(context, uEntry.element, oEntry.element))) continue;
|
|
1193
1193
|
context.report({
|
|
1194
|
-
messageId: "
|
|
1194
|
+
messageId: "expected-disconnect-or-unobserve-in-cleanup",
|
|
1195
1195
|
node: oEntry.node
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
@@ -1213,8 +1213,8 @@ var no_leaked_timeout_default = createRule({
|
|
|
1213
1213
|
type: "problem",
|
|
1214
1214
|
docs: { description: "Enforces that every 'setTimeout' in a component or custom hook has a corresponding 'clearTimeout'." },
|
|
1215
1215
|
messages: {
|
|
1216
|
-
|
|
1217
|
-
|
|
1216
|
+
"expected-clear-timeout-in-cleanup": "A 'setTimeout' created in '{{ kind }}' must be cleared with 'clearTimeout' in the cleanup function.",
|
|
1217
|
+
"expected-timeout-id": "A 'setTimeout' must be assigned to a variable for proper cleanup."
|
|
1218
1218
|
},
|
|
1219
1219
|
schema: []
|
|
1220
1220
|
},
|
|
@@ -1236,7 +1236,7 @@ function create(context) {
|
|
|
1236
1236
|
const timeoutIdNode = resolveEnclosingAssignmentTarget(node);
|
|
1237
1237
|
if (timeoutIdNode == null) {
|
|
1238
1238
|
context.report({
|
|
1239
|
-
messageId: "
|
|
1239
|
+
messageId: "expected-timeout-id",
|
|
1240
1240
|
node
|
|
1241
1241
|
});
|
|
1242
1242
|
return;
|
|
@@ -1259,7 +1259,7 @@ function create(context) {
|
|
|
1259
1259
|
if (cEntries.some((cEntry) => isInverseEntry(sEntry, cEntry))) continue;
|
|
1260
1260
|
context.report({
|
|
1261
1261
|
data: { kind: "useEffect" },
|
|
1262
|
-
messageId: "
|
|
1262
|
+
messageId: "expected-clear-timeout-in-cleanup",
|
|
1263
1263
|
node: sEntry.node
|
|
1264
1264
|
});
|
|
1265
1265
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.24.0-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eslint-react/ast": "5.
|
|
41
|
-
"@eslint-react/core": "5.
|
|
42
|
-
"@eslint-react/eslint": "5.
|
|
43
|
-
"@eslint-react/shared": "5.
|
|
44
|
-
"@eslint-react/var": "5.
|
|
40
|
+
"@eslint-react/ast": "5.24.0-beta.0",
|
|
41
|
+
"@eslint-react/core": "5.24.0-beta.0",
|
|
42
|
+
"@eslint-react/eslint": "5.24.0-beta.0",
|
|
43
|
+
"@eslint-react/shared": "5.24.0-beta.0",
|
|
44
|
+
"@eslint-react/var": "5.24.0-beta.0",
|
|
45
45
|
"@typescript-eslint/types": "^8.71.0",
|
|
46
46
|
"@typescript-eslint/utils": "^8.71.0",
|
|
47
47
|
"ts-pattern": "^5.9.0"
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@local/configs": "0.0.0",
|
|
51
51
|
"@local/eff": "0.0.0",
|
|
52
|
+
"@local/testkit": "0.0.0",
|
|
52
53
|
"@types/react": "^19.3.0",
|
|
53
54
|
"@types/react-dom": "^19.3.0",
|
|
54
55
|
"dedent": "^1.7.2",
|