eslint-plugin-react-web-api 3.0.0-next.57 → 3.0.0-next.59
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 +25 -28
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener } from "
|
|
|
2
2
|
import * as ast from "@eslint-react/ast";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
4
|
import { dual, or, unit } from "@eslint-react/eff";
|
|
5
|
-
import { findEnclosingAssignmentTarget,
|
|
5
|
+
import { findEnclosingAssignmentTarget, findVariable, getVariableInitializer, isAssignmentTargetEqual, isValueEqual } from "@eslint-react/var";
|
|
6
6
|
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
7
7
|
import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
8
8
|
import { P, isMatching, match } from "ts-pattern";
|
|
@@ -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 = "3.0.0-next.
|
|
30
|
+
var version = "3.0.0-next.59";
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/types/component-phase.ts
|
|
@@ -73,9 +73,6 @@ function getSignalValueExpression(node, initialScope) {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function getOptions(node, initialScope) {
|
|
76
|
-
function findProp(properties, propName) {
|
|
77
|
-
return findProperty(propName, properties, initialScope);
|
|
78
|
-
}
|
|
79
76
|
function getOpts(node) {
|
|
80
77
|
switch (node.type) {
|
|
81
78
|
case AST_NODE_TYPES.Identifier: {
|
|
@@ -88,14 +85,14 @@ function getOptions(node, initialScope) {
|
|
|
88
85
|
capture: Boolean(node.value)
|
|
89
86
|
};
|
|
90
87
|
case AST_NODE_TYPES.ObjectExpression: {
|
|
91
|
-
const vCapture = match(
|
|
88
|
+
const vCapture = match(ast.findProperty(node.properties, "capture")).with(P.nullish, () => false).with({ type: AST_NODE_TYPES.Property }, (prop) => {
|
|
92
89
|
const value = prop.value;
|
|
93
90
|
switch (value.type) {
|
|
94
91
|
case AST_NODE_TYPES.Literal: return Boolean(value.value);
|
|
95
92
|
default: return Boolean(getStaticValue(value, initialScope)?.value);
|
|
96
93
|
}
|
|
97
94
|
}).otherwise(() => false);
|
|
98
|
-
const pSignal =
|
|
95
|
+
const pSignal = ast.findProperty(node.properties, "signal");
|
|
99
96
|
return {
|
|
100
97
|
capture: vCapture,
|
|
101
98
|
signal: pSignal?.type === AST_NODE_TYPES.Property ? getSignalValueExpression(pSignal.value, initialScope) : unit
|
|
@@ -145,9 +142,9 @@ function create$3(context) {
|
|
|
145
142
|
if (!ast.isFunction(listener)) return;
|
|
146
143
|
if (options.signal != null) return;
|
|
147
144
|
context.report({
|
|
145
|
+
data: { eventMethodKind: callKind },
|
|
148
146
|
messageId: "unexpectedInlineFunction",
|
|
149
|
-
node: listener
|
|
150
|
-
data: { eventMethodKind: callKind }
|
|
147
|
+
node: listener
|
|
151
148
|
});
|
|
152
149
|
}
|
|
153
150
|
return defineRuleListener({
|
|
@@ -175,10 +172,10 @@ function create$3(context) {
|
|
|
175
172
|
aEntries.push({
|
|
176
173
|
...opts,
|
|
177
174
|
type,
|
|
178
|
-
node,
|
|
179
175
|
callee,
|
|
180
176
|
listener,
|
|
181
177
|
method: "addEventListener",
|
|
178
|
+
node,
|
|
182
179
|
phase: fKind
|
|
183
180
|
});
|
|
184
181
|
}).with("removeEventListener", (callKind) => {
|
|
@@ -190,10 +187,10 @@ function create$3(context) {
|
|
|
190
187
|
rEntries.push({
|
|
191
188
|
...opts,
|
|
192
189
|
type,
|
|
193
|
-
node,
|
|
194
190
|
callee,
|
|
195
191
|
listener,
|
|
196
192
|
method: "removeEventListener",
|
|
193
|
+
node,
|
|
197
194
|
phase: fKind
|
|
198
195
|
});
|
|
199
196
|
}).with("abort", () => {
|
|
@@ -208,9 +205,9 @@ function create$3(context) {
|
|
|
208
205
|
case "setup":
|
|
209
206
|
case "cleanup":
|
|
210
207
|
context.report({
|
|
208
|
+
data: { effectMethodKind: "useEffect" },
|
|
211
209
|
messageId: "expectedRemoveEventListenerInCleanup",
|
|
212
|
-
node: aEntry.node
|
|
213
|
-
data: { effectMethodKind: "useEffect" }
|
|
210
|
+
node: aEntry.node
|
|
214
211
|
});
|
|
215
212
|
continue;
|
|
216
213
|
case "mount":
|
|
@@ -286,8 +283,8 @@ function create$2(context) {
|
|
|
286
283
|
}
|
|
287
284
|
sEntries.push({
|
|
288
285
|
kind: "interval",
|
|
289
|
-
node,
|
|
290
286
|
callee: node.callee,
|
|
287
|
+
node,
|
|
291
288
|
phase: fEntry.kind,
|
|
292
289
|
timerId: intervalIdNode
|
|
293
290
|
});
|
|
@@ -301,8 +298,8 @@ function create$2(context) {
|
|
|
301
298
|
if (intervalIdNode == null) break;
|
|
302
299
|
cEntries.push({
|
|
303
300
|
kind: "interval",
|
|
304
|
-
node,
|
|
305
301
|
callee: node.callee,
|
|
302
|
+
node,
|
|
306
303
|
phase: fEntry.kind,
|
|
307
304
|
timerId: intervalIdNode
|
|
308
305
|
});
|
|
@@ -317,17 +314,17 @@ function create$2(context) {
|
|
|
317
314
|
case "setup":
|
|
318
315
|
case "cleanup":
|
|
319
316
|
context.report({
|
|
317
|
+
data: { kind: "useEffect" },
|
|
320
318
|
messageId: "expectedClearIntervalInCleanup",
|
|
321
|
-
node: sEntry.node
|
|
322
|
-
data: { kind: "useEffect" }
|
|
319
|
+
node: sEntry.node
|
|
323
320
|
});
|
|
324
321
|
continue;
|
|
325
322
|
case "mount":
|
|
326
323
|
case "unmount":
|
|
327
324
|
context.report({
|
|
325
|
+
data: { kind: "componentDidMount" },
|
|
328
326
|
messageId: "expectedClearIntervalInUnmount",
|
|
329
|
-
node: sEntry.node
|
|
330
|
-
data: { kind: "componentDidMount" }
|
|
327
|
+
node: sEntry.node
|
|
331
328
|
});
|
|
332
329
|
continue;
|
|
333
330
|
}
|
|
@@ -400,9 +397,9 @@ function create$1(context) {
|
|
|
400
397
|
match(getCallKind$1(context, node)).with("disconnect", () => {
|
|
401
398
|
dEntries.push({
|
|
402
399
|
kind: "ResizeObserver",
|
|
403
|
-
node,
|
|
404
400
|
callee: node.callee,
|
|
405
401
|
method: "disconnect",
|
|
402
|
+
node,
|
|
406
403
|
observer: object,
|
|
407
404
|
phase: fKind
|
|
408
405
|
});
|
|
@@ -411,10 +408,10 @@ function create$1(context) {
|
|
|
411
408
|
if (element == null) return;
|
|
412
409
|
oEntries.push({
|
|
413
410
|
kind: "ResizeObserver",
|
|
414
|
-
node,
|
|
415
411
|
callee: node.callee,
|
|
416
412
|
element,
|
|
417
413
|
method: "observe",
|
|
414
|
+
node,
|
|
418
415
|
observer: object,
|
|
419
416
|
phase: fKind
|
|
420
417
|
});
|
|
@@ -423,10 +420,10 @@ function create$1(context) {
|
|
|
423
420
|
if (element == null) return;
|
|
424
421
|
uEntries.push({
|
|
425
422
|
kind: "ResizeObserver",
|
|
426
|
-
node,
|
|
427
423
|
callee: node.callee,
|
|
428
424
|
element,
|
|
429
425
|
method: "unobserve",
|
|
426
|
+
node,
|
|
430
427
|
observer: object,
|
|
431
428
|
phase: fKind
|
|
432
429
|
});
|
|
@@ -537,8 +534,8 @@ function create(context) {
|
|
|
537
534
|
}
|
|
538
535
|
sEntries.push({
|
|
539
536
|
kind: "timeout",
|
|
540
|
-
node,
|
|
541
537
|
callee: node.callee,
|
|
538
|
+
node,
|
|
542
539
|
phase: fEntry.kind,
|
|
543
540
|
timerId: timeoutIdNode
|
|
544
541
|
});
|
|
@@ -549,8 +546,8 @@ function create(context) {
|
|
|
549
546
|
if (timeoutIdNode == null) break;
|
|
550
547
|
rEntries.push({
|
|
551
548
|
kind: "timeout",
|
|
552
|
-
node,
|
|
553
549
|
callee: node.callee,
|
|
550
|
+
node,
|
|
554
551
|
phase: fEntry.kind,
|
|
555
552
|
timerId: timeoutIdNode
|
|
556
553
|
});
|
|
@@ -565,17 +562,17 @@ function create(context) {
|
|
|
565
562
|
case "setup":
|
|
566
563
|
case "cleanup":
|
|
567
564
|
context.report({
|
|
565
|
+
data: { kind: "useEffect" },
|
|
568
566
|
messageId: "expectedClearTimeoutInCleanup",
|
|
569
|
-
node: sEntry.node
|
|
570
|
-
data: { kind: "useEffect" }
|
|
567
|
+
node: sEntry.node
|
|
571
568
|
});
|
|
572
569
|
continue;
|
|
573
570
|
case "mount":
|
|
574
571
|
case "unmount":
|
|
575
572
|
context.report({
|
|
573
|
+
data: { kind: "componentDidMount" },
|
|
576
574
|
messageId: "expectedClearTimeoutInUnmount",
|
|
577
|
-
node: sEntry.node
|
|
578
|
-
data: { kind: "componentDidMount" }
|
|
575
|
+
node: sEntry.node
|
|
579
576
|
});
|
|
580
577
|
continue;
|
|
581
578
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.59",
|
|
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": "canary",
|
|
44
44
|
"birecord": "^0.1.1",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/ast": "3.0.0-next.
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
46
|
+
"@eslint-react/ast": "3.0.0-next.59",
|
|
47
|
+
"@eslint-react/eff": "3.0.0-next.59",
|
|
48
|
+
"@eslint-react/shared": "3.0.0-next.59",
|
|
49
|
+
"@eslint-react/var": "3.0.0-next.59",
|
|
50
|
+
"@eslint-react/core": "3.0.0-next.59"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|