eslint-plugin-react-web-api 1.26.3-next.9 → 1.27.0-next.1
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.d.mts +31 -6
- package/dist/index.d.ts +31 -6
- package/dist/index.js +69 -37
- package/dist/index.mjs +68 -36
- package/package.json +13 -13
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
import { RulePreset } from '@eslint-react/shared';
|
|
2
3
|
|
|
3
4
|
type MessageID$3 = "expectedClearTimeoutInCleanup" | "expectedClearTimeoutInUnmount" | "expectedTimeoutId";
|
|
4
5
|
|
|
@@ -9,15 +10,39 @@ type MessageID$1 = "expectedClearIntervalInCleanup" | "expectedClearIntervalInUn
|
|
|
9
10
|
type MessageID = "expectedRemoveEventListenerInCleanup" | "expectedRemoveEventListenerInUnmount" | "unexpectedInlineFunction";
|
|
10
11
|
|
|
11
12
|
declare const _default: {
|
|
13
|
+
configs: {
|
|
14
|
+
recommended: {
|
|
15
|
+
plugins: {
|
|
16
|
+
"react-web-api": {
|
|
17
|
+
readonly meta: {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
};
|
|
21
|
+
readonly rules: {
|
|
22
|
+
readonly "no-leaked-event-listener": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
23
|
+
readonly "no-leaked-interval": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
24
|
+
readonly "no-leaked-resize-observer": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
25
|
+
readonly "no-leaked-timeout": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
name: string;
|
|
30
|
+
rules: RulePreset;
|
|
31
|
+
};
|
|
32
|
+
"recommended-legacy": {
|
|
33
|
+
plugins: string[];
|
|
34
|
+
rules: RulePreset;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
12
37
|
meta: {
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly version: string;
|
|
15
40
|
};
|
|
16
41
|
rules: {
|
|
17
|
-
"no-leaked-event-listener": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
18
|
-
"no-leaked-interval": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
19
|
-
"no-leaked-resize-observer": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
20
|
-
"no-leaked-timeout": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
42
|
+
readonly "no-leaked-event-listener": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
43
|
+
readonly "no-leaked-interval": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
44
|
+
readonly "no-leaked-resize-observer": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
45
|
+
readonly "no-leaked-timeout": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
21
46
|
};
|
|
22
47
|
};
|
|
23
48
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
import { RulePreset } from '@eslint-react/shared';
|
|
2
3
|
|
|
3
4
|
type MessageID$3 = "expectedClearTimeoutInCleanup" | "expectedClearTimeoutInUnmount" | "expectedTimeoutId";
|
|
4
5
|
|
|
@@ -9,15 +10,39 @@ type MessageID$1 = "expectedClearIntervalInCleanup" | "expectedClearIntervalInUn
|
|
|
9
10
|
type MessageID = "expectedRemoveEventListenerInCleanup" | "expectedRemoveEventListenerInUnmount" | "unexpectedInlineFunction";
|
|
10
11
|
|
|
11
12
|
declare const _default: {
|
|
13
|
+
configs: {
|
|
14
|
+
recommended: {
|
|
15
|
+
plugins: {
|
|
16
|
+
"react-web-api": {
|
|
17
|
+
readonly meta: {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
};
|
|
21
|
+
readonly rules: {
|
|
22
|
+
readonly "no-leaked-event-listener": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
23
|
+
readonly "no-leaked-interval": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
24
|
+
readonly "no-leaked-resize-observer": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
25
|
+
readonly "no-leaked-timeout": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
name: string;
|
|
30
|
+
rules: RulePreset;
|
|
31
|
+
};
|
|
32
|
+
"recommended-legacy": {
|
|
33
|
+
plugins: string[];
|
|
34
|
+
rules: RulePreset;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
12
37
|
meta: {
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly version: string;
|
|
15
40
|
};
|
|
16
41
|
rules: {
|
|
17
|
-
"no-leaked-event-listener": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
18
|
-
"no-leaked-interval": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
19
|
-
"no-leaked-resize-observer": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
20
|
-
"no-leaked-timeout": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
42
|
+
readonly "no-leaked-event-listener": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
43
|
+
readonly "no-leaked-interval": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$1, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
44
|
+
readonly "no-leaked-resize-observer": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
45
|
+
readonly "no-leaked-timeout": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
21
46
|
};
|
|
22
47
|
};
|
|
23
48
|
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var shared = require('@eslint-react/shared');
|
|
4
|
+
var AST = require('@eslint-react/ast');
|
|
4
5
|
var core = require('@eslint-react/core');
|
|
5
6
|
var eff = require('@eslint-react/eff');
|
|
6
7
|
var VAR2 = require('@eslint-react/var');
|
|
7
8
|
var utils = require('@typescript-eslint/utils');
|
|
8
9
|
var tsPattern = require('ts-pattern');
|
|
9
|
-
var shared = require('@eslint-react/shared');
|
|
10
|
-
var types = require('@typescript-eslint/types');
|
|
11
10
|
|
|
12
11
|
function _interopNamespace(e) {
|
|
13
12
|
if (e && e.__esModule) return e;
|
|
@@ -27,32 +26,42 @@ function _interopNamespace(e) {
|
|
|
27
26
|
return Object.freeze(n);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
var
|
|
29
|
+
var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
31
30
|
var VAR2__namespace = /*#__PURE__*/_interopNamespace(VAR2);
|
|
32
31
|
|
|
32
|
+
var __defProp = Object.defineProperty;
|
|
33
|
+
var __export = (target, all) => {
|
|
34
|
+
for (var name3 in all)
|
|
35
|
+
__defProp(target, name3, { get: all[name3], enumerable: true });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/configs/recommended.ts
|
|
39
|
+
var recommended_exports = {};
|
|
40
|
+
__export(recommended_exports, {
|
|
41
|
+
name: () => name,
|
|
42
|
+
rules: () => rules,
|
|
43
|
+
settings: () => settings
|
|
44
|
+
});
|
|
45
|
+
var name = "react-web-api/recommended";
|
|
46
|
+
var rules = {
|
|
47
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
48
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
49
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
50
|
+
"react-web-api/no-leaked-timeout": "warn"
|
|
51
|
+
};
|
|
52
|
+
var settings = {
|
|
53
|
+
"react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
|
|
54
|
+
};
|
|
55
|
+
|
|
33
56
|
// package.json
|
|
34
|
-
var
|
|
35
|
-
var version = "1.
|
|
57
|
+
var name2 = "eslint-plugin-react-web-api";
|
|
58
|
+
var version = "1.27.0-next.1";
|
|
36
59
|
var createRule = shared.createRuleForPlugin("web-api");
|
|
37
|
-
function getInstanceID(node, prev) {
|
|
38
|
-
switch (true) {
|
|
39
|
-
case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev):
|
|
40
|
-
return node.id;
|
|
41
|
-
case (node.type === types.AST_NODE_TYPES.AssignmentExpression && node.right === prev):
|
|
42
|
-
return node.left;
|
|
43
|
-
case (node.type === types.AST_NODE_TYPES.PropertyDefinition && node.value === prev):
|
|
44
|
-
return node.key;
|
|
45
|
-
case (node.type === types.AST_NODE_TYPES.BlockStatement || node.type === types.AST_NODE_TYPES.Program || node.parent === node):
|
|
46
|
-
return eff._;
|
|
47
|
-
default:
|
|
48
|
-
return getInstanceID(node.parent, node);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
60
|
function getPhaseKindOfFunction(node) {
|
|
52
61
|
return tsPattern.match(node).when(core.isFunctionOfUseEffectSetup, () => "setup").when(core.isFunctionOfUseEffectCleanup, () => "cleanup").when(core.isFunctionOfComponentDidMount, () => "mount").when(core.isFunctionOfComponentWillUnmount, () => "unmount").otherwise(() => eff._);
|
|
53
62
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
63
|
+
function isInstanceIdEqual(a, b, context) {
|
|
64
|
+
return VAR2__namespace.isVariableIdEqual(a, b, [
|
|
56
65
|
context.sourceCode.getScope(a),
|
|
57
66
|
context.sourceCode.getScope(b)
|
|
58
67
|
]);
|
|
@@ -169,7 +178,7 @@ var no_leaked_event_listener_default = createRule({
|
|
|
169
178
|
function isSameObject(a, b) {
|
|
170
179
|
switch (true) {
|
|
171
180
|
case (a.type === utils.AST_NODE_TYPES.MemberExpression && b.type === utils.AST_NODE_TYPES.MemberExpression):
|
|
172
|
-
return
|
|
181
|
+
return AST__namespace.isNodeEqual(a.object, b.object);
|
|
173
182
|
// TODO: Maybe there other cases to consider here.
|
|
174
183
|
default:
|
|
175
184
|
return false;
|
|
@@ -181,14 +190,14 @@ var no_leaked_event_listener_default = createRule({
|
|
|
181
190
|
if (!core.isInversePhase(aPhase, rPhase)) {
|
|
182
191
|
return false;
|
|
183
192
|
}
|
|
184
|
-
return isSameObject(aCallee, rCallee) &&
|
|
193
|
+
return isSameObject(aCallee, rCallee) && AST__namespace.isNodeEqual(aListener, rListener) && VAR2__namespace.isNodeValueEqual(aType, rType, [
|
|
185
194
|
context.sourceCode.getScope(aType),
|
|
186
195
|
context.sourceCode.getScope(rType)
|
|
187
196
|
]) && aCapture === rCapture;
|
|
188
197
|
}
|
|
189
198
|
function checkInlineFunction(node, callKind, options) {
|
|
190
199
|
const listener = node.arguments.at(1);
|
|
191
|
-
if (!
|
|
200
|
+
if (!AST__namespace.isFunction(listener)) {
|
|
192
201
|
return;
|
|
193
202
|
}
|
|
194
203
|
if (options.signal != null) {
|
|
@@ -325,7 +334,7 @@ var no_leaked_interval_default = createRule({
|
|
|
325
334
|
const sEntries = [];
|
|
326
335
|
const cEntries = [];
|
|
327
336
|
function isInverseEntry(a, b) {
|
|
328
|
-
return
|
|
337
|
+
return isInstanceIdEqual(a.timerId, b.timerId, context);
|
|
329
338
|
}
|
|
330
339
|
return {
|
|
331
340
|
[":function"](node) {
|
|
@@ -540,7 +549,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
540
549
|
if (!isNewResizeObserver(node)) {
|
|
541
550
|
return;
|
|
542
551
|
}
|
|
543
|
-
const id =
|
|
552
|
+
const id = VAR2__namespace.getVariableId(node);
|
|
544
553
|
if (id == null) {
|
|
545
554
|
context.report({
|
|
546
555
|
messageId: "unexpectedFloatingInstance",
|
|
@@ -557,20 +566,20 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
557
566
|
},
|
|
558
567
|
["Program:exit"]() {
|
|
559
568
|
for (const { id, node, phaseNode } of observers) {
|
|
560
|
-
if (dEntries.some((e) =>
|
|
569
|
+
if (dEntries.some((e) => isInstanceIdEqual(e.observer, id, context))) {
|
|
561
570
|
continue;
|
|
562
571
|
}
|
|
563
|
-
const oentries = oEntries.filter((e) =>
|
|
564
|
-
const uentries = uEntries.filter((e) =>
|
|
565
|
-
const isDynamic = (node2) => node2?.type === utils.AST_NODE_TYPES.CallExpression ||
|
|
572
|
+
const oentries = oEntries.filter((e) => isInstanceIdEqual(e.observer, id, context));
|
|
573
|
+
const uentries = uEntries.filter((e) => isInstanceIdEqual(e.observer, id, context));
|
|
574
|
+
const isDynamic = (node2) => node2?.type === utils.AST_NODE_TYPES.CallExpression || AST__namespace.isConditional(node2);
|
|
566
575
|
const isPhaseNode = (node2) => node2 === phaseNode;
|
|
567
|
-
const hasDynamicallyAdded = oentries.some((e) => !isPhaseNode(
|
|
576
|
+
const hasDynamicallyAdded = oentries.some((e) => !isPhaseNode(AST__namespace.findParentNode(e.node, eff.or(isDynamic, isPhaseNode))));
|
|
568
577
|
if (hasDynamicallyAdded) {
|
|
569
578
|
context.report({ messageId: "expectedDisconnectInControlFlow", node });
|
|
570
579
|
continue;
|
|
571
580
|
}
|
|
572
581
|
for (const oEntry of oentries) {
|
|
573
|
-
if (uentries.some((uEntry) =>
|
|
582
|
+
if (uentries.some((uEntry) => isInstanceIdEqual(uEntry.element, oEntry.element, context))) {
|
|
574
583
|
continue;
|
|
575
584
|
}
|
|
576
585
|
context.report({ messageId: "expectedDisconnectOrUnobserveInCleanup", node: oEntry.node });
|
|
@@ -618,7 +627,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
618
627
|
const sEntries = [];
|
|
619
628
|
const rEntries = [];
|
|
620
629
|
function isInverseEntry(a, b) {
|
|
621
|
-
return
|
|
630
|
+
return isInstanceIdEqual(a.timerId, b.timerId, context);
|
|
622
631
|
}
|
|
623
632
|
return {
|
|
624
633
|
[":function"](node) {
|
|
@@ -702,10 +711,10 @@ var no_leaked_timeout_default = createRule({
|
|
|
702
711
|
defaultOptions: []
|
|
703
712
|
});
|
|
704
713
|
|
|
705
|
-
// src/
|
|
706
|
-
var
|
|
714
|
+
// src/plugin.ts
|
|
715
|
+
var plugin = {
|
|
707
716
|
meta: {
|
|
708
|
-
name,
|
|
717
|
+
name: name2,
|
|
709
718
|
version
|
|
710
719
|
},
|
|
711
720
|
rules: {
|
|
@@ -716,4 +725,27 @@ var index_default = {
|
|
|
716
725
|
}
|
|
717
726
|
};
|
|
718
727
|
|
|
728
|
+
// src/index.ts
|
|
729
|
+
function makeConfig(config) {
|
|
730
|
+
return {
|
|
731
|
+
...config,
|
|
732
|
+
plugins: {
|
|
733
|
+
"react-web-api": plugin
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
function makeLegacyConfig({ rules: rules2 }) {
|
|
738
|
+
return {
|
|
739
|
+
plugins: ["react-web-api"],
|
|
740
|
+
rules: rules2
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
var index_default = {
|
|
744
|
+
...plugin,
|
|
745
|
+
configs: {
|
|
746
|
+
["recommended"]: makeConfig(recommended_exports),
|
|
747
|
+
["recommended-legacy"]: makeLegacyConfig(recommended_exports)
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
719
751
|
module.exports = index_default;
|
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createRuleForPlugin, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
2
|
+
import * as AST from '@eslint-react/ast';
|
|
2
3
|
import { ERPhaseRelevance, isInversePhase, isFunctionOfUseEffectSetup, isFunctionOfUseEffectCleanup, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount } from '@eslint-react/core';
|
|
3
4
|
import { _, or } from '@eslint-react/eff';
|
|
4
5
|
import * as VAR2 from '@eslint-react/var';
|
|
5
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
6
7
|
import { match, isMatching, P } from 'ts-pattern';
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name3 in all)
|
|
12
|
+
__defProp(target, name3, { get: all[name3], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/configs/recommended.ts
|
|
16
|
+
var recommended_exports = {};
|
|
17
|
+
__export(recommended_exports, {
|
|
18
|
+
name: () => name,
|
|
19
|
+
rules: () => rules,
|
|
20
|
+
settings: () => settings
|
|
21
|
+
});
|
|
22
|
+
var name = "react-web-api/recommended";
|
|
23
|
+
var rules = {
|
|
24
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
25
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
26
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
27
|
+
"react-web-api/no-leaked-timeout": "warn"
|
|
28
|
+
};
|
|
29
|
+
var settings = {
|
|
30
|
+
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
31
|
+
};
|
|
9
32
|
|
|
10
33
|
// package.json
|
|
11
|
-
var
|
|
12
|
-
var version = "1.
|
|
34
|
+
var name2 = "eslint-plugin-react-web-api";
|
|
35
|
+
var version = "1.27.0-next.1";
|
|
13
36
|
var createRule = createRuleForPlugin("web-api");
|
|
14
|
-
function getInstanceID(node, prev) {
|
|
15
|
-
switch (true) {
|
|
16
|
-
case (node.type === AST_NODE_TYPES$1.VariableDeclarator && node.init === prev):
|
|
17
|
-
return node.id;
|
|
18
|
-
case (node.type === AST_NODE_TYPES$1.AssignmentExpression && node.right === prev):
|
|
19
|
-
return node.left;
|
|
20
|
-
case (node.type === AST_NODE_TYPES$1.PropertyDefinition && node.value === prev):
|
|
21
|
-
return node.key;
|
|
22
|
-
case (node.type === AST_NODE_TYPES$1.BlockStatement || node.type === AST_NODE_TYPES$1.Program || node.parent === node):
|
|
23
|
-
return _;
|
|
24
|
-
default:
|
|
25
|
-
return getInstanceID(node.parent, node);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
37
|
function getPhaseKindOfFunction(node) {
|
|
29
38
|
return match(node).when(isFunctionOfUseEffectSetup, () => "setup").when(isFunctionOfUseEffectCleanup, () => "cleanup").when(isFunctionOfComponentDidMount, () => "mount").when(isFunctionOfComponentWillUnmount, () => "unmount").otherwise(() => _);
|
|
30
39
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
40
|
+
function isInstanceIdEqual(a, b, context) {
|
|
41
|
+
return VAR2.isVariableIdEqual(a, b, [
|
|
33
42
|
context.sourceCode.getScope(a),
|
|
34
43
|
context.sourceCode.getScope(b)
|
|
35
44
|
]);
|
|
@@ -146,7 +155,7 @@ var no_leaked_event_listener_default = createRule({
|
|
|
146
155
|
function isSameObject(a, b) {
|
|
147
156
|
switch (true) {
|
|
148
157
|
case (a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression):
|
|
149
|
-
return
|
|
158
|
+
return AST.isNodeEqual(a.object, b.object);
|
|
150
159
|
// TODO: Maybe there other cases to consider here.
|
|
151
160
|
default:
|
|
152
161
|
return false;
|
|
@@ -158,14 +167,14 @@ var no_leaked_event_listener_default = createRule({
|
|
|
158
167
|
if (!isInversePhase(aPhase, rPhase)) {
|
|
159
168
|
return false;
|
|
160
169
|
}
|
|
161
|
-
return isSameObject(aCallee, rCallee) &&
|
|
170
|
+
return isSameObject(aCallee, rCallee) && AST.isNodeEqual(aListener, rListener) && VAR2.isNodeValueEqual(aType, rType, [
|
|
162
171
|
context.sourceCode.getScope(aType),
|
|
163
172
|
context.sourceCode.getScope(rType)
|
|
164
173
|
]) && aCapture === rCapture;
|
|
165
174
|
}
|
|
166
175
|
function checkInlineFunction(node, callKind, options) {
|
|
167
176
|
const listener = node.arguments.at(1);
|
|
168
|
-
if (!
|
|
177
|
+
if (!AST.isFunction(listener)) {
|
|
169
178
|
return;
|
|
170
179
|
}
|
|
171
180
|
if (options.signal != null) {
|
|
@@ -302,7 +311,7 @@ var no_leaked_interval_default = createRule({
|
|
|
302
311
|
const sEntries = [];
|
|
303
312
|
const cEntries = [];
|
|
304
313
|
function isInverseEntry(a, b) {
|
|
305
|
-
return
|
|
314
|
+
return isInstanceIdEqual(a.timerId, b.timerId, context);
|
|
306
315
|
}
|
|
307
316
|
return {
|
|
308
317
|
[":function"](node) {
|
|
@@ -517,7 +526,7 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
517
526
|
if (!isNewResizeObserver(node)) {
|
|
518
527
|
return;
|
|
519
528
|
}
|
|
520
|
-
const id =
|
|
529
|
+
const id = VAR2.getVariableId(node);
|
|
521
530
|
if (id == null) {
|
|
522
531
|
context.report({
|
|
523
532
|
messageId: "unexpectedFloatingInstance",
|
|
@@ -534,20 +543,20 @@ var no_leaked_resize_observer_default = createRule({
|
|
|
534
543
|
},
|
|
535
544
|
["Program:exit"]() {
|
|
536
545
|
for (const { id, node, phaseNode } of observers) {
|
|
537
|
-
if (dEntries.some((e) =>
|
|
546
|
+
if (dEntries.some((e) => isInstanceIdEqual(e.observer, id, context))) {
|
|
538
547
|
continue;
|
|
539
548
|
}
|
|
540
|
-
const oentries = oEntries.filter((e) =>
|
|
541
|
-
const uentries = uEntries.filter((e) =>
|
|
542
|
-
const isDynamic = (node2) => node2?.type === AST_NODE_TYPES.CallExpression ||
|
|
549
|
+
const oentries = oEntries.filter((e) => isInstanceIdEqual(e.observer, id, context));
|
|
550
|
+
const uentries = uEntries.filter((e) => isInstanceIdEqual(e.observer, id, context));
|
|
551
|
+
const isDynamic = (node2) => node2?.type === AST_NODE_TYPES.CallExpression || AST.isConditional(node2);
|
|
543
552
|
const isPhaseNode = (node2) => node2 === phaseNode;
|
|
544
|
-
const hasDynamicallyAdded = oentries.some((e) => !isPhaseNode(
|
|
553
|
+
const hasDynamicallyAdded = oentries.some((e) => !isPhaseNode(AST.findParentNode(e.node, or(isDynamic, isPhaseNode))));
|
|
545
554
|
if (hasDynamicallyAdded) {
|
|
546
555
|
context.report({ messageId: "expectedDisconnectInControlFlow", node });
|
|
547
556
|
continue;
|
|
548
557
|
}
|
|
549
558
|
for (const oEntry of oentries) {
|
|
550
|
-
if (uentries.some((uEntry) =>
|
|
559
|
+
if (uentries.some((uEntry) => isInstanceIdEqual(uEntry.element, oEntry.element, context))) {
|
|
551
560
|
continue;
|
|
552
561
|
}
|
|
553
562
|
context.report({ messageId: "expectedDisconnectOrUnobserveInCleanup", node: oEntry.node });
|
|
@@ -595,7 +604,7 @@ var no_leaked_timeout_default = createRule({
|
|
|
595
604
|
const sEntries = [];
|
|
596
605
|
const rEntries = [];
|
|
597
606
|
function isInverseEntry(a, b) {
|
|
598
|
-
return
|
|
607
|
+
return isInstanceIdEqual(a.timerId, b.timerId, context);
|
|
599
608
|
}
|
|
600
609
|
return {
|
|
601
610
|
[":function"](node) {
|
|
@@ -679,10 +688,10 @@ var no_leaked_timeout_default = createRule({
|
|
|
679
688
|
defaultOptions: []
|
|
680
689
|
});
|
|
681
690
|
|
|
682
|
-
// src/
|
|
683
|
-
var
|
|
691
|
+
// src/plugin.ts
|
|
692
|
+
var plugin = {
|
|
684
693
|
meta: {
|
|
685
|
-
name,
|
|
694
|
+
name: name2,
|
|
686
695
|
version
|
|
687
696
|
},
|
|
688
697
|
rules: {
|
|
@@ -693,4 +702,27 @@ var index_default = {
|
|
|
693
702
|
}
|
|
694
703
|
};
|
|
695
704
|
|
|
705
|
+
// src/index.ts
|
|
706
|
+
function makeConfig(config) {
|
|
707
|
+
return {
|
|
708
|
+
...config,
|
|
709
|
+
plugins: {
|
|
710
|
+
"react-web-api": plugin
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
function makeLegacyConfig({ rules: rules2 }) {
|
|
715
|
+
return {
|
|
716
|
+
plugins: ["react-web-api"],
|
|
717
|
+
rules: rules2
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
var index_default = {
|
|
721
|
+
...plugin,
|
|
722
|
+
configs: {
|
|
723
|
+
["recommended"]: makeConfig(recommended_exports),
|
|
724
|
+
["recommended-legacy"]: makeLegacyConfig(recommended_exports)
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
|
|
696
728
|
export { index_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-web-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0-next.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for interacting with Web APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,21 +43,21 @@
|
|
|
43
43
|
"./package.json"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
47
|
-
"@typescript-eslint/types": "^8.
|
|
48
|
-
"@typescript-eslint/utils": "^8.
|
|
46
|
+
"@typescript-eslint/scope-manager": "^8.24.1",
|
|
47
|
+
"@typescript-eslint/types": "^8.24.1",
|
|
48
|
+
"@typescript-eslint/utils": "^8.24.1",
|
|
49
49
|
"string-ts": "^2.2.1",
|
|
50
50
|
"ts-pattern": "^5.6.2",
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/var": "1.
|
|
56
|
-
"@eslint-react/shared": "1.
|
|
51
|
+
"@eslint-react/core": "1.27.0-next.1",
|
|
52
|
+
"@eslint-react/ast": "1.27.0-next.1",
|
|
53
|
+
"@eslint-react/eff": "1.27.0-next.1",
|
|
54
|
+
"@eslint-react/jsx": "1.27.0-next.1",
|
|
55
|
+
"@eslint-react/var": "1.27.0-next.1",
|
|
56
|
+
"@eslint-react/shared": "1.27.0-next.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@types/react": "^19.0.
|
|
60
|
-
"@types/react-dom": "^19.0.
|
|
59
|
+
"@types/react": "^19.0.10",
|
|
60
|
+
"@types/react-dom": "^19.0.4",
|
|
61
61
|
"tsup": "^8.3.6",
|
|
62
62
|
"@local/configs": "0.0.0"
|
|
63
63
|
},
|
|
@@ -83,6 +83,6 @@
|
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsup --dts-resolve",
|
|
85
85
|
"lint:publish": "publint",
|
|
86
|
-
"lint:
|
|
86
|
+
"lint:ts": "tsc --noEmit"
|
|
87
87
|
}
|
|
88
88
|
}
|