eslint-plugin-runtime-cleanup 1.2.8
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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/_internal/ast-node.d.ts +19 -0
- package/dist/_internal/ast-node.d.ts.map +1 -0
- package/dist/_internal/ast-node.js +42 -0
- package/dist/_internal/ast-node.js.map +1 -0
- package/dist/_internal/bounded-cache.d.ts +37 -0
- package/dist/_internal/bounded-cache.d.ts.map +1 -0
- package/dist/_internal/bounded-cache.js +63 -0
- package/dist/_internal/bounded-cache.js.map +1 -0
- package/dist/_internal/cycle-safe-linked-search.d.ts +48 -0
- package/dist/_internal/cycle-safe-linked-search.d.ts.map +1 -0
- package/dist/_internal/cycle-safe-linked-search.js +70 -0
- package/dist/_internal/cycle-safe-linked-search.js.map +1 -0
- package/dist/_internal/expression-boolean-memoizer.d.ts +17 -0
- package/dist/_internal/expression-boolean-memoizer.d.ts.map +1 -0
- package/dist/_internal/expression-boolean-memoizer.js +22 -0
- package/dist/_internal/expression-boolean-memoizer.js.map +1 -0
- package/dist/_internal/filter-callback.d.ts +52 -0
- package/dist/_internal/filter-callback.d.ts.map +1 -0
- package/dist/_internal/filter-callback.js +108 -0
- package/dist/_internal/filter-callback.js.map +1 -0
- package/dist/_internal/floating-resource.d.ts +29 -0
- package/dist/_internal/floating-resource.d.ts.map +1 -0
- package/dist/_internal/floating-resource.js +114 -0
- package/dist/_internal/floating-resource.js.map +1 -0
- package/dist/_internal/member-call.d.ts +53 -0
- package/dist/_internal/member-call.d.ts.map +1 -0
- package/dist/_internal/member-call.js +61 -0
- package/dist/_internal/member-call.js.map +1 -0
- package/dist/_internal/normalize-expression-text.d.ts +21 -0
- package/dist/_internal/normalize-expression-text.d.ts.map +1 -0
- package/dist/_internal/normalize-expression-text.js +186 -0
- package/dist/_internal/normalize-expression-text.js.map +1 -0
- package/dist/_internal/nullish-comparison.d.ts +44 -0
- package/dist/_internal/nullish-comparison.d.ts.map +1 -0
- package/dist/_internal/nullish-comparison.js +162 -0
- package/dist/_internal/nullish-comparison.js.map +1 -0
- package/dist/_internal/plugin-settings.d.ts +30 -0
- package/dist/_internal/plugin-settings.d.ts.map +1 -0
- package/dist/_internal/plugin-settings.js +90 -0
- package/dist/_internal/plugin-settings.js.map +1 -0
- package/dist/_internal/report-adapter.d.ts +24 -0
- package/dist/_internal/report-adapter.d.ts.map +1 -0
- package/dist/_internal/report-adapter.js +35 -0
- package/dist/_internal/report-adapter.js.map +1 -0
- package/dist/_internal/rule-catalog.d.ts +47 -0
- package/dist/_internal/rule-catalog.d.ts.map +1 -0
- package/dist/_internal/rule-catalog.js +97 -0
- package/dist/_internal/rule-catalog.js.map +1 -0
- package/dist/_internal/rule-docs-metadata.d.ts +35 -0
- package/dist/_internal/rule-docs-metadata.d.ts.map +1 -0
- package/dist/_internal/rule-docs-metadata.js +172 -0
- package/dist/_internal/rule-docs-metadata.js.map +1 -0
- package/dist/_internal/rule-docs-url.d.ts +15 -0
- package/dist/_internal/rule-docs-url.d.ts.map +1 -0
- package/dist/_internal/rule-docs-url.js +15 -0
- package/dist/_internal/rule-docs-url.js.map +1 -0
- package/dist/_internal/rules-registry.d.ts +11 -0
- package/dist/_internal/rules-registry.d.ts.map +1 -0
- package/dist/_internal/rules-registry.js +53 -0
- package/dist/_internal/rules-registry.js.map +1 -0
- package/dist/_internal/runtime-cleanup-config-references.d.ts +38 -0
- package/dist/_internal/runtime-cleanup-config-references.d.ts.map +1 -0
- package/dist/_internal/runtime-cleanup-config-references.js +78 -0
- package/dist/_internal/runtime-cleanup-config-references.js.map +1 -0
- package/dist/_internal/safe-type-operation.d.ts +89 -0
- package/dist/_internal/safe-type-operation.d.ts.map +1 -0
- package/dist/_internal/safe-type-operation.js +147 -0
- package/dist/_internal/safe-type-operation.js.map +1 -0
- package/dist/_internal/scope-variable.d.ts +17 -0
- package/dist/_internal/scope-variable.d.ts.map +1 -0
- package/dist/_internal/scope-variable.js +30 -0
- package/dist/_internal/scope-variable.js.map +1 -0
- package/dist/_internal/type-checker.d.ts +11 -0
- package/dist/_internal/type-checker.d.ts.map +1 -0
- package/dist/_internal/type-checker.js +25 -0
- package/dist/_internal/type-checker.js.map +1 -0
- package/dist/_internal/type-predicate-autofix-safety.d.ts +16 -0
- package/dist/_internal/type-predicate-autofix-safety.d.ts.map +1 -0
- package/dist/_internal/type-predicate-autofix-safety.js +54 -0
- package/dist/_internal/type-predicate-autofix-safety.js.map +1 -0
- package/dist/_internal/type-reference-node.d.ts +23 -0
- package/dist/_internal/type-reference-node.d.ts.map +1 -0
- package/dist/_internal/type-reference-node.js +41 -0
- package/dist/_internal/type-reference-node.js.map +1 -0
- package/dist/_internal/typed-rule.d.ts +91 -0
- package/dist/_internal/typed-rule.d.ts.map +1 -0
- package/dist/_internal/typed-rule.js +121 -0
- package/dist/_internal/typed-rule.js.map +1 -0
- package/dist/_internal/value-rewrite-autofix-safety.d.ts +29 -0
- package/dist/_internal/value-rewrite-autofix-safety.d.ts.map +1 -0
- package/dist/_internal/value-rewrite-autofix-safety.js +108 -0
- package/dist/_internal/value-rewrite-autofix-safety.js.map +1 -0
- package/dist/plugin.cjs +3693 -0
- package/dist/plugin.cjs.map +7 -0
- package/dist/plugin.d.cts +75 -0
- package/dist/plugin.d.ts +75 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +223 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/no-floating-abort-controllers.d.ts +9 -0
- package/dist/rules/no-floating-abort-controllers.d.ts.map +1 -0
- package/dist/rules/no-floating-abort-controllers.js +144 -0
- package/dist/rules/no-floating-abort-controllers.js.map +1 -0
- package/dist/rules/no-floating-audio-contexts.d.ts +9 -0
- package/dist/rules/no-floating-audio-contexts.d.ts.map +1 -0
- package/dist/rules/no-floating-audio-contexts.js +95 -0
- package/dist/rules/no-floating-audio-contexts.js.map +1 -0
- package/dist/rules/no-floating-broadcast-channels.d.ts +9 -0
- package/dist/rules/no-floating-broadcast-channels.d.ts.map +1 -0
- package/dist/rules/no-floating-broadcast-channels.js +151 -0
- package/dist/rules/no-floating-broadcast-channels.js.map +1 -0
- package/dist/rules/no-floating-child-processes.d.ts +9 -0
- package/dist/rules/no-floating-child-processes.d.ts.map +1 -0
- package/dist/rules/no-floating-child-processes.js +259 -0
- package/dist/rules/no-floating-child-processes.js.map +1 -0
- package/dist/rules/no-floating-disposable-stacks.d.ts +9 -0
- package/dist/rules/no-floating-disposable-stacks.d.ts.map +1 -0
- package/dist/rules/no-floating-disposable-stacks.js +177 -0
- package/dist/rules/no-floating-disposable-stacks.js.map +1 -0
- package/dist/rules/no-floating-file-watchers.d.ts +9 -0
- package/dist/rules/no-floating-file-watchers.d.ts.map +1 -0
- package/dist/rules/no-floating-file-watchers.js +241 -0
- package/dist/rules/no-floating-file-watchers.js.map +1 -0
- package/dist/rules/no-floating-geolocation-watches.d.ts +9 -0
- package/dist/rules/no-floating-geolocation-watches.d.ts.map +1 -0
- package/dist/rules/no-floating-geolocation-watches.js +156 -0
- package/dist/rules/no-floating-geolocation-watches.js.map +1 -0
- package/dist/rules/no-floating-infinite-animations.d.ts +9 -0
- package/dist/rules/no-floating-infinite-animations.d.ts.map +1 -0
- package/dist/rules/no-floating-infinite-animations.js +131 -0
- package/dist/rules/no-floating-infinite-animations.js.map +1 -0
- package/dist/rules/no-floating-media-streams.d.ts +9 -0
- package/dist/rules/no-floating-media-streams.d.ts.map +1 -0
- package/dist/rules/no-floating-media-streams.js +175 -0
- package/dist/rules/no-floating-media-streams.js.map +1 -0
- package/dist/rules/no-floating-message-channels.d.ts +9 -0
- package/dist/rules/no-floating-message-channels.d.ts.map +1 -0
- package/dist/rules/no-floating-message-channels.js +150 -0
- package/dist/rules/no-floating-message-channels.js.map +1 -0
- package/dist/rules/no-floating-network-connections.d.ts +9 -0
- package/dist/rules/no-floating-network-connections.d.ts.map +1 -0
- package/dist/rules/no-floating-network-connections.js +170 -0
- package/dist/rules/no-floating-network-connections.js.map +1 -0
- package/dist/rules/no-floating-object-urls.d.ts +9 -0
- package/dist/rules/no-floating-object-urls.d.ts.map +1 -0
- package/dist/rules/no-floating-object-urls.js +83 -0
- package/dist/rules/no-floating-object-urls.js.map +1 -0
- package/dist/rules/no-floating-observers.d.ts +9 -0
- package/dist/rules/no-floating-observers.d.ts.map +1 -0
- package/dist/rules/no-floating-observers.js +160 -0
- package/dist/rules/no-floating-observers.js.map +1 -0
- package/dist/rules/no-floating-servers.d.ts +9 -0
- package/dist/rules/no-floating-servers.d.ts.map +1 -0
- package/dist/rules/no-floating-servers.js +282 -0
- package/dist/rules/no-floating-servers.js.map +1 -0
- package/dist/rules/no-floating-streams.d.ts +9 -0
- package/dist/rules/no-floating-streams.d.ts.map +1 -0
- package/dist/rules/no-floating-streams.js +222 -0
- package/dist/rules/no-floating-streams.js.map +1 -0
- package/dist/rules/no-floating-timers.d.ts +9 -0
- package/dist/rules/no-floating-timers.d.ts.map +1 -0
- package/dist/rules/no-floating-timers.js +145 -0
- package/dist/rules/no-floating-timers.js.map +1 -0
- package/dist/rules/no-floating-wake-locks.d.ts +9 -0
- package/dist/rules/no-floating-wake-locks.d.ts.map +1 -0
- package/dist/rules/no-floating-wake-locks.js +159 -0
- package/dist/rules/no-floating-wake-locks.js.map +1 -0
- package/dist/rules/no-floating-web-stream-locks.d.ts +9 -0
- package/dist/rules/no-floating-web-stream-locks.d.ts.map +1 -0
- package/dist/rules/no-floating-web-stream-locks.js +87 -0
- package/dist/rules/no-floating-web-stream-locks.js.map +1 -0
- package/dist/rules/no-floating-workers.d.ts +9 -0
- package/dist/rules/no-floating-workers.d.ts.map +1 -0
- package/dist/rules/no-floating-workers.js +185 -0
- package/dist/rules/no-floating-workers.js.map +1 -0
- package/dist/rules/no-unmanaged-event-listeners.d.ts +9 -0
- package/dist/rules/no-unmanaged-event-listeners.d.ts.map +1 -0
- package/dist/rules/no-unmanaged-event-listeners.js +210 -0
- package/dist/rules/no-unmanaged-event-listeners.js.map +1 -0
- package/docs/rules/getting-started.md +29 -0
- package/docs/rules/guides/adoption-checklist.md +31 -0
- package/docs/rules/guides/preset-selection-strategy.md +24 -0
- package/docs/rules/guides/rollout-and-fix-safety.md +42 -0
- package/docs/rules/guides/snapshot-testing.md +20 -0
- package/docs/rules/guides/type-aware-linting-readiness.md +20 -0
- package/docs/rules/no-floating-abort-controllers.md +126 -0
- package/docs/rules/no-floating-audio-contexts.md +104 -0
- package/docs/rules/no-floating-broadcast-channels.md +105 -0
- package/docs/rules/no-floating-child-processes.md +123 -0
- package/docs/rules/no-floating-disposable-stacks.md +118 -0
- package/docs/rules/no-floating-file-watchers.md +111 -0
- package/docs/rules/no-floating-geolocation-watches.md +95 -0
- package/docs/rules/no-floating-infinite-animations.md +110 -0
- package/docs/rules/no-floating-media-streams.md +113 -0
- package/docs/rules/no-floating-message-channels.md +114 -0
- package/docs/rules/no-floating-network-connections.md +116 -0
- package/docs/rules/no-floating-object-urls.md +102 -0
- package/docs/rules/no-floating-observers.md +108 -0
- package/docs/rules/no-floating-servers.md +127 -0
- package/docs/rules/no-floating-streams.md +120 -0
- package/docs/rules/no-floating-timers.md +120 -0
- package/docs/rules/no-floating-wake-locks.md +109 -0
- package/docs/rules/no-floating-web-stream-locks.md +105 -0
- package/docs/rules/no-floating-workers.md +123 -0
- package/docs/rules/no-unmanaged-event-listeners.md +143 -0
- package/docs/rules/overview.md +44 -0
- package/docs/rules/presets/all.md +35 -0
- package/docs/rules/presets/experimental.md +44 -0
- package/docs/rules/presets/index.md +54 -0
- package/docs/rules/presets/minimal.md +17 -0
- package/docs/rules/presets/recommended-type-checked.md +43 -0
- package/docs/rules/presets/recommended.md +34 -0
- package/docs/rules/presets/strict.md +36 -0
- package/package.json +323 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public plugin entrypoint for eslint-plugin-runtime-cleanup exports and preset wiring.
|
|
4
|
+
*/
|
|
5
|
+
import type { ESLint, Linter } from "eslint";
|
|
6
|
+
import { runtimeCleanupRules } from "./_internal/rules-registry.js";
|
|
7
|
+
import { type RuntimeCleanupConfigName as InternalRuntimeCleanupConfigName } from "./_internal/runtime-cleanup-config-references.js";
|
|
8
|
+
/**
|
|
9
|
+
* Canonical flat-config preset keys exposed through `plugin.configs`.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* These names are used by consumers when composing presets in ESLint flat
|
|
13
|
+
* config arrays.
|
|
14
|
+
*/
|
|
15
|
+
export type RuntimeCleanupConfigName = InternalRuntimeCleanupConfigName;
|
|
16
|
+
/**
|
|
17
|
+
* Flat-config preset shape produced by this plugin.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The `rules` map is required so preset composition can always merge concrete
|
|
21
|
+
* rule severity entries without additional null checks.
|
|
22
|
+
*/
|
|
23
|
+
export type RuntimeCleanupPresetConfig = Linter.Config & {
|
|
24
|
+
rules: NonNullable<Linter.Config["rules"]>;
|
|
25
|
+
};
|
|
26
|
+
/** Contract for the `configs` object exported by this plugin. */
|
|
27
|
+
type RuntimeCleanupConfigsContract = Record<RuntimeCleanupConfigName, RuntimeCleanupPresetConfig>;
|
|
28
|
+
/** Fully assembled plugin contract used by the runtime default export. */
|
|
29
|
+
type RuntimeCleanupPluginContract = Omit<ESLint.Plugin, "configs" | "rules"> & {
|
|
30
|
+
configs: RuntimeCleanupConfigsContract;
|
|
31
|
+
meta: {
|
|
32
|
+
name: string;
|
|
33
|
+
namespace: string;
|
|
34
|
+
version: string;
|
|
35
|
+
};
|
|
36
|
+
processors: NonNullable<ESLint.Plugin["processors"]>;
|
|
37
|
+
rules: NonNullable<ESLint.Plugin["rules"]>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Fully-qualified ESLint rule id used by this plugin.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Consumers typically use this when building strongly typed rule maps or helper
|
|
44
|
+
* utilities that require namespaced rule identifiers.
|
|
45
|
+
*/
|
|
46
|
+
export type RuntimeCleanupRuleId = `runtime-cleanup/${RuntimeCleanupRuleName}`;
|
|
47
|
+
/** Unqualified rule name supported by `eslint-plugin-runtime-cleanup`. */
|
|
48
|
+
export type RuntimeCleanupRuleName = keyof typeof runtimeCleanupRules;
|
|
49
|
+
/** Finalized typed view of all exported preset configurations. */
|
|
50
|
+
declare const runtimeCleanupConfigs: RuntimeCleanupConfigsContract;
|
|
51
|
+
/**
|
|
52
|
+
* Runtime type for the plugin's generated config presets.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Mirrors `plugin.configs` and is useful when composing typed preset-aware
|
|
56
|
+
* tooling in external integrations.
|
|
57
|
+
*/
|
|
58
|
+
export type RuntimeCleanupConfigs = typeof runtimeCleanupConfigs;
|
|
59
|
+
/**
|
|
60
|
+
* Main plugin object exported for ESLint consumption.
|
|
61
|
+
*/
|
|
62
|
+
declare const runtimeCleanupPlugin: RuntimeCleanupPluginContract;
|
|
63
|
+
/**
|
|
64
|
+
* Runtime type for the plugin object exported as default.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Includes resolved `meta`, `rules`, and `configs` contracts after plugin
|
|
68
|
+
* assembly.
|
|
69
|
+
*/
|
|
70
|
+
export type RuntimeCleanupPlugin = typeof runtimeCleanupPlugin;
|
|
71
|
+
/**
|
|
72
|
+
* Default plugin export consumed by ESLint flat config.
|
|
73
|
+
*/
|
|
74
|
+
export default runtimeCleanupPlugin;
|
|
75
|
+
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Public plugin entrypoint for eslint-plugin-runtime-cleanup exports and preset wiring.
|
|
4
|
+
*/
|
|
5
|
+
import type { ESLint, Linter } from "eslint";
|
|
6
|
+
import { runtimeCleanupRules } from "./_internal/rules-registry.js";
|
|
7
|
+
import { type RuntimeCleanupConfigName as InternalRuntimeCleanupConfigName } from "./_internal/runtime-cleanup-config-references.js";
|
|
8
|
+
/**
|
|
9
|
+
* Canonical flat-config preset keys exposed through `plugin.configs`.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* These names are used by consumers when composing presets in ESLint flat
|
|
13
|
+
* config arrays.
|
|
14
|
+
*/
|
|
15
|
+
export type RuntimeCleanupConfigName = InternalRuntimeCleanupConfigName;
|
|
16
|
+
/**
|
|
17
|
+
* Flat-config preset shape produced by this plugin.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The `rules` map is required so preset composition can always merge concrete
|
|
21
|
+
* rule severity entries without additional null checks.
|
|
22
|
+
*/
|
|
23
|
+
export type RuntimeCleanupPresetConfig = Linter.Config & {
|
|
24
|
+
rules: NonNullable<Linter.Config["rules"]>;
|
|
25
|
+
};
|
|
26
|
+
/** Contract for the `configs` object exported by this plugin. */
|
|
27
|
+
type RuntimeCleanupConfigsContract = Record<RuntimeCleanupConfigName, RuntimeCleanupPresetConfig>;
|
|
28
|
+
/** Fully assembled plugin contract used by the runtime default export. */
|
|
29
|
+
type RuntimeCleanupPluginContract = Omit<ESLint.Plugin, "configs" | "rules"> & {
|
|
30
|
+
configs: RuntimeCleanupConfigsContract;
|
|
31
|
+
meta: {
|
|
32
|
+
name: string;
|
|
33
|
+
namespace: string;
|
|
34
|
+
version: string;
|
|
35
|
+
};
|
|
36
|
+
processors: NonNullable<ESLint.Plugin["processors"]>;
|
|
37
|
+
rules: NonNullable<ESLint.Plugin["rules"]>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Fully-qualified ESLint rule id used by this plugin.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Consumers typically use this when building strongly typed rule maps or helper
|
|
44
|
+
* utilities that require namespaced rule identifiers.
|
|
45
|
+
*/
|
|
46
|
+
export type RuntimeCleanupRuleId = `runtime-cleanup/${RuntimeCleanupRuleName}`;
|
|
47
|
+
/** Unqualified rule name supported by `eslint-plugin-runtime-cleanup`. */
|
|
48
|
+
export type RuntimeCleanupRuleName = keyof typeof runtimeCleanupRules;
|
|
49
|
+
/** Finalized typed view of all exported preset configurations. */
|
|
50
|
+
declare const runtimeCleanupConfigs: RuntimeCleanupConfigsContract;
|
|
51
|
+
/**
|
|
52
|
+
* Runtime type for the plugin's generated config presets.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* Mirrors `plugin.configs` and is useful when composing typed preset-aware
|
|
56
|
+
* tooling in external integrations.
|
|
57
|
+
*/
|
|
58
|
+
export type RuntimeCleanupConfigs = typeof runtimeCleanupConfigs;
|
|
59
|
+
/**
|
|
60
|
+
* Main plugin object exported for ESLint consumption.
|
|
61
|
+
*/
|
|
62
|
+
declare const runtimeCleanupPlugin: RuntimeCleanupPluginContract;
|
|
63
|
+
/**
|
|
64
|
+
* Runtime type for the plugin object exported as default.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Includes resolved `meta`, `rules`, and `configs` contracts after plugin
|
|
68
|
+
* assembly.
|
|
69
|
+
*/
|
|
70
|
+
export type RuntimeCleanupPlugin = typeof runtimeCleanupPlugin;
|
|
71
|
+
/**
|
|
72
|
+
* Default plugin export consumed by ESLint flat config.
|
|
73
|
+
*/
|
|
74
|
+
export default runtimeCleanupPlugin;
|
|
75
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAM7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACH,KAAK,wBAAwB,IAAI,gCAAgC,EAGpE,MAAM,kDA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
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import typeScriptParser from "@typescript-eslint/parser";
|
|
2
|
+
// eslint-disable-next-line import-x/extensions -- Avoid importing from the ESM entrypoint to preserve CJS compatibility
|
|
3
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
4
|
+
import { runtimeCleanupRules } from "./_internal/rules-registry.js";
|
|
5
|
+
import { runtimeCleanupConfigMetadataByName, runtimeCleanupConfigNames, } from "./_internal/runtime-cleanup-config-references.js";
|
|
6
|
+
/** Default file globs targeted by plugin presets when `files` is omitted. */
|
|
7
|
+
const TYPE_SCRIPT_FILES = ["**/*.{ts,tsx,mts,cts}"];
|
|
8
|
+
/**
|
|
9
|
+
* Resolve package version from package.json data.
|
|
10
|
+
*
|
|
11
|
+
* @param pkg - Parsed package metadata value.
|
|
12
|
+
*
|
|
13
|
+
* @returns The package version, or `0.0.0` when unavailable.
|
|
14
|
+
*/
|
|
15
|
+
function getPackageVersion(pkg) {
|
|
16
|
+
if (typeof pkg !== "object" || pkg === null) {
|
|
17
|
+
return "0.0.0";
|
|
18
|
+
}
|
|
19
|
+
const version = Reflect.get(pkg, "version");
|
|
20
|
+
return typeof version === "string" ? version : "0.0.0";
|
|
21
|
+
}
|
|
22
|
+
/** Parser module reused across preset construction. */
|
|
23
|
+
const typeScriptParserValue = typeScriptParser;
|
|
24
|
+
/** Default parser options applied when a preset omits parser options. */
|
|
25
|
+
const defaultParserOptions = {
|
|
26
|
+
ecmaVersion: "latest",
|
|
27
|
+
sourceType: "module",
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Normalize unknown parser options into a mutable parser-options object.
|
|
31
|
+
*/
|
|
32
|
+
const normalizeParserOptions = (parserOptions) => parserOptions !== null &&
|
|
33
|
+
typeof parserOptions === "object" &&
|
|
34
|
+
!Array.isArray(parserOptions)
|
|
35
|
+
? { ...parserOptions }
|
|
36
|
+
: { ...defaultParserOptions };
|
|
37
|
+
/**
|
|
38
|
+
* ESLint-compatible rule map view of the strongly typed internal rule record.
|
|
39
|
+
*/
|
|
40
|
+
const runtimeCleanupEslintRules =
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Internal registry is intentionally narrowed to ESLint's plugin rule map contract.
|
|
42
|
+
runtimeCleanupRules;
|
|
43
|
+
/**
|
|
44
|
+
* Build an ESLint rules map that enables each provided rule at error level.
|
|
45
|
+
*
|
|
46
|
+
* @param ruleNames - Rule names to enable.
|
|
47
|
+
*
|
|
48
|
+
* @returns Rules config object compatible with flat config.
|
|
49
|
+
*/
|
|
50
|
+
function errorRulesFor(ruleNames) {
|
|
51
|
+
const rules = {};
|
|
52
|
+
for (const ruleName of ruleNames) {
|
|
53
|
+
rules[`runtime-cleanup/${ruleName}`] = "error";
|
|
54
|
+
}
|
|
55
|
+
return rules;
|
|
56
|
+
}
|
|
57
|
+
/** Effective per-preset rule lists after applying derived policy overlays. */
|
|
58
|
+
const effectivePresetRuleNamesByConfig = {
|
|
59
|
+
all: [
|
|
60
|
+
"no-floating-abort-controllers",
|
|
61
|
+
"no-floating-audio-contexts",
|
|
62
|
+
"no-floating-broadcast-channels",
|
|
63
|
+
"no-floating-child-processes",
|
|
64
|
+
"no-floating-disposable-stacks",
|
|
65
|
+
"no-floating-file-watchers",
|
|
66
|
+
"no-floating-geolocation-watches",
|
|
67
|
+
"no-floating-infinite-animations",
|
|
68
|
+
"no-floating-media-streams",
|
|
69
|
+
"no-floating-message-channels",
|
|
70
|
+
"no-floating-network-connections",
|
|
71
|
+
"no-floating-object-urls",
|
|
72
|
+
"no-floating-observers",
|
|
73
|
+
"no-floating-servers",
|
|
74
|
+
"no-floating-streams",
|
|
75
|
+
"no-floating-timers",
|
|
76
|
+
"no-floating-wake-locks",
|
|
77
|
+
"no-floating-web-stream-locks",
|
|
78
|
+
"no-floating-workers",
|
|
79
|
+
"no-unmanaged-event-listeners",
|
|
80
|
+
],
|
|
81
|
+
experimental: [],
|
|
82
|
+
minimal: [],
|
|
83
|
+
recommended: [
|
|
84
|
+
"no-floating-abort-controllers",
|
|
85
|
+
"no-floating-audio-contexts",
|
|
86
|
+
"no-floating-broadcast-channels",
|
|
87
|
+
"no-floating-child-processes",
|
|
88
|
+
"no-floating-disposable-stacks",
|
|
89
|
+
"no-floating-file-watchers",
|
|
90
|
+
"no-floating-geolocation-watches",
|
|
91
|
+
"no-floating-media-streams",
|
|
92
|
+
"no-floating-message-channels",
|
|
93
|
+
"no-floating-network-connections",
|
|
94
|
+
"no-floating-object-urls",
|
|
95
|
+
"no-floating-observers",
|
|
96
|
+
"no-floating-servers",
|
|
97
|
+
"no-floating-streams",
|
|
98
|
+
"no-floating-timers",
|
|
99
|
+
"no-floating-wake-locks",
|
|
100
|
+
"no-floating-workers",
|
|
101
|
+
"no-unmanaged-event-listeners",
|
|
102
|
+
],
|
|
103
|
+
"recommended-type-checked": [
|
|
104
|
+
"no-floating-abort-controllers",
|
|
105
|
+
"no-floating-audio-contexts",
|
|
106
|
+
"no-floating-broadcast-channels",
|
|
107
|
+
"no-floating-child-processes",
|
|
108
|
+
"no-floating-disposable-stacks",
|
|
109
|
+
"no-floating-file-watchers",
|
|
110
|
+
"no-floating-geolocation-watches",
|
|
111
|
+
"no-floating-infinite-animations",
|
|
112
|
+
"no-floating-media-streams",
|
|
113
|
+
"no-floating-message-channels",
|
|
114
|
+
"no-floating-network-connections",
|
|
115
|
+
"no-floating-object-urls",
|
|
116
|
+
"no-floating-observers",
|
|
117
|
+
"no-floating-servers",
|
|
118
|
+
"no-floating-streams",
|
|
119
|
+
"no-floating-timers",
|
|
120
|
+
"no-floating-wake-locks",
|
|
121
|
+
"no-floating-web-stream-locks",
|
|
122
|
+
"no-floating-workers",
|
|
123
|
+
"no-unmanaged-event-listeners",
|
|
124
|
+
],
|
|
125
|
+
strict: [
|
|
126
|
+
"no-floating-abort-controllers",
|
|
127
|
+
"no-floating-audio-contexts",
|
|
128
|
+
"no-floating-broadcast-channels",
|
|
129
|
+
"no-floating-child-processes",
|
|
130
|
+
"no-floating-disposable-stacks",
|
|
131
|
+
"no-floating-file-watchers",
|
|
132
|
+
"no-floating-geolocation-watches",
|
|
133
|
+
"no-floating-infinite-animations",
|
|
134
|
+
"no-floating-media-streams",
|
|
135
|
+
"no-floating-message-channels",
|
|
136
|
+
"no-floating-network-connections",
|
|
137
|
+
"no-floating-object-urls",
|
|
138
|
+
"no-floating-observers",
|
|
139
|
+
"no-floating-servers",
|
|
140
|
+
"no-floating-streams",
|
|
141
|
+
"no-floating-timers",
|
|
142
|
+
"no-floating-wake-locks",
|
|
143
|
+
"no-floating-web-stream-locks",
|
|
144
|
+
"no-floating-workers",
|
|
145
|
+
"no-unmanaged-event-listeners",
|
|
146
|
+
],
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Apply parser and plugin metadata required by all plugin presets.
|
|
150
|
+
*
|
|
151
|
+
* @param config - Preset-specific config fragment.
|
|
152
|
+
* @param plugin - Plugin object registered under the `runtime-cleanup`
|
|
153
|
+
* namespace.
|
|
154
|
+
* @param options - Preset-level wiring options.
|
|
155
|
+
*
|
|
156
|
+
* @returns Normalized preset config.
|
|
157
|
+
*/
|
|
158
|
+
function withRuntimeCleanupPlugin(config, plugin, options) {
|
|
159
|
+
const existingLanguageOptions = config.languageOptions ?? {};
|
|
160
|
+
const existingParserOptions = existingLanguageOptions["parserOptions"];
|
|
161
|
+
const parserOptions = normalizeParserOptions(existingParserOptions);
|
|
162
|
+
if (options.requiresTypeChecking &&
|
|
163
|
+
!Object.hasOwn(parserOptions, "projectService")) {
|
|
164
|
+
Reflect.set(parserOptions, "projectService", true);
|
|
165
|
+
}
|
|
166
|
+
const languageOptions = {
|
|
167
|
+
...existingLanguageOptions,
|
|
168
|
+
parser: existingLanguageOptions["parser"] ?? typeScriptParserValue,
|
|
169
|
+
parserOptions,
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
...config,
|
|
173
|
+
files: config.files ?? [...TYPE_SCRIPT_FILES],
|
|
174
|
+
languageOptions,
|
|
175
|
+
plugins: {
|
|
176
|
+
...config.plugins,
|
|
177
|
+
"runtime-cleanup": plugin,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** Minimal plugin object used when assembling flat-config presets. */
|
|
182
|
+
const pluginForConfigs = {
|
|
183
|
+
rules: runtimeCleanupEslintRules,
|
|
184
|
+
};
|
|
185
|
+
const createPresetConfig = (configName) => {
|
|
186
|
+
const configMetadata = runtimeCleanupConfigMetadataByName[configName];
|
|
187
|
+
return withRuntimeCleanupPlugin({
|
|
188
|
+
name: configMetadata.presetName,
|
|
189
|
+
rules: errorRulesFor(effectivePresetRuleNamesByConfig[configName]),
|
|
190
|
+
}, pluginForConfigs, {
|
|
191
|
+
requiresTypeChecking: configMetadata.requiresTypeChecking,
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Flat config presets distributed by eslint-plugin-runtime-cleanup.
|
|
196
|
+
*/
|
|
197
|
+
const createRuntimeCleanupConfigsDefinition = () =>
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Object.fromEntries cannot preserve the finite preset-key union.
|
|
199
|
+
Object.fromEntries(runtimeCleanupConfigNames.map((configName) => [
|
|
200
|
+
configName,
|
|
201
|
+
createPresetConfig(configName),
|
|
202
|
+
]));
|
|
203
|
+
const runtimeCleanupConfigsDefinition = createRuntimeCleanupConfigsDefinition();
|
|
204
|
+
/** Finalized typed view of all exported preset configurations. */
|
|
205
|
+
const runtimeCleanupConfigs = runtimeCleanupConfigsDefinition;
|
|
206
|
+
/**
|
|
207
|
+
* Main plugin object exported for ESLint consumption.
|
|
208
|
+
*/
|
|
209
|
+
const runtimeCleanupPlugin = {
|
|
210
|
+
configs: runtimeCleanupConfigs,
|
|
211
|
+
meta: {
|
|
212
|
+
name: "eslint-plugin-runtime-cleanup",
|
|
213
|
+
namespace: "runtime-cleanup",
|
|
214
|
+
version: getPackageVersion(packageJson),
|
|
215
|
+
},
|
|
216
|
+
processors: {},
|
|
217
|
+
rules: runtimeCleanupEslintRules,
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Default plugin export consumed by ESLint flat config.
|
|
221
|
+
*/
|
|
222
|
+
export default runtimeCleanupPlugin;
|
|
223
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAMA,OAAO,gBAAgB,MAAM,2BAA2B,CAAC;AAEzD,wHAAwH;AACxH,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAEH,kCAAkC,EAClC,yBAAyB,GAC5B,MAAM,kDAAkD,CAAC;AAE1D,6EAA6E;AAC7E,MAAM,iBAAiB,GAAG,CAAC,uBAAuB,CAAU,CAAC;AAiD7D;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,GAAY;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAY,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAErD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAC3D,CAAC;AAED,uDAAuD;AACvD,MAAM,qBAAqB,GAAkC,gBAAgB,CAAC;AAE9E,yEAAyE;AACzE,MAAM,oBAAoB,GAAG;IACzB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,QAAQ;CACK,CAAC;AAE9B;;GAEG;AACH,MAAM,sBAAsB,GAAG,CAC3B,aAAmD,EAClC,EAAE,CACnB,aAAa,KAAK,IAAI;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 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Require AbortController handles to be retained so work can be aborted during cleanup.
|
|
4
|
+
*/
|
|
5
|
+
import { type TSESLint } from "@typescript-eslint/utils";
|
|
6
|
+
/** Rule implementation for `runtime-cleanup/no-floating-abort-controllers`. */
|
|
7
|
+
declare const noFloatingAbortControllers: TSESLint.RuleModule<"floatingAbortController", readonly []>;
|
|
8
|
+
export default noFloatingAbortControllers;
|
|
9
|
+
//# sourceMappingURL=no-floating-abort-controllers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-floating-abort-controllers.d.ts","sourceRoot":"","sources":["../../src/rules/no-floating-abort-controllers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEH,KAAK,QAAQ,EAEhB,MAAM,0BAA0B,CAAC;AAsKlC,+EAA+E;AAC/E,QAAA,MAAM,0BAA0B,EAAE,QAAQ,CAAC,UAAU,CACjD,yBAAyB,EACzB,SAAS,EAAE,CA2Cb,CAAC;AAEH,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Require AbortController handles to be retained so work can be aborted during cleanup.
|
|
4
|
+
*/
|
|
5
|
+
import { AST_NODE_TYPES, } from "@typescript-eslint/utils";
|
|
6
|
+
import { getParentNode } from "../_internal/ast-node.js";
|
|
7
|
+
import { createRuleDocsUrl } from "../_internal/rule-docs-url.js";
|
|
8
|
+
import { getVariableInScopeChain } from "../_internal/scope-variable.js";
|
|
9
|
+
import { createTypedRule, } from "../_internal/typed-rule.js";
|
|
10
|
+
const abortControllerConstructorName = "AbortController";
|
|
11
|
+
const globalReceiverNames = [
|
|
12
|
+
"globalThis",
|
|
13
|
+
"self",
|
|
14
|
+
"window",
|
|
15
|
+
];
|
|
16
|
+
const globalReceiverNameSet = new Set(globalReceiverNames);
|
|
17
|
+
const isGlobalReceiverName = (name) => globalReceiverNameSet.has(name);
|
|
18
|
+
const getTransparentWrappedExpression = (node) => {
|
|
19
|
+
if (node.type === AST_NODE_TYPES.ChainExpression) {
|
|
20
|
+
return node.expression;
|
|
21
|
+
}
|
|
22
|
+
if (node.type === AST_NODE_TYPES.TSAsExpression) {
|
|
23
|
+
return node.expression;
|
|
24
|
+
}
|
|
25
|
+
if (node.type === AST_NODE_TYPES.TSNonNullExpression) {
|
|
26
|
+
return node.expression;
|
|
27
|
+
}
|
|
28
|
+
if (node.type === AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
29
|
+
return node.expression;
|
|
30
|
+
}
|
|
31
|
+
if (node.type === AST_NODE_TYPES.TSTypeAssertion) {
|
|
32
|
+
return node.expression;
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
36
|
+
const getStaticPropertyName = (node, computed) => {
|
|
37
|
+
if (!computed && node.type === AST_NODE_TYPES.Identifier) {
|
|
38
|
+
return node.name;
|
|
39
|
+
}
|
|
40
|
+
if (computed &&
|
|
41
|
+
node.type === AST_NODE_TYPES.Literal &&
|
|
42
|
+
typeof node.value === "string") {
|
|
43
|
+
return node.value;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
const isShadowedAbortControllerIdentifier = (context, identifier) => {
|
|
48
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
49
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
50
|
+
return variable !== null && variable.defs.length > 0;
|
|
51
|
+
};
|
|
52
|
+
const isDirectAbortControllerConstructor = (context, callee) => callee.type === AST_NODE_TYPES.Identifier &&
|
|
53
|
+
callee.name === abortControllerConstructorName &&
|
|
54
|
+
!isShadowedAbortControllerIdentifier(context, callee);
|
|
55
|
+
const isMemberAbortControllerConstructor = (callee) => callee.type === AST_NODE_TYPES.MemberExpression &&
|
|
56
|
+
!callee.optional &&
|
|
57
|
+
callee.object.type === AST_NODE_TYPES.Identifier &&
|
|
58
|
+
isGlobalReceiverName(callee.object.name) &&
|
|
59
|
+
getStaticPropertyName(callee.property, callee.computed) ===
|
|
60
|
+
abortControllerConstructorName;
|
|
61
|
+
const isAbortControllerConstructor = (context, callee) => isDirectAbortControllerConstructor(context, callee) ||
|
|
62
|
+
isMemberAbortControllerConstructor(callee);
|
|
63
|
+
const isDiscardedAbortControllerHandle = (node) => {
|
|
64
|
+
let current = node;
|
|
65
|
+
let parent = getParentNode(current);
|
|
66
|
+
while (parent !== undefined) {
|
|
67
|
+
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
68
|
+
if (wrappedExpression === current) {
|
|
69
|
+
current = parent;
|
|
70
|
+
parent = getParentNode(current);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (parent.type === AST_NODE_TYPES.ExpressionStatement &&
|
|
74
|
+
parent.expression === current) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (parent.type === AST_NODE_TYPES.UnaryExpression &&
|
|
78
|
+
parent.operator === "void" &&
|
|
79
|
+
parent.argument === current) {
|
|
80
|
+
const unaryParent = getParentNode(parent);
|
|
81
|
+
return unaryParent?.type === AST_NODE_TYPES.ExpressionStatement;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
};
|
|
87
|
+
const isImmediateAbortSignalAccess = (node) => {
|
|
88
|
+
let current = node;
|
|
89
|
+
let parent = getParentNode(current);
|
|
90
|
+
while (parent !== undefined) {
|
|
91
|
+
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
92
|
+
if (wrappedExpression === current) {
|
|
93
|
+
current = parent;
|
|
94
|
+
parent = getParentNode(current);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
return (parent.type === AST_NODE_TYPES.MemberExpression &&
|
|
98
|
+
parent.object === current &&
|
|
99
|
+
!parent.optional &&
|
|
100
|
+
getStaticPropertyName(parent.property, parent.computed) === "signal");
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
};
|
|
104
|
+
/** Rule implementation for `runtime-cleanup/no-floating-abort-controllers`. */
|
|
105
|
+
const noFloatingAbortControllers = createTypedRule({
|
|
106
|
+
create(context) {
|
|
107
|
+
return {
|
|
108
|
+
NewExpression(node) {
|
|
109
|
+
if (!isAbortControllerConstructor(context, node.callee) ||
|
|
110
|
+
(!isDiscardedAbortControllerHandle(node) &&
|
|
111
|
+
!isImmediateAbortSignalAccess(node))) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
context.report({
|
|
115
|
+
messageId: "floatingAbortController",
|
|
116
|
+
node,
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
defaultOptions: [],
|
|
122
|
+
meta: {
|
|
123
|
+
docs: {
|
|
124
|
+
description: "require AbortController handles to be retained so work can be aborted during cleanup.",
|
|
125
|
+
recommended: true,
|
|
126
|
+
requiresTypeChecking: false,
|
|
127
|
+
runtimeCleanupConfigs: [
|
|
128
|
+
"runtime-cleanup.configs.recommended",
|
|
129
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
130
|
+
"runtime-cleanup.configs.strict",
|
|
131
|
+
"runtime-cleanup.configs.all",
|
|
132
|
+
],
|
|
133
|
+
url: createRuleDocsUrl("no-floating-abort-controllers"),
|
|
134
|
+
},
|
|
135
|
+
messages: {
|
|
136
|
+
floatingAbortController: "Store or return the AbortController handle so abort() can cancel work during cleanup.",
|
|
137
|
+
},
|
|
138
|
+
schema: [],
|
|
139
|
+
type: "problem",
|
|
140
|
+
},
|
|
141
|
+
name: "no-floating-abort-controllers",
|
|
142
|
+
});
|
|
143
|
+
export default noFloatingAbortControllers;
|
|
144
|
+
//# sourceMappingURL=no-floating-abort-controllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-floating-abort-controllers.js","sourceRoot":"","sources":["../../src/rules/no-floating-abort-controllers.ts"],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AC;SAC1D;QACD,QAAQ,EAAE;YACN,uBAAuB,EACnB,uFAAuF;SAC9F;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,IAAI,EAAE,+BAA+B;CACxC,CAAC,CAAC;AAEH,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Require AudioContext instances to be retained so they can be closed.
|
|
4
|
+
*/
|
|
5
|
+
import { type TSESLint } from "@typescript-eslint/utils";
|
|
6
|
+
/** Rule implementation for `runtime-cleanup/no-floating-audio-contexts`. */
|
|
7
|
+
declare const noFloatingAudioContexts: TSESLint.RuleModule<"floatingAudioContext", readonly []>;
|
|
8
|
+
export default noFloatingAudioContexts;
|
|
9
|
+
//# sourceMappingURL=no-floating-audio-contexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-floating-audio-contexts.d.ts","sourceRoot":"","sources":["../../src/rules/no-floating-audio-contexts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAEH,KAAK,QAAQ,EAEhB,MAAM,0BAA0B,CAAC;AAkGlC,4EAA4E;AAC5E,QAAA,MAAM,uBAAuB,EAAE,QAAQ,CAAC,UAAU,CAC9C,sBAAsB,EACtB,SAAS,EAAE,CAoDb,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* Require AudioContext instances to be retained so they can be closed.
|
|
4
|
+
*/
|
|
5
|
+
import { AST_NODE_TYPES, } from "@typescript-eslint/utils";
|
|
6
|
+
import { collectStaticMemberPath, isDiscardedResourceExpression, isImmediateUnownedMemberReceiver, } from "../_internal/floating-resource.js";
|
|
7
|
+
import { createRuleDocsUrl } from "../_internal/rule-docs-url.js";
|
|
8
|
+
import { getVariableInScopeChain } from "../_internal/scope-variable.js";
|
|
9
|
+
import { createTypedRule, } from "../_internal/typed-rule.js";
|
|
10
|
+
const audioContextConstructorNames = [
|
|
11
|
+
"AudioContext",
|
|
12
|
+
"webkitAudioContext",
|
|
13
|
+
];
|
|
14
|
+
const cleanupMemberNames = new Set(["close"]);
|
|
15
|
+
const globalReceiverNames = ["globalThis", "self", "window"];
|
|
16
|
+
const audioContextConstructorNameSet = new Set(audioContextConstructorNames);
|
|
17
|
+
const globalReceiverNameSet = new Set(globalReceiverNames);
|
|
18
|
+
const isAudioContextConstructorName = (name) => audioContextConstructorNameSet.has(name);
|
|
19
|
+
const isShadowedIdentifier = (context, identifier) => {
|
|
20
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
21
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
22
|
+
return variable !== null && variable.defs.length > 0;
|
|
23
|
+
};
|
|
24
|
+
const getDirectAudioContextConstructorName = (context, callee) => {
|
|
25
|
+
if (callee.type !== AST_NODE_TYPES.Identifier ||
|
|
26
|
+
!isAudioContextConstructorName(callee.name) ||
|
|
27
|
+
isShadowedIdentifier(context, callee)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return callee.name;
|
|
31
|
+
};
|
|
32
|
+
const getMemberAudioContextConstructorName = (callee) => {
|
|
33
|
+
if (callee.type !== AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const path = collectStaticMemberPath(callee);
|
|
37
|
+
if (path?.length !== 2) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const receiverName = path[0];
|
|
41
|
+
if (receiverName === undefined ||
|
|
42
|
+
!globalReceiverNameSet.has(receiverName)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const constructorName = path[1];
|
|
46
|
+
return constructorName !== undefined &&
|
|
47
|
+
isAudioContextConstructorName(constructorName)
|
|
48
|
+
? constructorName
|
|
49
|
+
: undefined;
|
|
50
|
+
};
|
|
51
|
+
const getAudioContextConstructorName = (context, callee) => getDirectAudioContextConstructorName(context, callee) ??
|
|
52
|
+
getMemberAudioContextConstructorName(callee);
|
|
53
|
+
/** Rule implementation for `runtime-cleanup/no-floating-audio-contexts`. */
|
|
54
|
+
const noFloatingAudioContexts = createTypedRule({
|
|
55
|
+
create(context) {
|
|
56
|
+
return {
|
|
57
|
+
NewExpression(node) {
|
|
58
|
+
const constructorName = getAudioContextConstructorName(context, node.callee);
|
|
59
|
+
if (constructorName === undefined ||
|
|
60
|
+
(!isDiscardedResourceExpression(node) &&
|
|
61
|
+
!isImmediateUnownedMemberReceiver(node, cleanupMemberNames))) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
context.report({
|
|
65
|
+
data: { constructorName },
|
|
66
|
+
messageId: "floatingAudioContext",
|
|
67
|
+
node,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
defaultOptions: [],
|
|
73
|
+
meta: {
|
|
74
|
+
docs: {
|
|
75
|
+
description: "require AudioContext instances to be retained so they can be closed.",
|
|
76
|
+
recommended: true,
|
|
77
|
+
requiresTypeChecking: false,
|
|
78
|
+
runtimeCleanupConfigs: [
|
|
79
|
+
"runtime-cleanup.configs.recommended",
|
|
80
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
81
|
+
"runtime-cleanup.configs.strict",
|
|
82
|
+
"runtime-cleanup.configs.all",
|
|
83
|
+
],
|
|
84
|
+
url: createRuleDocsUrl("no-floating-audio-contexts"),
|
|
85
|
+
},
|
|
86
|
+
messages: {
|
|
87
|
+
floatingAudioContext: "Store or return the {{constructorName}} instance so close() can release audio resources during cleanup.",
|
|
88
|
+
},
|
|
89
|
+
schema: [],
|
|
90
|
+
type: "problem",
|
|
91
|
+
},
|
|
92
|
+
name: "no-floating-audio-contexts",
|
|
93
|
+
});
|
|
94
|
+
export default noFloatingAudioContexts;
|
|
95
|
+
//# sourceMappingURL=no-floating-audio-contexts.js.map
|