eslint-plugin-react-web-api 1.28.1-next.4 → 1.28.1-next.6
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 +19 -25
- package/dist/index.mjs +13 -19
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var shared = require('@eslint-react/shared');
|
|
|
4
4
|
var AST = require('@eslint-react/ast');
|
|
5
5
|
var core = require('@eslint-react/core');
|
|
6
6
|
var eff = require('@eslint-react/eff');
|
|
7
|
-
var
|
|
7
|
+
var VAR = require('@eslint-react/var');
|
|
8
8
|
var utils = require('@typescript-eslint/utils');
|
|
9
9
|
var tsPattern = require('ts-pattern');
|
|
10
10
|
|
|
@@ -27,7 +27,7 @@ function _interopNamespace(e) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
30
|
-
var
|
|
30
|
+
var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
|
|
31
31
|
|
|
32
32
|
var __defProp = Object.defineProperty;
|
|
33
33
|
var __export = (target, all) => {
|
|
@@ -55,17 +55,11 @@ var settings = {
|
|
|
55
55
|
|
|
56
56
|
// package.json
|
|
57
57
|
var name2 = "eslint-plugin-react-web-api";
|
|
58
|
-
var version = "1.28.1-next.
|
|
58
|
+
var version = "1.28.1-next.6";
|
|
59
59
|
var createRule = shared.createRuleForPlugin("web-api");
|
|
60
60
|
function getPhaseKindOfFunction(node) {
|
|
61
61
|
return tsPattern.match(node).when(core.isFunctionOfUseEffectSetup, () => "setup").when(core.isFunctionOfUseEffectCleanup, () => "cleanup").when(core.isFunctionOfComponentDidMount, () => "mount").when(core.isFunctionOfComponentWillUnmount, () => "unmount").otherwise(() => eff._);
|
|
62
62
|
}
|
|
63
|
-
function isInstanceIdEqual(context, a, b) {
|
|
64
|
-
return VAR2__namespace.isVariableIdEqual(a, b, [
|
|
65
|
-
context.sourceCode.getScope(a),
|
|
66
|
-
context.sourceCode.getScope(b)
|
|
67
|
-
]);
|
|
68
|
-
}
|
|
69
63
|
|
|
70
64
|
// src/rules/no-leaked-event-listener.ts
|
|
71
65
|
var RULE_NAME = "no-leaked-event-listener";
|
|
@@ -94,7 +88,7 @@ function getSignalValueExpression(node, initialScope) {
|
|
|
94
88
|
if (node == null) return eff._;
|
|
95
89
|
switch (node.type) {
|
|
96
90
|
case utils.AST_NODE_TYPES.Identifier: {
|
|
97
|
-
return getSignalValueExpression(
|
|
91
|
+
return getSignalValueExpression(VAR__namespace.getVariableNode(VAR__namespace.findVariable(node, initialScope), 0), initialScope);
|
|
98
92
|
}
|
|
99
93
|
case utils.AST_NODE_TYPES.MemberExpression:
|
|
100
94
|
return node;
|
|
@@ -104,7 +98,7 @@ function getSignalValueExpression(node, initialScope) {
|
|
|
104
98
|
}
|
|
105
99
|
function getOptions(node, initialScope) {
|
|
106
100
|
function findProp(properties, propName) {
|
|
107
|
-
return
|
|
101
|
+
return VAR__namespace.findPropertyInProperties(propName, properties, initialScope);
|
|
108
102
|
}
|
|
109
103
|
function getPropValue(prop, filter = (a) => true) {
|
|
110
104
|
if (prop?.type !== utils.AST_NODE_TYPES.Property) return eff._;
|
|
@@ -116,7 +110,7 @@ function getOptions(node, initialScope) {
|
|
|
116
110
|
break;
|
|
117
111
|
}
|
|
118
112
|
default: {
|
|
119
|
-
v =
|
|
113
|
+
v = VAR__namespace.toStaticValue({ kind: "lazy", node: value, initialScope }).value;
|
|
120
114
|
break;
|
|
121
115
|
}
|
|
122
116
|
}
|
|
@@ -125,8 +119,8 @@ function getOptions(node, initialScope) {
|
|
|
125
119
|
function getOpts(node2) {
|
|
126
120
|
switch (node2.type) {
|
|
127
121
|
case utils.AST_NODE_TYPES.Identifier: {
|
|
128
|
-
const variable =
|
|
129
|
-
const variableNode =
|
|
122
|
+
const variable = VAR__namespace.findVariable(node2, initialScope);
|
|
123
|
+
const variableNode = VAR__namespace.getVariableNode(variable, 0);
|
|
130
124
|
if (variableNode?.type === utils.AST_NODE_TYPES.ObjectExpression) {
|
|
131
125
|
return getOpts(variableNode);
|
|
132
126
|
}
|
|
@@ -190,7 +184,7 @@ var no_leaked_event_listener_default = createRule({
|
|
|
190
184
|
if (!core.isInversePhase(aPhase, rPhase)) {
|
|
191
185
|
return false;
|
|
192
186
|
}
|
|
193
|
-
return isSameObject(aCallee, rCallee) && AST__namespace.isNodeEqual(aListener, rListener) &&
|
|
187
|
+
return isSameObject(aCallee, rCallee) && AST__namespace.isNodeEqual(aListener, rListener) && VAR__namespace.isNodeValueEqual(aType, rType, [
|
|
194
188
|
context.sourceCode.getScope(aType),
|
|
195
189
|
context.sourceCode.getScope(rType)
|
|
196
190
|
]) && aCapture === rCapture;
|
|
@@ -334,7 +328,7 @@ var no_leaked_interval_default = createRule({
|
|
|
334
328
|
const sEntries = [];
|
|
335
329
|
const cEntries = [];
|
|
336
330
|
function isInverseEntry(a, b) {
|
|
337
|
-
return isInstanceIdEqual(context, a.timerId, b.timerId);
|
|
331
|
+
return core.isInstanceIdEqual(context, a.timerId, b.timerId);
|
|
338
332
|
}
|
|
339
333
|
return {
|
|
340
334
|
[":function"](node) {
|
|
@@ -354,7 +348,7 @@ var no_leaked_interval_default = createRule({
|
|
|
354
348
|
if (!core.ERPhaseRelevance.has(fEntry.kind)) {
|
|
355
349
|
break;
|
|
356
350
|
}
|
|
357
|
-
const intervalIdNode =
|
|
351
|
+
const intervalIdNode = VAR__namespace.getVariableDeclaratorId(node);
|
|
358
352
|
if (intervalIdNode == null) {
|
|
359
353
|
context.report({
|
|
360
354
|
messageId: "expectedIntervalId",
|
|
@@ -438,7 +432,7 @@ function isFromObserver(context, node) {
|
|
|
438
432
|
switch (true) {
|
|
439
433
|
case node.type === utils.AST_NODE_TYPES.Identifier: {
|
|
440
434
|
const initialScope = context.sourceCode.getScope(node);
|
|
441
|
-
const object =
|
|
435
|
+
const object = VAR__namespace.getVariableNode(VAR__namespace.findVariable(node, initialScope), 0);
|
|
442
436
|
return isNewResizeObserver(object);
|
|
443
437
|
}
|
|
444
438
|
case node.type === utils.AST_NODE_TYPES.MemberExpression:
|
|
@@ -549,7 +543,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
549
543
|
if (!isNewResizeObserver(node)) {
|
|
550
544
|
return;
|
|
551
545
|
}
|
|
552
|
-
const id =
|
|
546
|
+
const id = core.getInstanceId(node);
|
|
553
547
|
if (id == null) {
|
|
554
548
|
context.report({
|
|
555
549
|
messageId: "unexpectedFloatingInstance",
|
|
@@ -566,11 +560,11 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
566
560
|
},
|
|
567
561
|
["Program:exit"]() {
|
|
568
562
|
for (const { id, node, phaseNode } of observers) {
|
|
569
|
-
if (dEntries.some((e) => isInstanceIdEqual(context, e.observer, id))) {
|
|
563
|
+
if (dEntries.some((e) => core.isInstanceIdEqual(context, e.observer, id))) {
|
|
570
564
|
continue;
|
|
571
565
|
}
|
|
572
|
-
const oentries = oEntries.filter((e) => isInstanceIdEqual(context, e.observer, id));
|
|
573
|
-
const uentries = uEntries.filter((e) => isInstanceIdEqual(context, e.observer, id));
|
|
566
|
+
const oentries = oEntries.filter((e) => core.isInstanceIdEqual(context, e.observer, id));
|
|
567
|
+
const uentries = uEntries.filter((e) => core.isInstanceIdEqual(context, e.observer, id));
|
|
574
568
|
const isDynamic = (node2) => node2?.type === utils.AST_NODE_TYPES.CallExpression || AST__namespace.isConditional(node2);
|
|
575
569
|
const isPhaseNode = (node2) => node2 === phaseNode;
|
|
576
570
|
const hasDynamicallyAdded = oentries.some((e) => !isPhaseNode(AST__namespace.findParentNode(e.node, eff.or(isDynamic, isPhaseNode))));
|
|
@@ -579,7 +573,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
579
573
|
continue;
|
|
580
574
|
}
|
|
581
575
|
for (const oEntry of oentries) {
|
|
582
|
-
if (uentries.some((uEntry) => isInstanceIdEqual(context, uEntry.element, oEntry.element))) {
|
|
576
|
+
if (uentries.some((uEntry) => core.isInstanceIdEqual(context, uEntry.element, oEntry.element))) {
|
|
583
577
|
continue;
|
|
584
578
|
}
|
|
585
579
|
context.report({ messageId: "expectedDisconnectOrUnobserveInCleanup", node: oEntry.node });
|
|
@@ -627,7 +621,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
627
621
|
const sEntries = [];
|
|
628
622
|
const rEntries = [];
|
|
629
623
|
function isInverseEntry(a, b) {
|
|
630
|
-
return isInstanceIdEqual(context, a.timerId, b.timerId);
|
|
624
|
+
return core.isInstanceIdEqual(context, a.timerId, b.timerId);
|
|
631
625
|
}
|
|
632
626
|
return {
|
|
633
627
|
[":function"](node) {
|
|
@@ -644,7 +638,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
644
638
|
}
|
|
645
639
|
switch (getCallKind4(node)) {
|
|
646
640
|
case "setTimeout": {
|
|
647
|
-
const timeoutIdNode =
|
|
641
|
+
const timeoutIdNode = VAR__namespace.getVariableDeclaratorId(node);
|
|
648
642
|
if (timeoutIdNode == null) {
|
|
649
643
|
context.report({
|
|
650
644
|
messageId: "expectedTimeoutId",
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRuleForPlugin, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
2
2
|
import * as AST from '@eslint-react/ast';
|
|
3
|
-
import { ERPhaseRelevance, isInversePhase, isFunctionOfUseEffectSetup, isFunctionOfUseEffectCleanup, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount } from '@eslint-react/core';
|
|
3
|
+
import { ERPhaseRelevance, isInstanceIdEqual, getInstanceId, isInversePhase, isFunctionOfUseEffectSetup, isFunctionOfUseEffectCleanup, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount } from '@eslint-react/core';
|
|
4
4
|
import { _, or } from '@eslint-react/eff';
|
|
5
|
-
import * as
|
|
5
|
+
import * as VAR from '@eslint-react/var';
|
|
6
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
7
7
|
import { match, isMatching, P } from 'ts-pattern';
|
|
8
8
|
|
|
@@ -32,17 +32,11 @@ var settings = {
|
|
|
32
32
|
|
|
33
33
|
// package.json
|
|
34
34
|
var name2 = "eslint-plugin-react-web-api";
|
|
35
|
-
var version = "1.28.1-next.
|
|
35
|
+
var version = "1.28.1-next.6";
|
|
36
36
|
var createRule = createRuleForPlugin("web-api");
|
|
37
37
|
function getPhaseKindOfFunction(node) {
|
|
38
38
|
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfUseEffectCleanup, () => "cleanup").when(isFunctionOfComponentDidMount, () => "mount").when(isFunctionOfComponentWillUnmount, () => "unmount").otherwise(() => _);
|
|
39
39
|
}
|
|
40
|
-
function isInstanceIdEqual(context, a, b) {
|
|
41
|
-
return VAR2.isVariableIdEqual(a, b, [
|
|
42
|
-
context.sourceCode.getScope(a),
|
|
43
|
-
context.sourceCode.getScope(b)
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
40
|
|
|
47
41
|
// src/rules/no-leaked-event-listener.ts
|
|
48
42
|
var RULE_NAME = "no-leaked-event-listener";
|
|
@@ -71,7 +65,7 @@ function getSignalValueExpression(node, initialScope) {
|
|
|
71
65
|
if (node == null) return _;
|
|
72
66
|
switch (node.type) {
|
|
73
67
|
case AST_NODE_TYPES.Identifier: {
|
|
74
|
-
return getSignalValueExpression(
|
|
68
|
+
return getSignalValueExpression(VAR.getVariableNode(VAR.findVariable(node, initialScope), 0), initialScope);
|
|
75
69
|
}
|
|
76
70
|
case AST_NODE_TYPES.MemberExpression:
|
|
77
71
|
return node;
|
|
@@ -81,7 +75,7 @@ function getSignalValueExpression(node, initialScope) {
|
|
|
81
75
|
}
|
|
82
76
|
function getOptions(node, initialScope) {
|
|
83
77
|
function findProp(properties, propName) {
|
|
84
|
-
return
|
|
78
|
+
return VAR.findPropertyInProperties(propName, properties, initialScope);
|
|
85
79
|
}
|
|
86
80
|
function getPropValue(prop, filter = (a) => true) {
|
|
87
81
|
if (prop?.type !== AST_NODE_TYPES.Property) return _;
|
|
@@ -93,7 +87,7 @@ function getOptions(node, initialScope) {
|
|
|
93
87
|
break;
|
|
94
88
|
}
|
|
95
89
|
default: {
|
|
96
|
-
v =
|
|
90
|
+
v = VAR.toStaticValue({ kind: "lazy", node: value, initialScope }).value;
|
|
97
91
|
break;
|
|
98
92
|
}
|
|
99
93
|
}
|
|
@@ -102,8 +96,8 @@ function getOptions(node, initialScope) {
|
|
|
102
96
|
function getOpts(node2) {
|
|
103
97
|
switch (node2.type) {
|
|
104
98
|
case AST_NODE_TYPES.Identifier: {
|
|
105
|
-
const variable =
|
|
106
|
-
const variableNode =
|
|
99
|
+
const variable = VAR.findVariable(node2, initialScope);
|
|
100
|
+
const variableNode = VAR.getVariableNode(variable, 0);
|
|
107
101
|
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
108
102
|
return getOpts(variableNode);
|
|
109
103
|
}
|
|
@@ -167,7 +161,7 @@ var no_leaked_event_listener_default = createRule({
|
|
|
167
161
|
if (!isInversePhase(aPhase, rPhase)) {
|
|
168
162
|
return false;
|
|
169
163
|
}
|
|
170
|
-
return isSameObject(aCallee, rCallee) && AST.isNodeEqual(aListener, rListener) &&
|
|
164
|
+
return isSameObject(aCallee, rCallee) && AST.isNodeEqual(aListener, rListener) && VAR.isNodeValueEqual(aType, rType, [
|
|
171
165
|
context.sourceCode.getScope(aType),
|
|
172
166
|
context.sourceCode.getScope(rType)
|
|
173
167
|
]) && aCapture === rCapture;
|
|
@@ -331,7 +325,7 @@ var no_leaked_interval_default = createRule({
|
|
|
331
325
|
if (!ERPhaseRelevance.has(fEntry.kind)) {
|
|
332
326
|
break;
|
|
333
327
|
}
|
|
334
|
-
const intervalIdNode =
|
|
328
|
+
const intervalIdNode = VAR.getVariableDeclaratorId(node);
|
|
335
329
|
if (intervalIdNode == null) {
|
|
336
330
|
context.report({
|
|
337
331
|
messageId: "expectedIntervalId",
|
|
@@ -415,7 +409,7 @@ function isFromObserver(context, node) {
|
|
|
415
409
|
switch (true) {
|
|
416
410
|
case node.type === AST_NODE_TYPES.Identifier: {
|
|
417
411
|
const initialScope = context.sourceCode.getScope(node);
|
|
418
|
-
const object =
|
|
412
|
+
const object = VAR.getVariableNode(VAR.findVariable(node, initialScope), 0);
|
|
419
413
|
return isNewResizeObserver(object);
|
|
420
414
|
}
|
|
421
415
|
case node.type === AST_NODE_TYPES.MemberExpression:
|
|
@@ -526,7 +520,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
526
520
|
if (!isNewResizeObserver(node)) {
|
|
527
521
|
return;
|
|
528
522
|
}
|
|
529
|
-
const id =
|
|
523
|
+
const id = getInstanceId(node);
|
|
530
524
|
if (id == null) {
|
|
531
525
|
context.report({
|
|
532
526
|
messageId: "unexpectedFloatingInstance",
|
|
@@ -621,7 +615,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
621
615
|
}
|
|
622
616
|
switch (getCallKind4(node)) {
|
|
623
617
|
case "setTimeout": {
|
|
624
|
-
const timeoutIdNode =
|
|
618
|
+
const timeoutIdNode = VAR.getVariableDeclaratorId(node);
|
|
625
619
|
if (timeoutIdNode == null) {
|
|
626
620
|
context.report({
|
|
627
621
|
messageId: "expectedTimeoutId",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "1.28.1-next.
|
|
3
|
+
"version": "1.28.1-next.6",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"@typescript-eslint/utils": "^8.25.0",
|
|
49
49
|
"string-ts": "^2.2.1",
|
|
50
50
|
"ts-pattern": "^5.6.2",
|
|
51
|
-
"@eslint-react/ast": "1.28.1-next.
|
|
52
|
-
"@eslint-react/core": "1.28.1-next.
|
|
53
|
-
"@eslint-react/eff": "1.28.1-next.
|
|
54
|
-
"@eslint-react/jsx": "1.28.1-next.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
51
|
+
"@eslint-react/ast": "1.28.1-next.6",
|
|
52
|
+
"@eslint-react/core": "1.28.1-next.6",
|
|
53
|
+
"@eslint-react/eff": "1.28.1-next.6",
|
|
54
|
+
"@eslint-react/jsx": "1.28.1-next.6",
|
|
55
|
+
"@eslint-react/shared": "1.28.1-next.6",
|
|
56
|
+
"@eslint-react/var": "1.28.1-next.6"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^19.0.10",
|