eslint-plugin-runtime-cleanup 1.2.8 → 1.2.10
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/README.md +29 -29
- package/dist/_internal/ast-node.d.ts +5 -1
- package/dist/_internal/ast-node.d.ts.map +1 -1
- package/dist/_internal/ast-node.js +2 -1
- package/dist/_internal/ast-node.js.map +1 -1
- package/dist/_internal/bounded-cache.d.ts.map +1 -1
- package/dist/_internal/bounded-cache.js +2 -1
- package/dist/_internal/bounded-cache.js.map +1 -1
- package/dist/_internal/expression-boolean-memoizer.d.ts.map +1 -1
- package/dist/_internal/expression-boolean-memoizer.js +2 -1
- package/dist/_internal/expression-boolean-memoizer.js.map +1 -1
- package/dist/_internal/filter-callback.d.ts +5 -1
- package/dist/_internal/filter-callback.d.ts.map +1 -1
- package/dist/_internal/filter-callback.js +9 -10
- package/dist/_internal/filter-callback.js.map +1 -1
- package/dist/_internal/floating-resource.d.ts +8 -0
- package/dist/_internal/floating-resource.d.ts.map +1 -1
- package/dist/_internal/floating-resource.js +42 -36
- package/dist/_internal/floating-resource.js.map +1 -1
- package/dist/_internal/normalize-expression-text.d.ts +6 -1
- package/dist/_internal/normalize-expression-text.d.ts.map +1 -1
- package/dist/_internal/normalize-expression-text.js +30 -28
- package/dist/_internal/normalize-expression-text.js.map +1 -1
- package/dist/_internal/nullish-comparison.d.ts +1 -1
- package/dist/_internal/nullish-comparison.d.ts.map +1 -1
- package/dist/_internal/nullish-comparison.js +16 -11
- package/dist/_internal/nullish-comparison.js.map +1 -1
- package/dist/_internal/plugin-settings.d.ts +2 -1
- package/dist/_internal/plugin-settings.d.ts.map +1 -1
- package/dist/_internal/plugin-settings.js +3 -2
- package/dist/_internal/plugin-settings.js.map +1 -1
- package/dist/_internal/report-adapter.d.ts +5 -4
- package/dist/_internal/report-adapter.d.ts.map +1 -1
- package/dist/_internal/report-adapter.js +3 -2
- package/dist/_internal/report-adapter.js.map +1 -1
- package/dist/_internal/rule-catalog.d.ts.map +1 -1
- package/dist/_internal/rule-catalog.js +3 -2
- package/dist/_internal/rule-catalog.js.map +1 -1
- package/dist/_internal/rule-docs-metadata.d.ts +2 -1
- package/dist/_internal/rule-docs-metadata.d.ts.map +1 -1
- package/dist/_internal/rule-docs-metadata.js +36 -33
- package/dist/_internal/rule-docs-metadata.js.map +1 -1
- package/dist/_internal/rules-registry.d.ts +2 -1
- package/dist/_internal/rules-registry.d.ts.map +1 -1
- package/dist/_internal/rules-registry.js.map +1 -1
- package/dist/_internal/runtime-cleanup-config-references.d.ts +2 -1
- package/dist/_internal/runtime-cleanup-config-references.d.ts.map +1 -1
- package/dist/_internal/runtime-cleanup-config-references.js +8 -7
- package/dist/_internal/runtime-cleanup-config-references.js.map +1 -1
- package/dist/_internal/scope-variable.d.ts.map +1 -1
- package/dist/_internal/scope-variable.js +5 -4
- package/dist/_internal/scope-variable.js.map +1 -1
- package/dist/_internal/type-checker.d.ts +2 -2
- package/dist/_internal/type-checker.d.ts.map +1 -1
- package/dist/_internal/type-checker.js +10 -8
- package/dist/_internal/type-checker.js.map +1 -1
- package/dist/_internal/type-predicate-autofix-safety.d.ts +5 -1
- package/dist/_internal/type-predicate-autofix-safety.d.ts.map +1 -1
- package/dist/_internal/type-predicate-autofix-safety.js +9 -10
- package/dist/_internal/type-predicate-autofix-safety.js.map +1 -1
- package/dist/_internal/type-reference-node.d.ts +7 -5
- package/dist/_internal/type-reference-node.d.ts.map +1 -1
- package/dist/_internal/type-reference-node.js +6 -6
- package/dist/_internal/type-reference-node.js.map +1 -1
- package/dist/_internal/typed-rule.d.ts +2 -1
- package/dist/_internal/typed-rule.d.ts.map +1 -1
- package/dist/_internal/typed-rule.js +6 -5
- package/dist/_internal/typed-rule.js.map +1 -1
- package/dist/_internal/value-rewrite-autofix-safety.d.ts +5 -1
- package/dist/_internal/value-rewrite-autofix-safety.d.ts.map +1 -1
- package/dist/_internal/value-rewrite-autofix-safety.js +10 -18
- package/dist/_internal/value-rewrite-autofix-safety.js.map +1 -1
- package/dist/plugin.cjs +571 -662
- package/dist/plugin.cjs.map +4 -4
- package/dist/plugin.d.cts +2 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +8 -7
- package/dist/plugin.js.map +1 -1
- package/dist/rules/no-floating-abort-controllers.d.ts.map +1 -1
- package/dist/rules/no-floating-abort-controllers.js +24 -52
- package/dist/rules/no-floating-abort-controllers.js.map +1 -1
- package/dist/rules/no-floating-audio-contexts.d.ts.map +1 -1
- package/dist/rules/no-floating-audio-contexts.js +7 -6
- package/dist/rules/no-floating-audio-contexts.js.map +1 -1
- package/dist/rules/no-floating-broadcast-channels.d.ts.map +1 -1
- package/dist/rules/no-floating-broadcast-channels.js +31 -59
- package/dist/rules/no-floating-broadcast-channels.js.map +1 -1
- package/dist/rules/no-floating-child-processes.d.ts.map +1 -1
- package/dist/rules/no-floating-child-processes.js +43 -45
- package/dist/rules/no-floating-child-processes.js.map +1 -1
- package/dist/rules/no-floating-disposable-stacks.d.ts.map +1 -1
- package/dist/rules/no-floating-disposable-stacks.js +37 -38
- package/dist/rules/no-floating-disposable-stacks.js.map +1 -1
- package/dist/rules/no-floating-file-watchers.d.ts.map +1 -1
- package/dist/rules/no-floating-file-watchers.js +40 -42
- package/dist/rules/no-floating-file-watchers.js.map +1 -1
- package/dist/rules/no-floating-geolocation-watches.js +20 -20
- package/dist/rules/no-floating-geolocation-watches.js.map +1 -1
- package/dist/rules/no-floating-infinite-animations.d.ts.map +1 -1
- package/dist/rules/no-floating-infinite-animations.js +4 -3
- package/dist/rules/no-floating-infinite-animations.js.map +1 -1
- package/dist/rules/no-floating-media-streams.d.ts.map +1 -1
- package/dist/rules/no-floating-media-streams.js +24 -24
- package/dist/rules/no-floating-media-streams.js.map +1 -1
- package/dist/rules/no-floating-message-channels.js +30 -30
- package/dist/rules/no-floating-message-channels.js.map +1 -1
- package/dist/rules/no-floating-network-connections.d.ts.map +1 -1
- package/dist/rules/no-floating-network-connections.js +36 -36
- package/dist/rules/no-floating-network-connections.js.map +1 -1
- package/dist/rules/no-floating-object-urls.d.ts.map +1 -1
- package/dist/rules/no-floating-object-urls.js +4 -3
- package/dist/rules/no-floating-object-urls.js.map +1 -1
- package/dist/rules/no-floating-observers.d.ts.map +1 -1
- package/dist/rules/no-floating-observers.js +33 -34
- package/dist/rules/no-floating-observers.js.map +1 -1
- package/dist/rules/no-floating-servers.d.ts.map +1 -1
- package/dist/rules/no-floating-servers.js +50 -52
- package/dist/rules/no-floating-servers.js.map +1 -1
- package/dist/rules/no-floating-streams.d.ts.map +1 -1
- package/dist/rules/no-floating-streams.js +28 -29
- package/dist/rules/no-floating-streams.js.map +1 -1
- package/dist/rules/no-floating-timers.d.ts.map +1 -1
- package/dist/rules/no-floating-timers.js +7 -47
- package/dist/rules/no-floating-timers.js.map +1 -1
- package/dist/rules/no-floating-wake-locks.js +20 -20
- package/dist/rules/no-floating-wake-locks.js.map +1 -1
- package/dist/rules/no-floating-web-stream-locks.d.ts.map +1 -1
- package/dist/rules/no-floating-web-stream-locks.js +4 -3
- package/dist/rules/no-floating-web-stream-locks.js.map +1 -1
- package/dist/rules/no-floating-workers.d.ts.map +1 -1
- package/dist/rules/no-floating-workers.js +39 -40
- package/dist/rules/no-floating-workers.js.map +1 -1
- package/dist/rules/no-unmanaged-event-listeners.d.ts.map +1 -1
- package/dist/rules/no-unmanaged-event-listeners.js +23 -23
- package/dist/rules/no-unmanaged-event-listeners.js.map +1 -1
- package/docs/rules/no-floating-audio-contexts.md +1 -2
- package/docs/rules/no-floating-media-streams.md +1 -1
- package/docs/rules/no-floating-object-urls.md +3 -3
- package/docs/rules/no-floating-observers.md +1 -1
- package/docs/rules/no-floating-servers.md +1 -1
- package/docs/rules/no-floating-wake-locks.md +1 -1
- package/docs/rules/no-floating-web-stream-locks.md +1 -2
- package/docs/rules/presets/index.md +28 -28
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -48,36 +48,36 @@ Runtime-cleanup rules are listed below. Each rule documents the exact resource-l
|
|
|
48
48
|
- `fix` = autofixable
|
|
49
49
|
- `suggest` = suggestions available
|
|
50
50
|
- `-` = report only
|
|
51
|
-
- `Preset
|
|
52
|
-
- [
|
|
53
|
-
- [
|
|
54
|
-
- [
|
|
55
|
-
- [
|
|
56
|
-
- [
|
|
57
|
-
- [
|
|
58
|
-
|
|
59
|
-
| Rule | Fix |
|
|
51
|
+
- `Preset emoji` legend:
|
|
52
|
+
- [🟢](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/minimal) - [`runtime-cleanup.configs.minimal`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/minimal)
|
|
53
|
+
- [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) - [`runtime-cleanup.configs.recommended`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended)
|
|
54
|
+
- [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) - [`runtime-cleanup.configs["recommended-type-checked"]`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked)
|
|
55
|
+
- [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) - [`runtime-cleanup.configs.strict`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict)
|
|
56
|
+
- [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) - [`runtime-cleanup.configs.all`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all)
|
|
57
|
+
- [🧪](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/experimental) - [`runtime-cleanup.configs.experimental`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/experimental)
|
|
58
|
+
|
|
59
|
+
| Rule | Fix | Presets |
|
|
60
60
|
| --- | :-: | :-- |
|
|
61
|
-
| [`no-floating-abort-controllers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-abort-controllers) | - | [
|
|
62
|
-
| [`no-floating-audio-contexts`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-audio-contexts) | - | [
|
|
63
|
-
| [`no-floating-broadcast-channels`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-broadcast-channels) | - | [
|
|
64
|
-
| [`no-floating-child-processes`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-child-processes) | - | [
|
|
65
|
-
| [`no-floating-disposable-stacks`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-disposable-stacks) | - | [
|
|
66
|
-
| [`no-floating-file-watchers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-file-watchers) | - | [
|
|
67
|
-
| [`no-floating-geolocation-watches`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-geolocation-watches) | - | [
|
|
68
|
-
| [`no-floating-infinite-animations`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-infinite-animations) | - | [
|
|
69
|
-
| [`no-floating-media-streams`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-media-streams) | - | [
|
|
70
|
-
| [`no-floating-message-channels`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-message-channels) | - | [
|
|
71
|
-
| [`no-floating-network-connections`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-network-connections) | - | [
|
|
72
|
-
| [`no-floating-object-urls`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-object-urls) | - | [
|
|
73
|
-
| [`no-floating-observers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-observers) | - | [
|
|
74
|
-
| [`no-floating-servers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-servers) | - | [
|
|
75
|
-
| [`no-floating-streams`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-streams) | - | [
|
|
76
|
-
| [`no-floating-timers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-timers) | - | [
|
|
77
|
-
| [`no-floating-wake-locks`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-wake-locks) | - | [
|
|
78
|
-
| [`no-floating-web-stream-locks`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-web-stream-locks) | - | [
|
|
79
|
-
| [`no-floating-workers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-workers) | - | [
|
|
80
|
-
| [`no-unmanaged-event-listeners`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-unmanaged-event-listeners) | - | [
|
|
61
|
+
| [`no-floating-abort-controllers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-abort-controllers) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
62
|
+
| [`no-floating-audio-contexts`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-audio-contexts) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
63
|
+
| [`no-floating-broadcast-channels`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-broadcast-channels) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
64
|
+
| [`no-floating-child-processes`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-child-processes) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
65
|
+
| [`no-floating-disposable-stacks`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-disposable-stacks) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
66
|
+
| [`no-floating-file-watchers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-file-watchers) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
67
|
+
| [`no-floating-geolocation-watches`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-geolocation-watches) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
68
|
+
| [`no-floating-infinite-animations`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-infinite-animations) | - | [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
69
|
+
| [`no-floating-media-streams`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-media-streams) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
70
|
+
| [`no-floating-message-channels`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-message-channels) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
71
|
+
| [`no-floating-network-connections`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-network-connections) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
72
|
+
| [`no-floating-object-urls`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-object-urls) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
73
|
+
| [`no-floating-observers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-observers) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
74
|
+
| [`no-floating-servers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-servers) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
75
|
+
| [`no-floating-streams`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-streams) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
76
|
+
| [`no-floating-timers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-timers) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
77
|
+
| [`no-floating-wake-locks`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-wake-locks) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
78
|
+
| [`no-floating-web-stream-locks`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-web-stream-locks) | - | [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
79
|
+
| [`no-floating-workers`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-floating-workers) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
80
|
+
| [`no-unmanaged-event-listeners`](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/no-unmanaged-event-listeners) | - | [🟡](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended) [🧬](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/recommended-type-checked) [🔴](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/strict) [🟣](https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/presets/all) |
|
|
81
81
|
|
|
82
82
|
## Rule Roadmap
|
|
83
83
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* AST parent-chain traversal helpers used by multiple rule utilities.
|
|
4
|
+
*/
|
|
5
|
+
import { type TSESTree } from "@typescript-eslint/utils";
|
|
2
6
|
/**
|
|
3
7
|
* Gets a node's parent reference when available.
|
|
4
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-node.d.ts","sourceRoot":"","sources":["../../src/_internal/ast-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ast-node.d.ts","sourceRoot":"","sources":["../../src/_internal/ast-node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAmBzE;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACtB,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAC9B,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,SACgC,CAAC;AAE9D;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GACvB,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAC9B,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAqBlC,CAAC"}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* AST parent-chain traversal helpers used by multiple rule utilities.
|
|
4
4
|
*/
|
|
5
5
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
6
|
+
import { keyIn } from "ts-extras";
|
|
6
7
|
import { resolveFirstValueInLinkedStructure } from "./cycle-safe-linked-search.js";
|
|
7
8
|
/**
|
|
8
9
|
* Determine whether a node exposes an optional `parent` property.
|
|
9
10
|
*/
|
|
10
|
-
const hasOptionalParentProperty = (node) => "parent"
|
|
11
|
+
const hasOptionalParentProperty = (node) => keyIn(node, "parent");
|
|
11
12
|
/**
|
|
12
13
|
* Gets a node's parent reference when available.
|
|
13
14
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-node.js","sourceRoot":"","sources":["../../src/_internal/ast-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast-node.js","sourceRoot":"","sources":["../../src/_internal/ast-node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AASnF;;GAEG;AACH,MAAM,yBAAyB,GAAG,CAC9B,IAA6B,EACC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CACzB,IAA6B,EACM,EAAE,CACrC,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,IAA6B,EACI,EAAE;IACnC,MAAM,YAAY,GAAG,kCAAkC,CAGrD;QACE,WAAW,EAAE,CACT,WAAoC,EACN,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,IAAI;QACvE,YAAY,EAAE,CAAC,WAAoC,EAAE,EAAE,CACnD,WAAW,CAAC,IAAI,KAAK,cAAc,CAAC,OAAO;YACvC,CAAC,CAAC;gBACI,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,WAAW;aACrB;YACH,CAAC,CAAC;gBACI,KAAK,EAAE,KAAK;aACf;QACX,SAAS,EAAE,IAAI;KAClB,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-cache.d.ts","sourceRoot":"","sources":["../../src/_internal/bounded-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bounded-cache.d.ts","sourceRoot":"","sources":["../../src/_internal/bounded-cache.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,MAAM,wBAAwB,CAAC,KAAK,IACpC,QAAQ,CAAC;IACL,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC,GACF,QAAQ,CAAC;IACL,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC,CAAC;AAET;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,EAAE,KAAK,EAC3C,OAAO,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,EACtB,KAAK,GAAG,KACT,wBAAwB,CAAC,KAAK,CAgBhC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,GAAG,EAAE,KAAK,EAAE,oCAK9C,QAAQ,CAAC;IACR,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvB,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CAChB,CAAC,KAAG,IAoBJ,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
|
+
import { isSafeInteger } from "ts-extras";
|
|
7
8
|
const isSameValueZero = (left, right) => left === right ||
|
|
8
9
|
(typeof left === "number" &&
|
|
9
10
|
typeof right === "number" &&
|
|
@@ -45,7 +46,7 @@ export const getBoundedCacheValue = (cache, key) => {
|
|
|
45
46
|
* - `value`: Entry value.
|
|
46
47
|
*/
|
|
47
48
|
export const setBoundedCacheValue = ({ cache, key, maxEntries, value, }) => {
|
|
48
|
-
if (!
|
|
49
|
+
if (!isSafeInteger(maxEntries) || maxEntries < 1) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
if (cache.has(key)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-cache.js","sourceRoot":"","sources":["../../src/_internal/bounded-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAQ,IAAW,EAAE,KAAY,EAAW,EAAE,CAClE,IAAI,KAAK,KAAK;IACd,CAAC,OAAO,IAAI,KAAK,QAAQ;QACrB,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAc7B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAChC,KAAsB,EACtB,GAAQ,EACuB,EAAE;IACjC,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;QACpC,IAAI,eAAe,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;YACjC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAEtB,OAAO;gBACH,KAAK,EAAE,IAAI;gBACX,KAAK;aACR,CAAC;QACN,CAAC;IACL,CAAC;IAED,OAAO;QACH,KAAK,EAAE,KAAK;KACf,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAa,EAC7C,KAAK,EACL,GAAG,EACH,UAAU,EACV,KAAK,GAMP,EAAQ,EAAE;IACR,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"bounded-cache.js","sourceRoot":"","sources":["../../src/_internal/bounded-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,eAAe,GAAG,CAAQ,IAAW,EAAE,KAAY,EAAW,EAAE,CAClE,IAAI,KAAK,KAAK;IACd,CAAC,OAAO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OAAO;QACX,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-boolean-memoizer.d.ts","sourceRoot":"","sources":["../../src/_internal/expression-boolean-memoizer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"expression-boolean-memoizer.d.ts","sourceRoot":"","sources":["../../src/_internal/expression-boolean-memoizer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,GAC1C,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,OAAO,KACjE,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,OAAO,CAgBzD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDefined } from "ts-extras";
|
|
1
2
|
/**
|
|
2
3
|
* Memoize a boolean expression predicate using a `WeakMap` keyed by expression
|
|
3
4
|
* node identity.
|
|
@@ -11,7 +12,7 @@ export const memoizeExpressionBooleanPredicate = (evaluate) => {
|
|
|
11
12
|
const cache = new WeakMap();
|
|
12
13
|
return (expression) => {
|
|
13
14
|
const cachedResult = cache.get(expression);
|
|
14
|
-
if (cachedResult
|
|
15
|
+
if (isDefined(cachedResult)) {
|
|
15
16
|
return cachedResult;
|
|
16
17
|
}
|
|
17
18
|
const result = evaluate(expression);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-boolean-memoizer.js","sourceRoot":"","sources":["../../src/_internal/expression-boolean-memoizer.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC7C,QAAgE,EACR,EAAE;IAC1D,MAAM,KAAK,GAAG,IAAI,OAAO,EAA0C,CAAC;IAEpE,OAAO,CAAC,UAAU,EAAE,EAAE;QAClB,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAE3C,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"expression-boolean-memoizer.js","sourceRoot":"","sources":["../../src/_internal/expression-boolean-memoizer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC7C,QAAgE,EACR,EAAE;IAC1D,MAAM,KAAK,GAAG,IAAI,OAAO,EAA0C,CAAC;IAEpE,OAAO,CAAC,UAAU,EAAE,EAAE;QAClB,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAE3C,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;YAC1B,OAAO,YAAY,CAAC;QACxB,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEpC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAE9B,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Utilities for detecting nodes that live inside `.filter(...)` callbacks.
|
|
4
|
+
*/
|
|
5
|
+
import { type TSESTree } from "@typescript-eslint/utils";
|
|
2
6
|
/**
|
|
3
7
|
* Narrows call expressions to direct `.filter(...)` calls.
|
|
4
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-callback.d.ts","sourceRoot":"","sources":["../../src/_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,CAAC,IAAI,CAAC,KAC9B,OA6BF,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Utilities for detecting nodes that live inside `.filter(...)` callbacks.
|
|
4
4
|
*/
|
|
5
5
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
6
|
+
import { arrayAt, setHas } from "ts-extras";
|
|
6
7
|
import { getParentNode } from "./ast-node.js";
|
|
7
8
|
/** Target method name used for callback-context detection. */
|
|
8
9
|
const FILTER_METHOD_NAME = "filter";
|
|
@@ -48,7 +49,7 @@ const isSingleParameterExpressionArrowFunction = (callback) => {
|
|
|
48
49
|
if (callback.body.type === AST_NODE_TYPES.BlockStatement) {
|
|
49
50
|
return false;
|
|
50
51
|
}
|
|
51
|
-
const firstParameter = callback.params
|
|
52
|
+
const firstParameter = arrayAt(callback.params, 0);
|
|
52
53
|
return firstParameter?.type === AST_NODE_TYPES.Identifier;
|
|
53
54
|
};
|
|
54
55
|
/**
|
|
@@ -85,20 +86,18 @@ export const isWithinFilterCallback = (node) => {
|
|
|
85
86
|
let currentNode = node;
|
|
86
87
|
const visitedNodes = new Set();
|
|
87
88
|
while (currentNode) {
|
|
88
|
-
if (visitedNodes
|
|
89
|
+
if (setHas(visitedNodes, currentNode)) {
|
|
89
90
|
return false;
|
|
90
91
|
}
|
|
91
92
|
visitedNodes.add(currentNode);
|
|
92
93
|
if (isFunctionCallbackNode(currentNode)) {
|
|
93
94
|
const callbackParent = getParentNode(currentNode);
|
|
94
|
-
if (callbackParent?.type
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
isFilterCallExpression(callbackParent)) {
|
|
101
|
-
return true;
|
|
95
|
+
if (callbackParent?.type === AST_NODE_TYPES.CallExpression) {
|
|
96
|
+
const [firstArgument] = callbackParent.arguments;
|
|
97
|
+
if (firstArgument === currentNode &&
|
|
98
|
+
isFilterCallExpression(callbackParent)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
currentNode = getParentNode(currentNode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-callback.js","sourceRoot":"","sources":["../../src/_internal/filter-callback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter-callback.js","sourceRoot":"","sources":["../../src/_internal/filter-callback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,8DAA8D;AAC9D,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,sBAAsB,GAAG,CAC3B,IAA6B,EACyC,EAAE,CACxE,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,uBAAuB;IACpD,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,UAA6C,EAQ/C,EAAE,CACA,CAAC,UAAU,CAAC,QAAQ;IACpB,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,gBAAgB;IAC1D,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ;IAC3B,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ;IAC3B,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU;IAC7D,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC7C,UAA6C,EAG/C,EAAE;IACA,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;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AM,sBAAsB,GAAG,CAClC,IAA6B,EACtB,EAAE;IACT,IAAI,WAAW,GAA8B,IAAI,CAAC;IAClD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAiB,CAAC;IAE9C,OAAO,WAAW,EAAE,CAAC;QACjB,IAAI,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAE9B,IAAI,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;YAClD,IAAI,cAAc,EAAE,IAAI,KAAK,cAAc,CAAC,cAAc,EAAE,CAAC;gBACzD,MAAM,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC;gBAEjD,IACI,aAAa,KAAK,WAAW;oBAC7B,sBAAsB,CAAC,cAAc,CAAC,EACxC,CAAC;oBACC,OAAO,IAAI,CAAC;gBAChB,CAAC;YACL,CAAC;QACL,CAAC;QAED,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -15,6 +15,14 @@ export declare const getStaticPropertyName: (node: Readonly<TSESTree.MemberExpre
|
|
|
15
15
|
* Resolve a simple static member path such as `globalThis.URL.createObjectURL`.
|
|
16
16
|
*/
|
|
17
17
|
export declare const collectStaticMemberPath: (node: Readonly<TSESTree.Expression>) => readonly string[] | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Walk through transparent syntax wrappers and return the first parent that
|
|
20
|
+
* changes ownership semantics.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getFirstOpaqueParent: (node: Readonly<TSESTree.Node>) => Readonly<{
|
|
23
|
+
current: Readonly<TSESTree.Node>;
|
|
24
|
+
parent: Readonly<TSESTree.Node>;
|
|
25
|
+
}> | undefined;
|
|
18
26
|
/**
|
|
19
27
|
* Check whether a resource-producing expression is discarded as a standalone
|
|
20
28
|
* expression or explicitly voided.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating-resource.d.ts","sourceRoot":"","sources":["../../src/_internal/floating-resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"floating-resource.d.ts","sourceRoot":"","sources":["../../src/_internal/floating-resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAMzE;;GAEG;AACH,eAAO,MAAM,+BAA+B,GACxC,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAC9B,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,SA0B5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAC9B,MAAM,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,EACrD,UAAU,OAAO,KAClB,MAAM,GAAG,SAcX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAChC,MAAM,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KACpC,SAAS,MAAM,EAAE,GAAG,SAetB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC7B,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAE3B,QAAQ,CAAC;IACL,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CACnC,CAAC,GACF,SAgBL,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,GACtC,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAC9B,OA2BF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,GACzC,MAAM,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC7B,oBAAoB,WAAW,CAAC,MAAM,CAAC,KACxC,OAoBF,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Shared AST helpers for rules that reject unowned cleanup handles.
|
|
4
4
|
*/
|
|
5
5
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
6
|
+
import { isDefined, setHas } from "ts-extras";
|
|
6
7
|
import { getParentNode } from "./ast-node.js";
|
|
7
8
|
/**
|
|
8
9
|
* Unwrap syntax that does not change whether a resource expression is owned.
|
|
@@ -54,36 +55,47 @@ export const collectStaticMemberPath = (node) => {
|
|
|
54
55
|
}
|
|
55
56
|
const objectPath = collectStaticMemberPath(node.object);
|
|
56
57
|
const propertyName = getStaticPropertyName(node.property, node.computed);
|
|
57
|
-
return objectPath
|
|
58
|
+
return !isDefined(objectPath) || !isDefined(propertyName)
|
|
58
59
|
? undefined
|
|
59
60
|
: [...objectPath, propertyName];
|
|
60
61
|
};
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
63
|
+
* Walk through transparent syntax wrappers and return the first parent that
|
|
64
|
+
* changes ownership semantics.
|
|
64
65
|
*/
|
|
65
|
-
export const
|
|
66
|
+
export const getFirstOpaqueParent = (node) => {
|
|
66
67
|
let current = node;
|
|
67
68
|
let parent = getParentNode(current);
|
|
68
|
-
while (parent
|
|
69
|
+
while (isDefined(parent)) {
|
|
69
70
|
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
70
|
-
if (wrappedExpression
|
|
71
|
-
current
|
|
72
|
-
parent = getParentNode(current);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (parent.type === AST_NODE_TYPES.ExpressionStatement &&
|
|
76
|
-
parent.expression === current) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
if (parent.type === AST_NODE_TYPES.UnaryExpression &&
|
|
80
|
-
parent.operator === "void" &&
|
|
81
|
-
parent.argument === current) {
|
|
82
|
-
const unaryParent = getParentNode(parent);
|
|
83
|
-
return unaryParent?.type === AST_NODE_TYPES.ExpressionStatement;
|
|
71
|
+
if (wrappedExpression !== current) {
|
|
72
|
+
return { current, parent };
|
|
84
73
|
}
|
|
74
|
+
current = parent;
|
|
75
|
+
parent = getParentNode(current);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Check whether a resource-producing expression is discarded as a standalone
|
|
81
|
+
* expression or explicitly voided.
|
|
82
|
+
*/
|
|
83
|
+
export const isDiscardedResourceExpression = (node) => {
|
|
84
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
85
|
+
if (!isDefined(opaqueParent)) {
|
|
85
86
|
return false;
|
|
86
87
|
}
|
|
88
|
+
const { current, parent } = opaqueParent;
|
|
89
|
+
if (parent.type === AST_NODE_TYPES.ExpressionStatement &&
|
|
90
|
+
parent.expression === current) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (parent.type === AST_NODE_TYPES.UnaryExpression &&
|
|
94
|
+
parent.operator === "void" &&
|
|
95
|
+
parent.argument === current) {
|
|
96
|
+
const unaryParent = getParentNode(parent);
|
|
97
|
+
return unaryParent?.type === AST_NODE_TYPES.ExpressionStatement;
|
|
98
|
+
}
|
|
87
99
|
return false;
|
|
88
100
|
};
|
|
89
101
|
/**
|
|
@@ -92,23 +104,17 @@ export const isDiscardedResourceExpression = (node) => {
|
|
|
92
104
|
* calls such as `new AudioContext().close()` are not reported here.
|
|
93
105
|
*/
|
|
94
106
|
export const isImmediateUnownedMemberReceiver = (node, cleanupMemberNames) => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
99
|
-
if (wrappedExpression === current) {
|
|
100
|
-
current = parent;
|
|
101
|
-
parent = getParentNode(current);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (parent.type !== AST_NODE_TYPES.MemberExpression ||
|
|
105
|
-
parent.object !== current ||
|
|
106
|
-
parent.optional) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
const propertyName = getStaticPropertyName(parent.property, parent.computed);
|
|
110
|
-
return (propertyName === undefined || !cleanupMemberNames.has(propertyName));
|
|
107
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
108
|
+
if (!isDefined(opaqueParent)) {
|
|
109
|
+
return false;
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
const { current, parent } = opaqueParent;
|
|
112
|
+
if (parent.type !== AST_NODE_TYPES.MemberExpression ||
|
|
113
|
+
parent.object !== current ||
|
|
114
|
+
parent.optional) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const propertyName = getStaticPropertyName(parent.property, parent.computed);
|
|
118
|
+
return !isDefined(propertyName) || !setHas(cleanupMemberNames, propertyName);
|
|
113
119
|
};
|
|
114
120
|
//# sourceMappingURL=floating-resource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating-resource.js","sourceRoot":"","sources":["../../src/_internal/floating-resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"floating-resource.js","sourceRoot":"","sources":["../../src/_internal/floating-resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC3C,IAA6B,EACM,EAAE;IACrC,IAAI,IAAI,CAAC,IAAI,KAAK,cA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YAAY,CAAC,CAAC;AACjF,CAAC,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Structural normalization and equivalence checks for expressions and type
|
|
4
|
+
* nodes used by safe-fix heuristics.
|
|
5
|
+
*/
|
|
6
|
+
import { type TSESTree } from "@typescript-eslint/utils";
|
|
2
7
|
/**
|
|
3
8
|
* Compare two expressions for structural equivalence after unwrapping
|
|
4
9
|
* transparent TypeScript wrappers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-expression-text.d.ts","sourceRoot":"","sources":["../../src/_internal/normalize-expression-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize-expression-text.d.ts","sourceRoot":"","sources":["../../src/_internal/normalize-expression-text.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAiPzE;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACjC,MAAM,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KACrC,OAIE,CAAC;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAC/B,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EACjC,OAAO,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,KACnC,OAA+C,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* nodes used by safe-fix heuristics.
|
|
5
5
|
*/
|
|
6
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
7
|
+
import { isDefined, not, objectHasOwn, objectKeys, setHas } from "ts-extras";
|
|
7
8
|
/**
|
|
8
9
|
* ESTree metadata keys ignored during structural-equivalence checks.
|
|
9
10
|
*/
|
|
@@ -30,7 +31,7 @@ const isComparableRecord = (value) => typeof value === "object" && value !== nul
|
|
|
30
31
|
/**
|
|
31
32
|
* Return stable comparable keys after stripping metadata properties.
|
|
32
33
|
*/
|
|
33
|
-
const getComparableKeys = (value) =>
|
|
34
|
+
const getComparableKeys = (value) => objectKeys(value).filter(not((key) => setHas(ignoredPropertyKeys, key)));
|
|
34
35
|
/**
|
|
35
36
|
* Read comparable keys with per-comparison caching to reduce repeated
|
|
36
37
|
* key-filter allocations during deep traversals.
|
|
@@ -42,7 +43,7 @@ const getComparableKeys = (value) => Object.keys(value).filter((key) => !ignored
|
|
|
42
43
|
*/
|
|
43
44
|
const getCachedComparableKeys = (value, comparableKeysByObject) => {
|
|
44
45
|
const existingComparableKeys = comparableKeysByObject.get(value);
|
|
45
|
-
if (existingComparableKeys
|
|
46
|
+
if (isDefined(existingComparableKeys)) {
|
|
46
47
|
return existingComparableKeys;
|
|
47
48
|
}
|
|
48
49
|
const comparableKeys = getComparableKeys(value);
|
|
@@ -56,32 +57,33 @@ const getCachedComparableKeys = (value, comparableKeysByObject) => {
|
|
|
56
57
|
*
|
|
57
58
|
* @returns The innermost wrapped expression.
|
|
58
59
|
*/
|
|
60
|
+
const getTransparentExpression = (expression) => {
|
|
61
|
+
if (expression.type === AST_NODE_TYPES.TSAsExpression) {
|
|
62
|
+
return expression.expression;
|
|
63
|
+
}
|
|
64
|
+
if (expression.type === AST_NODE_TYPES.TSNonNullExpression) {
|
|
65
|
+
return expression.expression;
|
|
66
|
+
}
|
|
67
|
+
if (expression.type === AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
68
|
+
return expression.expression;
|
|
69
|
+
}
|
|
70
|
+
if (expression.type === AST_NODE_TYPES.TSTypeAssertion) {
|
|
71
|
+
return expression.expression;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
};
|
|
59
75
|
const unwrapTransparentExpression = (expression) => {
|
|
60
76
|
let currentExpression = expression;
|
|
61
77
|
const visitedExpressions = new Set();
|
|
62
|
-
while (
|
|
63
|
-
if (visitedExpressions.has(currentExpression)) {
|
|
64
|
-
return currentExpression;
|
|
65
|
-
}
|
|
78
|
+
while (!setHas(visitedExpressions, currentExpression)) {
|
|
66
79
|
visitedExpressions.add(currentExpression);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (currentExpression.type === AST_NODE_TYPES.TSNonNullExpression) {
|
|
72
|
-
currentExpression = currentExpression.expression;
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (currentExpression.type === AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
76
|
-
currentExpression = currentExpression.expression;
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (currentExpression.type === AST_NODE_TYPES.TSTypeAssertion) {
|
|
80
|
-
currentExpression = currentExpression.expression;
|
|
81
|
-
continue;
|
|
80
|
+
const transparentExpression = getTransparentExpression(currentExpression);
|
|
81
|
+
if (!isDefined(transparentExpression)) {
|
|
82
|
+
return currentExpression;
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
currentExpression = transparentExpression;
|
|
84
85
|
}
|
|
86
|
+
return currentExpression;
|
|
85
87
|
};
|
|
86
88
|
/**
|
|
87
89
|
* Records a compared object pair and reports whether that pair was already
|
|
@@ -95,14 +97,14 @@ const unwrapTransparentExpression = (expression) => {
|
|
|
95
97
|
*/
|
|
96
98
|
const markAndCheckSeenPair = (left, right, seenPairs) => {
|
|
97
99
|
const seenRightNodes = seenPairs.get(left);
|
|
98
|
-
if (seenRightNodes
|
|
100
|
+
if (isDefined(seenRightNodes) && seenRightNodes.has(right)) {
|
|
99
101
|
return true;
|
|
100
102
|
}
|
|
101
|
-
if (seenRightNodes
|
|
102
|
-
|
|
103
|
+
if (isDefined(seenRightNodes)) {
|
|
104
|
+
seenRightNodes.add(right);
|
|
103
105
|
}
|
|
104
106
|
else {
|
|
105
|
-
|
|
107
|
+
seenPairs.set(left, new WeakSet([right]));
|
|
106
108
|
}
|
|
107
109
|
return false;
|
|
108
110
|
};
|
|
@@ -154,11 +156,11 @@ const areEquivalentNodeValues = (left, right, seenPairs = new WeakMap(), compara
|
|
|
154
156
|
if (leftKeys.length !== rightKeys.length) {
|
|
155
157
|
return false;
|
|
156
158
|
}
|
|
157
|
-
if (leftKeys.some((key) => !rightKeySet
|
|
159
|
+
if (leftKeys.some((key) => !setHas(rightKeySet, key))) {
|
|
158
160
|
return false;
|
|
159
161
|
}
|
|
160
162
|
return leftKeys.every((key) => {
|
|
161
|
-
if (!
|
|
163
|
+
if (!objectHasOwn(left, key) || !objectHasOwn(right, key)) {
|
|
162
164
|
return false;
|
|
163
165
|
}
|
|
164
166
|
return areEquivalentNodeValues(left[key], right[key], seenPairs, comparableKeysByObject, depth + 1);
|