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
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,3693 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// dist/plugin.js
|
|
31
|
+
var plugin_exports = {};
|
|
32
|
+
__export(plugin_exports, {
|
|
33
|
+
default: () => plugin_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
36
|
+
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
37
|
+
|
|
38
|
+
// package.json
|
|
39
|
+
var package_default = {
|
|
40
|
+
$schema: "https://www.schemastore.org/package.json",
|
|
41
|
+
name: "eslint-plugin-runtime-cleanup",
|
|
42
|
+
version: "1.2.8",
|
|
43
|
+
private: false,
|
|
44
|
+
description: "ESLint rules for requiring cleanup of runtime resources.",
|
|
45
|
+
keywords: [
|
|
46
|
+
"eslint",
|
|
47
|
+
"eslint-plugin",
|
|
48
|
+
"eslintplugin",
|
|
49
|
+
"cleanup",
|
|
50
|
+
"resources",
|
|
51
|
+
"runtime",
|
|
52
|
+
"typescript"
|
|
53
|
+
],
|
|
54
|
+
homepage: "https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/",
|
|
55
|
+
bugs: {
|
|
56
|
+
url: "https://github.com/Nick2bad4u/eslint-plugin-runtime-cleanup/issues",
|
|
57
|
+
email: "20943337+Nick2bad4u@users.noreply.github.com"
|
|
58
|
+
},
|
|
59
|
+
repository: {
|
|
60
|
+
type: "git",
|
|
61
|
+
url: "git+https://github.com/Nick2bad4u/eslint-plugin-runtime-cleanup.git"
|
|
62
|
+
},
|
|
63
|
+
license: "MIT",
|
|
64
|
+
author: "Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com> (https://github.com/Nick2bad4u)",
|
|
65
|
+
contributors: [
|
|
66
|
+
{
|
|
67
|
+
name: "Nick2bad4u",
|
|
68
|
+
email: "20943337+Nick2bad4u@users.noreply.github.com",
|
|
69
|
+
url: "https://github.com/Nick2bad4u"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
sideEffects: false,
|
|
73
|
+
type: "module",
|
|
74
|
+
exports: {
|
|
75
|
+
".": {
|
|
76
|
+
import: {
|
|
77
|
+
types: "./dist/plugin.d.ts",
|
|
78
|
+
default: "./dist/plugin.js"
|
|
79
|
+
},
|
|
80
|
+
require: {
|
|
81
|
+
types: "./dist/plugin.d.cts",
|
|
82
|
+
default: "./dist/plugin.cjs"
|
|
83
|
+
},
|
|
84
|
+
default: "./dist/plugin.js"
|
|
85
|
+
},
|
|
86
|
+
"./package.json": "./package.json"
|
|
87
|
+
},
|
|
88
|
+
main: "./dist/plugin.cjs",
|
|
89
|
+
types: "./dist/plugin.d.ts",
|
|
90
|
+
files: [
|
|
91
|
+
"dist",
|
|
92
|
+
"docs/rules/**",
|
|
93
|
+
"CHANGELOG.md"
|
|
94
|
+
],
|
|
95
|
+
workspaces: [
|
|
96
|
+
"docs/docusaurus"
|
|
97
|
+
],
|
|
98
|
+
scripts: {
|
|
99
|
+
prebench: "npm run build",
|
|
100
|
+
bench: "node benchmarks/run-eslint-stats.mjs",
|
|
101
|
+
"prebench:compare": "npm run build",
|
|
102
|
+
"bench:compare": "node benchmarks/run-eslint-stats.mjs --iterations=6 --warmup=2 --compare=coverage/benchmarks/eslint-stats.json",
|
|
103
|
+
"prebench:eslint:stats": "npm run build",
|
|
104
|
+
"bench:eslint:stats": "node benchmarks/run-eslint-stats.mjs",
|
|
105
|
+
"prebench:eslint:timing": "npm run build",
|
|
106
|
+
"bench:eslint:timing": 'cross-env TIMING=all eslint --config benchmarks/eslint-timing.config.mjs --stats "test/fixtures/typed/*.invalid.ts"',
|
|
107
|
+
"prebench:rule-benchmark": "npm run build",
|
|
108
|
+
"bench:rule-benchmark": "eslint-rule-benchmark run",
|
|
109
|
+
"prebench:ui": "npm run build",
|
|
110
|
+
"bench:ui": "vitest bench --ui",
|
|
111
|
+
"prebench:watch": "npm run build",
|
|
112
|
+
"bench:watch": "vitest bench",
|
|
113
|
+
build: "tsc -b tsconfig.build.json --force && npm run build:types:cjs && npm run build:cjs",
|
|
114
|
+
"build:cjs": 'esbuild dist/plugin.js --bundle --format=cjs --platform=node --packages=external --sourcemap --outfile=dist/plugin.cjs --footer:js="module.exports = module.exports.default;"',
|
|
115
|
+
"build:clean": `node -e "require('node:fs').rmSync('dist',{recursive:true,force:true})"`,
|
|
116
|
+
"build:eslint-inspector": 'npx -y @eslint/config-inspector@latest build --outDir "docs/docusaurus/static/eslint-inspector" --base "/eslint-plugin-runtime-cleanup/eslint-inspector/"',
|
|
117
|
+
"build:eslint-inspector:local": "npx @eslint/config-inspector",
|
|
118
|
+
"build:stylelint-inspector": 'npx -y stylelint-config-inspector@latest build --outDir "docs/docusaurus/static/stylelint-inspector" --base "/eslint-plugin-runtime-cleanup/stylelint-inspector/"',
|
|
119
|
+
"build:stylelint-inspector:local": "npx stylelint-config-inspector@latest",
|
|
120
|
+
"build:types:cjs": `node -e "require('node:fs').copyFileSync('dist/plugin.d.ts','dist/plugin.d.cts')"`,
|
|
121
|
+
changelog: "git-cliff --config cliff.toml --current",
|
|
122
|
+
"changelog:generate": "git-cliff --config cliff.toml --output CHANGELOG.md",
|
|
123
|
+
"changelog:preview": "git-cliff --config cliff.toml --unreleased",
|
|
124
|
+
"changelog:release-notes": "git-cliff --config cliff.toml --latest --strip all",
|
|
125
|
+
"clean:cache": "del-cli dist coverage cache .cache .vite .turbo",
|
|
126
|
+
"clean:cache:coverage": "del-cli coverage .coverage",
|
|
127
|
+
"clean:cache:dist": "del-cli dist release",
|
|
128
|
+
"clean:cache:eslint": "del-cli .cache/.eslintcache",
|
|
129
|
+
"clean:cache:ncu": "del-cli .cache/.ncu-cache.json",
|
|
130
|
+
"clean:cache:prettier": "del-cli .cache/.prettier-cache .prettier-cache .prettiercache",
|
|
131
|
+
"clean:cache:stryker": "del-cli .stryker-tmp",
|
|
132
|
+
"clean:cache:stylelint": "del-cli .cache/stylelintcache stylelintcache .stylelintcache",
|
|
133
|
+
"clean:cache:temp": 'del-cli ".temp/**"',
|
|
134
|
+
"clean:cache:typescript": "del-cli .cache/**.tsbuildinfo .cache/builds",
|
|
135
|
+
"clean:cache:vite": "del-cli .cache/vite .cache/vitest .cache/vitest-zero-coverage .cache/vite-zero-coverage",
|
|
136
|
+
"clean:database": "del-cli %appdata%/uptime-watcher/uptime-watcher.sqlite",
|
|
137
|
+
"clean:docs": "del-cli docs/docusaurus/.docusaurus/** docs/docusaurus/build/** docs/docusaurus/site-docs/developer/api/**",
|
|
138
|
+
"clean:docusaurus": "npm run clean:docs && npm run --workspace docs/docusaurus clear",
|
|
139
|
+
"cognitive-complexity": "cognitive-complexity-ts --threshold 10",
|
|
140
|
+
precommit: "npm run sync:rules:write",
|
|
141
|
+
commit: "git-cz",
|
|
142
|
+
contrib: "all-contributors",
|
|
143
|
+
"contrib:add": "all-contributors add",
|
|
144
|
+
"contrib:check": "all-contributors check",
|
|
145
|
+
"contrib:compare": "npm run contrib:check",
|
|
146
|
+
"contrib:generate": "all-contributors generate",
|
|
147
|
+
coverage: "vitest run --coverage",
|
|
148
|
+
"docs:api": "npm run --workspace docs/docusaurus docs:api",
|
|
149
|
+
"docs:api:local": "npm run --workspace docs/docusaurus docs:api:local",
|
|
150
|
+
"docs:build": "npm run --workspace docs/docusaurus build",
|
|
151
|
+
"docs:build:local": "npm run --workspace docs/docusaurus build:local",
|
|
152
|
+
"docs:check-links": "npm run docs:api && node ./scripts/check-doc-links.mjs",
|
|
153
|
+
"docs:devtools:metadata": "node scripts/generate-devtools-workspace-metadata.mjs",
|
|
154
|
+
"docs:serve": "npm run --workspace docs/docusaurus serve",
|
|
155
|
+
"docs:start": "npm run --workspace docs/docusaurus start",
|
|
156
|
+
"docs:start:devtools": "npm run docs:devtools:metadata && npm run docs:api:local && npm run --workspace docs/docusaurus start:devtools",
|
|
157
|
+
"docs:toc": "remark docs --use remark-toc --output",
|
|
158
|
+
"docs:typecheck": "npm run --workspace docs/docusaurus typecheck",
|
|
159
|
+
"docs:typedoc": "npm run --workspace docs/docusaurus docs:api",
|
|
160
|
+
"docs:typedoc:local": "npm run --workspace docs/docusaurus docs:api:local",
|
|
161
|
+
"docs:validate-links": "remark docs --use remark-validate-links --frail",
|
|
162
|
+
knip: "cross-env NODE_OPTIONS=--max_old_space_size=4096 NODE_NO_WARNINGS=1 npx knip -c knip.config.ts --cache --cache-location .cache/knip --tsConfig tsconfig.json",
|
|
163
|
+
lint: "cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint . --cache --cache-strategy content --cache-location .cache/.eslintcache",
|
|
164
|
+
"lint:action": "npm run lint:actions",
|
|
165
|
+
"lint:actions": "node scripts/lint-actionlint.mjs",
|
|
166
|
+
"lint:all": "npm run lint && npm run typecheck && npm run lint:css && npm run lint:prettier && npm run lint:remark && npm run lint:package && npm run lint:secretlint && npm run lint:yaml && npm run lint:actions && npm run lint:circular && npm run sync:rules:check",
|
|
167
|
+
"lint:all:fix": "npm run lint:fix && npm run typecheck && npm run lint:css:fix && npm run lint:prettier:fix && npm run lint:remark && npm run lint:package && npm run lint:secretlint && npm run lint:yaml:fix && npm run lint:actions && npm run lint:circular && npm run sync:rules:write",
|
|
168
|
+
"lint:all:fix:quiet": "npm run lint:fix:quiet && npm run typecheck && npm run lint:css:fix && npm run lint:prettier:fix && npm run lint:remark && npm run lint:package && npm run lint:secretlint && npm run lint:yaml:fix && npm run lint:actions && npm run lint:circular && npm run sync:rules:write",
|
|
169
|
+
"lint:circular": "npm run madge:circular",
|
|
170
|
+
"lint:compat:eslint9": "node scripts/eslint9-compat-smoke.mjs",
|
|
171
|
+
"lint:config:build": "npm run build:eslint-inspector",
|
|
172
|
+
"lint:config:inspect": "npx eslint --inspect-config",
|
|
173
|
+
"lint:css": 'stylelint --cache --config stylelint.config.mjs --cache-strategy content --cache-location .cache/stylelintcache src/ docs/ --custom-formatter stylelint-formatter-pretty && echo "Stylelint done!"',
|
|
174
|
+
"lint:css:fix": 'stylelint --cache --config stylelint.config.mjs --cache-strategy content --cache-location .cache/stylelintcache src/ docs/ --custom-formatter stylelint-formatter-pretty --fix && echo "Stylelint done!"',
|
|
175
|
+
"lint:depcheck": "npm run knip -- --dependencies",
|
|
176
|
+
"lint:deps": "npm run knip -- --dependencies",
|
|
177
|
+
"lint:dupes": "jscpd src/ --config jscpd.json",
|
|
178
|
+
"lint:dupes:all": "jscpd src/ --config jscpd.json --min-lines 3",
|
|
179
|
+
"lint:dupes:skiplocal": "jscpd src/ --skipLocal --config jscpd.json",
|
|
180
|
+
"lint:dupes:skiplocal:all": "jscpd src/ --skipLocal --config jscpd.json --min-lines 3",
|
|
181
|
+
"lint:duplicates": "npm run lint:dupes",
|
|
182
|
+
"lint:exports": "ts-unused-exports tsconfig.json src/plugin.ts --excludePathsFromReport=plugin.ts",
|
|
183
|
+
"lint:fix": "cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint . --cache --cache-strategy content --cache-location .cache/.eslintcache --fix",
|
|
184
|
+
"lint:fix:quiet": 'cross-env ESLINT_PROGRESS=off NODE_OPTIONS=--max_old_space_size=16384 eslint . --cache --cache-strategy content --cache-location .cache/.eslintcache --fix && echo "Eslint fix done!"',
|
|
185
|
+
"lint:grype": "grype . -c .grype.yaml --name eslint-plugin-runtime-cleanup",
|
|
186
|
+
"lint:knip": "npm run knip",
|
|
187
|
+
"lint:knip:exports": "npm run knip -- --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates",
|
|
188
|
+
"lint:knip:unused:exports": "npm run knip -- --dependencies --exports",
|
|
189
|
+
"lint:leaves": "npm run madge:leaves",
|
|
190
|
+
"lint:metrics": "npm run sloc",
|
|
191
|
+
"lint:nocache": "cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint .",
|
|
192
|
+
"lint:node-version-files": "node scripts/sync-node-version-files.mjs --check",
|
|
193
|
+
"lint:orphans": "npm run madge:orphans",
|
|
194
|
+
"lint:package": 'npm run lint:node-version-files && npm run lint:package-sort && npm run lint:packagelintrc && echo "Package.json lint done!"',
|
|
195
|
+
"lint:package:strict": 'npm run lint:node-version-files && npm run lint:package-sort && npm run lint:package-check:strict && npm run lint:packagelintrc && echo "Package.json lint done!"',
|
|
196
|
+
"lint:package-check": "publint && attw --pack .",
|
|
197
|
+
"lint:package-check:strict": "publint && node scripts/check-package-types.mjs",
|
|
198
|
+
"lint:package-sort": 'sort-package-json "./package.json" "./docs/docusaurus/package.json"',
|
|
199
|
+
"lint:package-sort-check": 'sort-package-json --check "./package.json" "./docs/docusaurus/package.json"',
|
|
200
|
+
"lint:packagelintrc": "npmPkgJsonLint . --config .npmpackagejsonlintrc.json",
|
|
201
|
+
"lint:prettier": "prettier . --log-level warn --cache --cache-location=.cache/.prettier-cache --cache-strategy=content --check",
|
|
202
|
+
"lint:prettier:fix": "prettier . --log-level warn --cache --cache-location=.cache/.prettier-cache --cache-strategy=content --write",
|
|
203
|
+
"lint:publint": "publint",
|
|
204
|
+
"lint:quiet": 'cross-env ESLINT_PROGRESS=nofile NODE_OPTIONS=--max_old_space_size=16384 eslint . --cache --cache-strategy content --cache-location .cache/.eslintcache && echo "Eslint done!"',
|
|
205
|
+
"lint:remark": 'remark --rc-path .remarkrc.mjs --silently-ignore --ignore-path .remarkignore --frail "*.{md,mdx}" "docs/**/*.{md,mdx}" --quiet',
|
|
206
|
+
"lint:remark:fix": 'prettier --log-level warn --ignore-path prettierignore.remark --cache --cache-location=.cache/.prettier-cache --cache-strategy=content --no-error-on-unmatched-pattern --write "*.{md,mdx}" "docs/**/*.{md,mdx}" && npm run remark:fix',
|
|
207
|
+
"lint:secretlint": 'secretlint --secretlintrc .secretlintrc.cjs --secretlintignore .secretlintignore "./*" ".vscode/**" "assets/**" "src/**" "electron/**" "shared/**" "config/**" "scripts/**" "playwright/**" "storybook/**" ".storybook" "tests/**" "benchmarks/**" ".devin/**" "public/**" ".github/**" "docs/Architecture/**" "docs/*" "docs/assets/**" "docs/Guides/**" "docs/Testing/**" "docs/TSDoc/**" "docs/docusaurus/src/**" "docs/docusaurus/static/**" "docs/docusaurus/blog/**" "docs/docusaurus/docs/**" "docs/docusaurus/docs/*"',
|
|
208
|
+
"lint:secrets": "detect-secrets scan",
|
|
209
|
+
"lint:unused": "npm run knip -- --include unlisted,unresolved,duplicates",
|
|
210
|
+
"lint:unused-deps": "npm run knip -- --dependencies",
|
|
211
|
+
"lint:yaml": 'cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint --cache --cache-strategy content --cache-location .cache/.eslintcache "**/*.{yml,yaml}" && echo "YAML lint done!"',
|
|
212
|
+
"lint:yaml:fix": 'cross-env NODE_OPTIONS=--max_old_space_size=16384 eslint --cache --cache-strategy content --cache-location .cache/.eslintcache --fix "**/*.{yml,yaml}" && echo "YAML lint (fix) done!"',
|
|
213
|
+
"madge:circular": 'madge --circular --json --no-spinner --ts-config tsconfig.json --extensions ts,tsx,js,jsx,mjs,cjs,cts,mts ./src --exclude "(^|[\\/])(test|dist|node_modules|cache|.cache|coverage|build|eslint-inspector|temp|.docusaurus)($|[\\/])|\\.css$"',
|
|
214
|
+
"madge:leaves": 'madge --leaves --no-spinner --ts-config tsconfig.json --extensions ts,tsx,js,jsx,mjs,cjs,cts,mts ./src --exclude "(^|[\\/])(test|dist|node_modules|cache|.cache|coverage|build|eslint-inspector|temp|.docusaurus)($|[\\/])|\\.css$"',
|
|
215
|
+
"madge:orphans": 'madge --orphans --no-spinner --ts-config tsconfig.json --extensions ts,tsx,js,jsx,mjs,cjs,cts,mts ./src --exclude "(^|[\\/])(test|dist|node_modules|cache|.cache|coverage|build|eslint-inspector|temp|.docusaurus)($|[\\/])|\\.css$"',
|
|
216
|
+
"open:coverage": "open-cli coverage/index.html",
|
|
217
|
+
prepublishOnly: "npm run release:check",
|
|
218
|
+
"release:check": "npm run release:verify",
|
|
219
|
+
"release:verify": "cross-env NODE_OPTIONS= npm run build && cross-env NODE_OPTIONS= npm run lint:nocache && cross-env NODE_OPTIONS= npm run typecheck && cross-env NODE_OPTIONS= VITEST_TYPECHECK=false npm run test && cross-env NODE_OPTIONS= npm run sync:rules:check && cross-env NODE_OPTIONS= npm run docs:check-links && cross-env NODE_OPTIONS= npm run lint:package:strict",
|
|
220
|
+
"remark:fix": 'remark --rc-path .remarkrc.mjs --silently-ignore --ignore-path .remarkignore --frail --quiet --output -- "*.{md,mdx}" "docs/**/*.{md,mdx}"',
|
|
221
|
+
"remark:test-config": 'remark --rc-path .remarkrc.mjs --silently-ignore --ignore-path .remarkignore --frail "README.md"',
|
|
222
|
+
size: "size-limit",
|
|
223
|
+
"sync:node-version-files": "node scripts/sync-node-version-files.mjs",
|
|
224
|
+
"sync:peer-eslint-range": "node scripts/sync-peer-eslint-range.mjs",
|
|
225
|
+
"sync:presets-rules-matrix": "node scripts/sync-presets-rules-matrix.mjs",
|
|
226
|
+
"sync:readme-rules-table": "node scripts/sync-readme-rules-table.mjs",
|
|
227
|
+
"sync:readme-rules-table:update": "npm run build && cross-env RUNTIME_CLEANUP_UPDATE_GENERATED_DOCS=1 vitest run test/readme-rules-table-sync.test.ts -u",
|
|
228
|
+
"sync:readme-rules-table:write": "node scripts/sync-readme-rules-table.mjs --write",
|
|
229
|
+
"sync:rules:check": "npm run sync:readme-rules-table && npm run sync:presets-rules-matrix",
|
|
230
|
+
"sync:rules:write": "npm run sync:readme-rules-table:write && node scripts/sync-presets-rules-matrix.mjs --write",
|
|
231
|
+
pretest: "npm run build",
|
|
232
|
+
test: "vitest run",
|
|
233
|
+
"test:autofix:fixtures": `node -e "console.log('No autofix fixtures are defined yet.')"`,
|
|
234
|
+
"test:autofix:fixtures:typed": `node -e "console.log('No typed autofix fixtures are defined yet.')"`,
|
|
235
|
+
"test:ci": "cross-env CI=true vitest run --reporter=default",
|
|
236
|
+
"test:coverage": "vitest run --coverage --reporter=default",
|
|
237
|
+
"test:coverage:detailed": "vitest run --coverage --reporter=verbose",
|
|
238
|
+
"test:coverage:minimal": "vitest run --coverage --reporter=dot",
|
|
239
|
+
"test:coverage:open": "npm run test:coverage && npm run open:coverage",
|
|
240
|
+
"test:coverage:quiet": "vitest run --coverage --reporter=default --silent",
|
|
241
|
+
"test:coverage:verbose": "vitest run --coverage --reporter=verbose",
|
|
242
|
+
"test:detailed": "vitest run --reporter=verbose",
|
|
243
|
+
"test:minimal": "vitest run --reporter=dot",
|
|
244
|
+
"test:open": "npm run test:coverage && npm run open:coverage",
|
|
245
|
+
"test:quiet": "vitest run --reporter=default --silent",
|
|
246
|
+
"test:serial": "cross-env MAX_THREADS=1 vitest run",
|
|
247
|
+
"test:stryker": "stryker run --ignoreStatic --concurrency 12 --incrementalFile .cache/stryker/incremental-fast.json",
|
|
248
|
+
"test:stryker:ci": "cross-env CI=true stryker run --ignoreStatic --concurrency 2 --incrementalFile .cache/stryker/incremental-fast-ci.json",
|
|
249
|
+
"test:stryker:full": "stryker run --concurrency 12 --incrementalFile .cache/stryker/incremental-full.json",
|
|
250
|
+
"test:stryker:full:ci": "cross-env CI=true stryker run --concurrency 2 --incrementalFile .cache/stryker/incremental-full-ci.json",
|
|
251
|
+
"test:verbose": "vitest run --reporter=verbose",
|
|
252
|
+
"test:watch": "vitest",
|
|
253
|
+
typecheck: "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.build.json --noEmit && tsc -p tsconfig.eslint.json --noEmit && tsc -p tsconfig.js.json --noEmit && npm run --workspace docs/docusaurus typecheck",
|
|
254
|
+
"typecheck:all": "npm run typecheck",
|
|
255
|
+
"types:update": "typesync",
|
|
256
|
+
"update-deps": "npx ncu -i --install never && npm update --workspaces --force && npm install --force && npm run sync:peer-eslint-range && npm run sync:node-version-files && npm run sync:rules:write",
|
|
257
|
+
"verify:readme-rules-table": "npm run build && npm run sync:rules:write"
|
|
258
|
+
},
|
|
259
|
+
overrides: {
|
|
260
|
+
"jsonc-eslint-parser": "$jsonc-eslint-parser"
|
|
261
|
+
},
|
|
262
|
+
dependencies: {
|
|
263
|
+
"@typescript-eslint/parser": "^8.59.3",
|
|
264
|
+
"@typescript-eslint/type-utils": "^8.59.3",
|
|
265
|
+
"@typescript-eslint/utils": "^8.59.3"
|
|
266
|
+
},
|
|
267
|
+
devDependencies: {
|
|
268
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
269
|
+
"@csstools/stylelint-formatter-github": "^2.0.0",
|
|
270
|
+
"@double-great/remark-lint-alt-text": "^1.1.1",
|
|
271
|
+
"@eslint/config-inspector": "^3.0.2",
|
|
272
|
+
"@microsoft/tsdoc-config": "^0.18.1",
|
|
273
|
+
"@size-limit/file": "^12.1.0",
|
|
274
|
+
"@stryker-ignorer/console-all": "^0.3.2",
|
|
275
|
+
"@stryker-mutator/core": "^9.6.1",
|
|
276
|
+
"@stryker-mutator/typescript-checker": "^9.6.1",
|
|
277
|
+
"@stryker-mutator/vitest-runner": "^9.6.1",
|
|
278
|
+
"@types/htmlhint": "^1.1.5",
|
|
279
|
+
"@types/madge": "^5.0.3",
|
|
280
|
+
"@types/node": "^25.8.0",
|
|
281
|
+
"@types/sloc": "^0.2.3",
|
|
282
|
+
"@typescript-eslint/rule-tester": "^8.59.3",
|
|
283
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
284
|
+
"@vitest/ui": "^4.1.6",
|
|
285
|
+
actionlint: "^2.0.6",
|
|
286
|
+
"all-contributors-cli": "^6.26.1",
|
|
287
|
+
"cognitive-complexity-ts": "^0.8.1",
|
|
288
|
+
commitlint: "^21.0.1",
|
|
289
|
+
"commitlint-config-gitmoji": "^2.3.1",
|
|
290
|
+
"cross-env": "^10.1.0",
|
|
291
|
+
"del-cli": "^7.0.0",
|
|
292
|
+
"detect-secrets": "^1.0.6",
|
|
293
|
+
esbuild: "^0.28.0",
|
|
294
|
+
eslint: "^10.4.0",
|
|
295
|
+
"eslint-config-nick2bad4u": "^1.0.16",
|
|
296
|
+
"eslint-formatter-unix": "^9.0.1",
|
|
297
|
+
"eslint-rule-benchmark": "^0.8.0",
|
|
298
|
+
"fast-check": "^4.8.0",
|
|
299
|
+
"git-cliff": "^2.13.1",
|
|
300
|
+
"gitleaks-secret-scanner": "^2.1.1",
|
|
301
|
+
htmlhint: "^1.9.2",
|
|
302
|
+
jscpd: "^4.2.2",
|
|
303
|
+
knip: "^6.14.1",
|
|
304
|
+
leasot: "^14.4.0",
|
|
305
|
+
madge: "^8.0.0",
|
|
306
|
+
"markdown-link-check": "^3.14.2",
|
|
307
|
+
"npm-check-updates": "^22.2.0",
|
|
308
|
+
"npm-package-json-lint": "^10.4.0",
|
|
309
|
+
picocolors: "^1.1.1",
|
|
310
|
+
prettier: "^3.8.3",
|
|
311
|
+
"prettier-config-nick2bad4u": "^1.0.13",
|
|
312
|
+
"prettier-plugin-jsdoc-type": "^0.2.0",
|
|
313
|
+
publint: "^0.3.21",
|
|
314
|
+
"rehype-katex": "^7.0.1",
|
|
315
|
+
remark: "^15.0.1",
|
|
316
|
+
"remark-cli": "^12.0.1",
|
|
317
|
+
"remark-config-nick2bad4u": "^1.0.2",
|
|
318
|
+
secretlint: "^13.0.2",
|
|
319
|
+
"secretlint-config-nick2bad4u": "^1.0.5",
|
|
320
|
+
"size-limit": "^12.1.0",
|
|
321
|
+
sloc: "^0.3.2",
|
|
322
|
+
"sort-package-json": "^3.6.1",
|
|
323
|
+
stylelint: "^17.11.1",
|
|
324
|
+
"stylelint-config-nick2bad4u": "^1.0.11",
|
|
325
|
+
"ts-unused-exports": "^11.0.1",
|
|
326
|
+
typedoc: "^0.28.19",
|
|
327
|
+
typescript: "^6.0.3",
|
|
328
|
+
"typescript-eslint": "^8.59.3",
|
|
329
|
+
typesync: "^0.14.3",
|
|
330
|
+
vfile: "^6.0.3",
|
|
331
|
+
vite: "^8.0.13",
|
|
332
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
333
|
+
vitest: "^4.1.6",
|
|
334
|
+
"yamllint-js": "^0.2.4"
|
|
335
|
+
},
|
|
336
|
+
peerDependencies: {
|
|
337
|
+
eslint: "^9.0.0 || ^10.4.0",
|
|
338
|
+
typescript: "^5.0.0 || ^6.0.2"
|
|
339
|
+
},
|
|
340
|
+
packageManager: "npm@11.14.1",
|
|
341
|
+
engines: {
|
|
342
|
+
node: ">=22.0.0"
|
|
343
|
+
},
|
|
344
|
+
devEngines: {
|
|
345
|
+
runtime: {
|
|
346
|
+
name: "node",
|
|
347
|
+
version: ">=22.0.0",
|
|
348
|
+
onFail: "error"
|
|
349
|
+
},
|
|
350
|
+
packageManager: {
|
|
351
|
+
name: "npm",
|
|
352
|
+
version: ">=11.0.0",
|
|
353
|
+
onFail: "error"
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
publishConfig: {
|
|
357
|
+
provenance: true,
|
|
358
|
+
registry: "https://registry.npmjs.org/"
|
|
359
|
+
},
|
|
360
|
+
readme: "README.md"
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// dist/rules/no-floating-abort-controllers.js
|
|
364
|
+
var import_utils3 = require("@typescript-eslint/utils");
|
|
365
|
+
|
|
366
|
+
// dist/_internal/ast-node.js
|
|
367
|
+
var import_utils = require("@typescript-eslint/utils");
|
|
368
|
+
|
|
369
|
+
// dist/_internal/cycle-safe-linked-search.js
|
|
370
|
+
var FLOYD_FAST_POINTER_ADVANCE_STEPS = 2;
|
|
371
|
+
var resolveFirstValueInLinkedStructure = ({ getNextNode, resolveValue, startNode }) => {
|
|
372
|
+
let slowNode = startNode;
|
|
373
|
+
let fastNode = startNode;
|
|
374
|
+
while (slowNode !== null) {
|
|
375
|
+
const resolvedValue = resolveValue(slowNode);
|
|
376
|
+
if (resolvedValue.found) {
|
|
377
|
+
return resolvedValue;
|
|
378
|
+
}
|
|
379
|
+
slowNode = getNextNode(slowNode);
|
|
380
|
+
for (let step = 0; step < FLOYD_FAST_POINTER_ADVANCE_STEPS; step += 1) {
|
|
381
|
+
if (fastNode === null) {
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
fastNode = getNextNode(fastNode);
|
|
385
|
+
}
|
|
386
|
+
if (slowNode !== null && fastNode !== null && slowNode === fastNode) {
|
|
387
|
+
return {
|
|
388
|
+
found: false
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
found: false
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// dist/_internal/ast-node.js
|
|
398
|
+
var hasOptionalParentProperty = (node) => "parent" in node;
|
|
399
|
+
var getParentNode = (node) => hasOptionalParentProperty(node) ? node.parent : void 0;
|
|
400
|
+
|
|
401
|
+
// dist/_internal/rule-docs-url.js
|
|
402
|
+
var RULE_DOCS_URL_BASE = "https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/";
|
|
403
|
+
var createRuleDocsUrl = (ruleName) => `${RULE_DOCS_URL_BASE}${ruleName}`;
|
|
404
|
+
|
|
405
|
+
// dist/_internal/scope-variable.js
|
|
406
|
+
var getVariableInScopeChain = (scope, variableName) => {
|
|
407
|
+
const lookupResult = resolveFirstValueInLinkedStructure({
|
|
408
|
+
getNextNode: (currentScope) => currentScope.upper,
|
|
409
|
+
resolveValue: (currentScope) => {
|
|
410
|
+
const variable = currentScope.set.get(variableName);
|
|
411
|
+
return variable === void 0 ? {
|
|
412
|
+
found: false
|
|
413
|
+
} : {
|
|
414
|
+
found: true,
|
|
415
|
+
value: variable
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
startNode: scope
|
|
419
|
+
});
|
|
420
|
+
return lookupResult.found ? lookupResult.value : null;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// dist/_internal/typed-rule.js
|
|
424
|
+
var import_utils2 = require("@typescript-eslint/utils");
|
|
425
|
+
|
|
426
|
+
// dist/_internal/plugin-settings.js
|
|
427
|
+
var RUNTIME_CLEANUP_SETTINGS_KEY = "runtime-cleanup";
|
|
428
|
+
var DISABLE_ALL_AUTOFIXES_KEY = "disableAllAutofixes";
|
|
429
|
+
var settingsByProgram = /* @__PURE__ */ new WeakMap();
|
|
430
|
+
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
431
|
+
var getRuntimeCleanupSettings = (settings) => {
|
|
432
|
+
if (!isObject(settings)) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
const pluginSettings = settings[RUNTIME_CLEANUP_SETTINGS_KEY];
|
|
436
|
+
return isObject(pluginSettings) ? pluginSettings : null;
|
|
437
|
+
};
|
|
438
|
+
var readBooleanFlag = (object, key) => Object.hasOwn(object, key) && object[key] === true;
|
|
439
|
+
var readDisableAllAutofixesFromSettings = (settings) => {
|
|
440
|
+
const pluginSettings = getRuntimeCleanupSettings(settings);
|
|
441
|
+
if (pluginSettings === null) {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
return readBooleanFlag(pluginSettings, DISABLE_ALL_AUTOFIXES_KEY);
|
|
445
|
+
};
|
|
446
|
+
var registerProgramSettingsForContext = (context) => {
|
|
447
|
+
const programNode = context.sourceCode.ast;
|
|
448
|
+
const parsedSettings = Object.freeze({
|
|
449
|
+
disableAllAutofixes: readDisableAllAutofixesFromSettings(context.settings)
|
|
450
|
+
});
|
|
451
|
+
const existingProgramSettings = settingsByProgram.get(programNode);
|
|
452
|
+
if (existingProgramSettings !== void 0) {
|
|
453
|
+
return existingProgramSettings;
|
|
454
|
+
}
|
|
455
|
+
settingsByProgram.set(programNode, parsedSettings);
|
|
456
|
+
return parsedSettings;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// dist/_internal/rule-catalog.js
|
|
460
|
+
var orderedRuleNames = [
|
|
461
|
+
"no-floating-timers",
|
|
462
|
+
"no-unmanaged-event-listeners",
|
|
463
|
+
"no-floating-observers",
|
|
464
|
+
"no-floating-workers",
|
|
465
|
+
"no-floating-child-processes",
|
|
466
|
+
"no-floating-abort-controllers",
|
|
467
|
+
"no-floating-streams",
|
|
468
|
+
"no-floating-disposable-stacks",
|
|
469
|
+
"no-floating-network-connections",
|
|
470
|
+
"no-floating-file-watchers",
|
|
471
|
+
"no-floating-broadcast-channels",
|
|
472
|
+
"no-floating-message-channels",
|
|
473
|
+
"no-floating-servers",
|
|
474
|
+
"no-floating-geolocation-watches",
|
|
475
|
+
"no-floating-media-streams",
|
|
476
|
+
"no-floating-wake-locks",
|
|
477
|
+
"no-floating-object-urls",
|
|
478
|
+
"no-floating-audio-contexts",
|
|
479
|
+
"no-floating-web-stream-locks",
|
|
480
|
+
"no-floating-infinite-animations"
|
|
481
|
+
];
|
|
482
|
+
var toRuleCatalogId = (ruleNumber) => `R${String(ruleNumber).padStart(3, "0")}`;
|
|
483
|
+
var runtimeCleanupRuleCatalogEntries = orderedRuleNames.map((ruleName, index) => {
|
|
484
|
+
const ruleNumber = index + 1;
|
|
485
|
+
return {
|
|
486
|
+
ruleId: toRuleCatalogId(ruleNumber),
|
|
487
|
+
ruleName,
|
|
488
|
+
ruleNumber
|
|
489
|
+
};
|
|
490
|
+
});
|
|
491
|
+
var runtimeCleanupRuleCatalogByRuleName = Object.fromEntries(runtimeCleanupRuleCatalogEntries.map((entry) => [entry.ruleName, entry]));
|
|
492
|
+
var getRuleCatalogEntryForRuleNameOrNull = (ruleName) => runtimeCleanupRuleCatalogByRuleName[ruleName] ?? null;
|
|
493
|
+
var runtimeCleanupRuleCatalogByRuleId = new Map(runtimeCleanupRuleCatalogEntries.map((entry) => [entry.ruleId, entry]));
|
|
494
|
+
|
|
495
|
+
// dist/_internal/typed-rule.js
|
|
496
|
+
var createTypedRule = (ruleDefinition) => {
|
|
497
|
+
const catalogEntry = getRuleCatalogEntryForRuleNameOrNull(ruleDefinition.name);
|
|
498
|
+
const createdRule = import_utils2.ESLintUtils.RuleCreator.withoutDocs(ruleDefinition);
|
|
499
|
+
const ruleDocs = createdRule.meta.docs;
|
|
500
|
+
if (ruleDocs === void 0) {
|
|
501
|
+
throw new TypeError(`Rule '${ruleDefinition.name}' must declare meta.docs.`);
|
|
502
|
+
}
|
|
503
|
+
const canonicalDocsUrl = createRuleDocsUrl(ruleDefinition.name);
|
|
504
|
+
if (typeof ruleDocs.url === "string" && ruleDocs.url !== canonicalDocsUrl) {
|
|
505
|
+
throw new TypeError(`Rule '${ruleDefinition.name}' has non-canonical docs.url '${ruleDocs.url}'. Expected '${canonicalDocsUrl}'.`);
|
|
506
|
+
}
|
|
507
|
+
if (catalogEntry === null && ruleDefinition.name.startsWith("require-")) {
|
|
508
|
+
throw new TypeError(`Rule '${ruleDefinition.name}' is missing from the stable rule catalog.`);
|
|
509
|
+
}
|
|
510
|
+
const docsWithCatalog = catalogEntry === null ? {
|
|
511
|
+
...ruleDocs,
|
|
512
|
+
url: canonicalDocsUrl
|
|
513
|
+
} : {
|
|
514
|
+
...ruleDocs,
|
|
515
|
+
ruleId: catalogEntry.ruleId,
|
|
516
|
+
ruleNumber: catalogEntry.ruleNumber,
|
|
517
|
+
url: canonicalDocsUrl
|
|
518
|
+
};
|
|
519
|
+
const metaDefaultOptions = createdRule.meta.defaultOptions;
|
|
520
|
+
return {
|
|
521
|
+
...createdRule,
|
|
522
|
+
create(context) {
|
|
523
|
+
registerProgramSettingsForContext(context);
|
|
524
|
+
return createdRule.create(context);
|
|
525
|
+
},
|
|
526
|
+
meta: {
|
|
527
|
+
...createdRule.meta,
|
|
528
|
+
...metaDefaultOptions === void 0 ? {} : { defaultOptions: metaDefaultOptions },
|
|
529
|
+
docs: docsWithCatalog
|
|
530
|
+
},
|
|
531
|
+
name: ruleDefinition.name
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
var getTypedRuleServices = (context) => {
|
|
535
|
+
const parserServices = import_utils2.ESLintUtils.getParserServices(context, true);
|
|
536
|
+
const program = parserServices.program;
|
|
537
|
+
if (program === null) {
|
|
538
|
+
throw new Error("Typed rule requires parserServices.program; ensure projectService is enabled for this lint run.");
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
checker: program.getTypeChecker(),
|
|
542
|
+
parserServices
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
// dist/rules/no-floating-abort-controllers.js
|
|
547
|
+
var abortControllerConstructorName = "AbortController";
|
|
548
|
+
var globalReceiverNames = [
|
|
549
|
+
"globalThis",
|
|
550
|
+
"self",
|
|
551
|
+
"window"
|
|
552
|
+
];
|
|
553
|
+
var globalReceiverNameSet = new Set(globalReceiverNames);
|
|
554
|
+
var isGlobalReceiverName = (name) => globalReceiverNameSet.has(name);
|
|
555
|
+
var getTransparentWrappedExpression = (node) => {
|
|
556
|
+
if (node.type === import_utils3.AST_NODE_TYPES.ChainExpression) {
|
|
557
|
+
return node.expression;
|
|
558
|
+
}
|
|
559
|
+
if (node.type === import_utils3.AST_NODE_TYPES.TSAsExpression) {
|
|
560
|
+
return node.expression;
|
|
561
|
+
}
|
|
562
|
+
if (node.type === import_utils3.AST_NODE_TYPES.TSNonNullExpression) {
|
|
563
|
+
return node.expression;
|
|
564
|
+
}
|
|
565
|
+
if (node.type === import_utils3.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
566
|
+
return node.expression;
|
|
567
|
+
}
|
|
568
|
+
if (node.type === import_utils3.AST_NODE_TYPES.TSTypeAssertion) {
|
|
569
|
+
return node.expression;
|
|
570
|
+
}
|
|
571
|
+
return void 0;
|
|
572
|
+
};
|
|
573
|
+
var getStaticPropertyName = (node, computed) => {
|
|
574
|
+
if (!computed && node.type === import_utils3.AST_NODE_TYPES.Identifier) {
|
|
575
|
+
return node.name;
|
|
576
|
+
}
|
|
577
|
+
if (computed && node.type === import_utils3.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
578
|
+
return node.value;
|
|
579
|
+
}
|
|
580
|
+
return void 0;
|
|
581
|
+
};
|
|
582
|
+
var isShadowedAbortControllerIdentifier = (context, identifier) => {
|
|
583
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
584
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
585
|
+
return variable !== null && variable.defs.length > 0;
|
|
586
|
+
};
|
|
587
|
+
var isDirectAbortControllerConstructor = (context, callee) => callee.type === import_utils3.AST_NODE_TYPES.Identifier && callee.name === abortControllerConstructorName && !isShadowedAbortControllerIdentifier(context, callee);
|
|
588
|
+
var isMemberAbortControllerConstructor = (callee) => callee.type === import_utils3.AST_NODE_TYPES.MemberExpression && !callee.optional && callee.object.type === import_utils3.AST_NODE_TYPES.Identifier && isGlobalReceiverName(callee.object.name) && getStaticPropertyName(callee.property, callee.computed) === abortControllerConstructorName;
|
|
589
|
+
var isAbortControllerConstructor = (context, callee) => isDirectAbortControllerConstructor(context, callee) || isMemberAbortControllerConstructor(callee);
|
|
590
|
+
var isDiscardedAbortControllerHandle = (node) => {
|
|
591
|
+
let current = node;
|
|
592
|
+
let parent = getParentNode(current);
|
|
593
|
+
while (parent !== void 0) {
|
|
594
|
+
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
595
|
+
if (wrappedExpression === current) {
|
|
596
|
+
current = parent;
|
|
597
|
+
parent = getParentNode(current);
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
if (parent.type === import_utils3.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
601
|
+
return true;
|
|
602
|
+
}
|
|
603
|
+
if (parent.type === import_utils3.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
604
|
+
const unaryParent = getParentNode(parent);
|
|
605
|
+
return unaryParent?.type === import_utils3.AST_NODE_TYPES.ExpressionStatement;
|
|
606
|
+
}
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
return false;
|
|
610
|
+
};
|
|
611
|
+
var isImmediateAbortSignalAccess = (node) => {
|
|
612
|
+
let current = node;
|
|
613
|
+
let parent = getParentNode(current);
|
|
614
|
+
while (parent !== void 0) {
|
|
615
|
+
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
616
|
+
if (wrappedExpression === current) {
|
|
617
|
+
current = parent;
|
|
618
|
+
parent = getParentNode(current);
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
return parent.type === import_utils3.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.optional && getStaticPropertyName(parent.property, parent.computed) === "signal";
|
|
622
|
+
}
|
|
623
|
+
return false;
|
|
624
|
+
};
|
|
625
|
+
var noFloatingAbortControllers = createTypedRule({
|
|
626
|
+
create(context) {
|
|
627
|
+
return {
|
|
628
|
+
NewExpression(node) {
|
|
629
|
+
if (!isAbortControllerConstructor(context, node.callee) || !isDiscardedAbortControllerHandle(node) && !isImmediateAbortSignalAccess(node)) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
context.report({
|
|
633
|
+
messageId: "floatingAbortController",
|
|
634
|
+
node
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
},
|
|
639
|
+
defaultOptions: [],
|
|
640
|
+
meta: {
|
|
641
|
+
docs: {
|
|
642
|
+
description: "require AbortController handles to be retained so work can be aborted during cleanup.",
|
|
643
|
+
recommended: true,
|
|
644
|
+
requiresTypeChecking: false,
|
|
645
|
+
runtimeCleanupConfigs: [
|
|
646
|
+
"runtime-cleanup.configs.recommended",
|
|
647
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
648
|
+
"runtime-cleanup.configs.strict",
|
|
649
|
+
"runtime-cleanup.configs.all"
|
|
650
|
+
],
|
|
651
|
+
url: createRuleDocsUrl("no-floating-abort-controllers")
|
|
652
|
+
},
|
|
653
|
+
messages: {
|
|
654
|
+
floatingAbortController: "Store or return the AbortController handle so abort() can cancel work during cleanup."
|
|
655
|
+
},
|
|
656
|
+
schema: [],
|
|
657
|
+
type: "problem"
|
|
658
|
+
},
|
|
659
|
+
name: "no-floating-abort-controllers"
|
|
660
|
+
});
|
|
661
|
+
var no_floating_abort_controllers_default = noFloatingAbortControllers;
|
|
662
|
+
|
|
663
|
+
// dist/rules/no-floating-audio-contexts.js
|
|
664
|
+
var import_utils5 = require("@typescript-eslint/utils");
|
|
665
|
+
|
|
666
|
+
// dist/_internal/floating-resource.js
|
|
667
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
668
|
+
var getTransparentWrappedExpression2 = (node) => {
|
|
669
|
+
if (node.type === import_utils4.AST_NODE_TYPES.AwaitExpression) {
|
|
670
|
+
return node.argument;
|
|
671
|
+
}
|
|
672
|
+
if (node.type === import_utils4.AST_NODE_TYPES.ChainExpression) {
|
|
673
|
+
return node.expression;
|
|
674
|
+
}
|
|
675
|
+
if (node.type === import_utils4.AST_NODE_TYPES.TSAsExpression) {
|
|
676
|
+
return node.expression;
|
|
677
|
+
}
|
|
678
|
+
if (node.type === import_utils4.AST_NODE_TYPES.TSNonNullExpression) {
|
|
679
|
+
return node.expression;
|
|
680
|
+
}
|
|
681
|
+
if (node.type === import_utils4.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
682
|
+
return node.expression;
|
|
683
|
+
}
|
|
684
|
+
if (node.type === import_utils4.AST_NODE_TYPES.TSTypeAssertion) {
|
|
685
|
+
return node.expression;
|
|
686
|
+
}
|
|
687
|
+
return void 0;
|
|
688
|
+
};
|
|
689
|
+
var getStaticPropertyName2 = (node, computed) => {
|
|
690
|
+
if (!computed && node.type === import_utils4.AST_NODE_TYPES.Identifier) {
|
|
691
|
+
return node.name;
|
|
692
|
+
}
|
|
693
|
+
if (computed && node.type === import_utils4.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
694
|
+
return node.value;
|
|
695
|
+
}
|
|
696
|
+
return void 0;
|
|
697
|
+
};
|
|
698
|
+
var collectStaticMemberPath = (node) => {
|
|
699
|
+
if (node.type === import_utils4.AST_NODE_TYPES.Identifier) {
|
|
700
|
+
return [node.name];
|
|
701
|
+
}
|
|
702
|
+
if (node.type !== import_utils4.AST_NODE_TYPES.MemberExpression || node.optional) {
|
|
703
|
+
return void 0;
|
|
704
|
+
}
|
|
705
|
+
const objectPath = collectStaticMemberPath(node.object);
|
|
706
|
+
const propertyName = getStaticPropertyName2(node.property, node.computed);
|
|
707
|
+
return objectPath === void 0 || propertyName === void 0 ? void 0 : [...objectPath, propertyName];
|
|
708
|
+
};
|
|
709
|
+
var isDiscardedResourceExpression = (node) => {
|
|
710
|
+
let current = node;
|
|
711
|
+
let parent = getParentNode(current);
|
|
712
|
+
while (parent !== void 0) {
|
|
713
|
+
const wrappedExpression = getTransparentWrappedExpression2(parent);
|
|
714
|
+
if (wrappedExpression === current) {
|
|
715
|
+
current = parent;
|
|
716
|
+
parent = getParentNode(current);
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
if (parent.type === import_utils4.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
720
|
+
return true;
|
|
721
|
+
}
|
|
722
|
+
if (parent.type === import_utils4.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
723
|
+
const unaryParent = getParentNode(parent);
|
|
724
|
+
return unaryParent?.type === import_utils4.AST_NODE_TYPES.ExpressionStatement;
|
|
725
|
+
}
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
return false;
|
|
729
|
+
};
|
|
730
|
+
var isImmediateUnownedMemberReceiver = (node, cleanupMemberNames3) => {
|
|
731
|
+
let current = node;
|
|
732
|
+
let parent = getParentNode(current);
|
|
733
|
+
while (parent !== void 0) {
|
|
734
|
+
const wrappedExpression = getTransparentWrappedExpression2(parent);
|
|
735
|
+
if (wrappedExpression === current) {
|
|
736
|
+
current = parent;
|
|
737
|
+
parent = getParentNode(current);
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
if (parent.type !== import_utils4.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
const propertyName = getStaticPropertyName2(parent.property, parent.computed);
|
|
744
|
+
return propertyName === void 0 || !cleanupMemberNames3.has(propertyName);
|
|
745
|
+
}
|
|
746
|
+
return false;
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
// dist/rules/no-floating-audio-contexts.js
|
|
750
|
+
var audioContextConstructorNames = [
|
|
751
|
+
"AudioContext",
|
|
752
|
+
"webkitAudioContext"
|
|
753
|
+
];
|
|
754
|
+
var cleanupMemberNames = /* @__PURE__ */ new Set(["close"]);
|
|
755
|
+
var globalReceiverNames2 = ["globalThis", "self", "window"];
|
|
756
|
+
var audioContextConstructorNameSet = new Set(audioContextConstructorNames);
|
|
757
|
+
var globalReceiverNameSet2 = new Set(globalReceiverNames2);
|
|
758
|
+
var isAudioContextConstructorName = (name) => audioContextConstructorNameSet.has(name);
|
|
759
|
+
var isShadowedIdentifier = (context, identifier) => {
|
|
760
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
761
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
762
|
+
return variable !== null && variable.defs.length > 0;
|
|
763
|
+
};
|
|
764
|
+
var getDirectAudioContextConstructorName = (context, callee) => {
|
|
765
|
+
if (callee.type !== import_utils5.AST_NODE_TYPES.Identifier || !isAudioContextConstructorName(callee.name) || isShadowedIdentifier(context, callee)) {
|
|
766
|
+
return void 0;
|
|
767
|
+
}
|
|
768
|
+
return callee.name;
|
|
769
|
+
};
|
|
770
|
+
var getMemberAudioContextConstructorName = (callee) => {
|
|
771
|
+
if (callee.type !== import_utils5.AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
772
|
+
return void 0;
|
|
773
|
+
}
|
|
774
|
+
const path = collectStaticMemberPath(callee);
|
|
775
|
+
if (path?.length !== 2) {
|
|
776
|
+
return void 0;
|
|
777
|
+
}
|
|
778
|
+
const receiverName = path[0];
|
|
779
|
+
if (receiverName === void 0 || !globalReceiverNameSet2.has(receiverName)) {
|
|
780
|
+
return void 0;
|
|
781
|
+
}
|
|
782
|
+
const constructorName = path[1];
|
|
783
|
+
return constructorName !== void 0 && isAudioContextConstructorName(constructorName) ? constructorName : void 0;
|
|
784
|
+
};
|
|
785
|
+
var getAudioContextConstructorName = (context, callee) => getDirectAudioContextConstructorName(context, callee) ?? getMemberAudioContextConstructorName(callee);
|
|
786
|
+
var noFloatingAudioContexts = createTypedRule({
|
|
787
|
+
create(context) {
|
|
788
|
+
return {
|
|
789
|
+
NewExpression(node) {
|
|
790
|
+
const constructorName = getAudioContextConstructorName(context, node.callee);
|
|
791
|
+
if (constructorName === void 0 || !isDiscardedResourceExpression(node) && !isImmediateUnownedMemberReceiver(node, cleanupMemberNames)) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
context.report({
|
|
795
|
+
data: { constructorName },
|
|
796
|
+
messageId: "floatingAudioContext",
|
|
797
|
+
node
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
},
|
|
802
|
+
defaultOptions: [],
|
|
803
|
+
meta: {
|
|
804
|
+
docs: {
|
|
805
|
+
description: "require AudioContext instances to be retained so they can be closed.",
|
|
806
|
+
recommended: true,
|
|
807
|
+
requiresTypeChecking: false,
|
|
808
|
+
runtimeCleanupConfigs: [
|
|
809
|
+
"runtime-cleanup.configs.recommended",
|
|
810
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
811
|
+
"runtime-cleanup.configs.strict",
|
|
812
|
+
"runtime-cleanup.configs.all"
|
|
813
|
+
],
|
|
814
|
+
url: createRuleDocsUrl("no-floating-audio-contexts")
|
|
815
|
+
},
|
|
816
|
+
messages: {
|
|
817
|
+
floatingAudioContext: "Store or return the {{constructorName}} instance so close() can release audio resources during cleanup."
|
|
818
|
+
},
|
|
819
|
+
schema: [],
|
|
820
|
+
type: "problem"
|
|
821
|
+
},
|
|
822
|
+
name: "no-floating-audio-contexts"
|
|
823
|
+
});
|
|
824
|
+
var no_floating_audio_contexts_default = noFloatingAudioContexts;
|
|
825
|
+
|
|
826
|
+
// dist/rules/no-floating-broadcast-channels.js
|
|
827
|
+
var import_utils6 = require("@typescript-eslint/utils");
|
|
828
|
+
var broadcastChannelConstructorName = "BroadcastChannel";
|
|
829
|
+
var globalReceiverNames3 = [
|
|
830
|
+
"globalThis",
|
|
831
|
+
"self",
|
|
832
|
+
"window"
|
|
833
|
+
];
|
|
834
|
+
var globalReceiverNameSet3 = new Set(globalReceiverNames3);
|
|
835
|
+
var isGlobalReceiverName2 = (name) => globalReceiverNameSet3.has(name);
|
|
836
|
+
var getTransparentWrappedExpression3 = (node) => {
|
|
837
|
+
if (node.type === import_utils6.AST_NODE_TYPES.ChainExpression) {
|
|
838
|
+
return node.expression;
|
|
839
|
+
}
|
|
840
|
+
if (node.type === import_utils6.AST_NODE_TYPES.TSAsExpression) {
|
|
841
|
+
return node.expression;
|
|
842
|
+
}
|
|
843
|
+
if (node.type === import_utils6.AST_NODE_TYPES.TSNonNullExpression) {
|
|
844
|
+
return node.expression;
|
|
845
|
+
}
|
|
846
|
+
if (node.type === import_utils6.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
847
|
+
return node.expression;
|
|
848
|
+
}
|
|
849
|
+
if (node.type === import_utils6.AST_NODE_TYPES.TSTypeAssertion) {
|
|
850
|
+
return node.expression;
|
|
851
|
+
}
|
|
852
|
+
return void 0;
|
|
853
|
+
};
|
|
854
|
+
var getStaticPropertyName3 = (node, computed) => {
|
|
855
|
+
if (!computed && node.type === import_utils6.AST_NODE_TYPES.Identifier) {
|
|
856
|
+
return node.name;
|
|
857
|
+
}
|
|
858
|
+
if (computed && node.type === import_utils6.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
859
|
+
return node.value;
|
|
860
|
+
}
|
|
861
|
+
return void 0;
|
|
862
|
+
};
|
|
863
|
+
var isShadowedBroadcastChannelIdentifier = (context, identifier) => {
|
|
864
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
865
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
866
|
+
return variable !== null && variable.defs.length > 0;
|
|
867
|
+
};
|
|
868
|
+
var isDirectBroadcastChannelConstructor = (context, callee) => callee.type === import_utils6.AST_NODE_TYPES.Identifier && callee.name === broadcastChannelConstructorName && !isShadowedBroadcastChannelIdentifier(context, callee);
|
|
869
|
+
var isMemberBroadcastChannelConstructor = (callee) => callee.type === import_utils6.AST_NODE_TYPES.MemberExpression && !callee.optional && callee.object.type === import_utils6.AST_NODE_TYPES.Identifier && isGlobalReceiverName2(callee.object.name) && getStaticPropertyName3(callee.property, callee.computed) === broadcastChannelConstructorName;
|
|
870
|
+
var isBroadcastChannelConstructor = (context, callee) => isDirectBroadcastChannelConstructor(context, callee) || isMemberBroadcastChannelConstructor(callee);
|
|
871
|
+
var isDiscardedBroadcastChannel = (node) => {
|
|
872
|
+
let current = node;
|
|
873
|
+
let parent = getParentNode(current);
|
|
874
|
+
while (parent !== void 0) {
|
|
875
|
+
const wrappedExpression = getTransparentWrappedExpression3(parent);
|
|
876
|
+
if (wrappedExpression === current) {
|
|
877
|
+
current = parent;
|
|
878
|
+
parent = getParentNode(current);
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
if (parent.type === import_utils6.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
if (parent.type === import_utils6.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
885
|
+
const unaryParent = getParentNode(parent);
|
|
886
|
+
return unaryParent?.type === import_utils6.AST_NODE_TYPES.ExpressionStatement;
|
|
887
|
+
}
|
|
888
|
+
return false;
|
|
889
|
+
}
|
|
890
|
+
return false;
|
|
891
|
+
};
|
|
892
|
+
var isImmediateBroadcastChannelMethodReceiver = (node) => {
|
|
893
|
+
let current = node;
|
|
894
|
+
let parent = getParentNode(current);
|
|
895
|
+
while (parent !== void 0) {
|
|
896
|
+
const wrappedExpression = getTransparentWrappedExpression3(parent);
|
|
897
|
+
if (wrappedExpression === current) {
|
|
898
|
+
current = parent;
|
|
899
|
+
parent = getParentNode(current);
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
if (parent.type !== import_utils6.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
903
|
+
return false;
|
|
904
|
+
}
|
|
905
|
+
if (getStaticPropertyName3(parent.property, parent.computed) === "close") {
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
908
|
+
const callExpression = getParentNode(parent);
|
|
909
|
+
return callExpression?.type === import_utils6.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
910
|
+
}
|
|
911
|
+
return false;
|
|
912
|
+
};
|
|
913
|
+
var noFloatingBroadcastChannels = createTypedRule({
|
|
914
|
+
create(context) {
|
|
915
|
+
return {
|
|
916
|
+
NewExpression(node) {
|
|
917
|
+
if (!isBroadcastChannelConstructor(context, node.callee) || !isDiscardedBroadcastChannel(node) && !isImmediateBroadcastChannelMethodReceiver(node)) {
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
context.report({
|
|
921
|
+
messageId: "floatingBroadcastChannel",
|
|
922
|
+
node
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
},
|
|
927
|
+
defaultOptions: [],
|
|
928
|
+
meta: {
|
|
929
|
+
docs: {
|
|
930
|
+
description: "require BroadcastChannel handles to be retained so they can be closed.",
|
|
931
|
+
recommended: true,
|
|
932
|
+
requiresTypeChecking: false,
|
|
933
|
+
runtimeCleanupConfigs: [
|
|
934
|
+
"runtime-cleanup.configs.recommended",
|
|
935
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
936
|
+
"runtime-cleanup.configs.strict",
|
|
937
|
+
"runtime-cleanup.configs.all"
|
|
938
|
+
],
|
|
939
|
+
url: createRuleDocsUrl("no-floating-broadcast-channels")
|
|
940
|
+
},
|
|
941
|
+
messages: {
|
|
942
|
+
floatingBroadcastChannel: "Store or return the BroadcastChannel handle so close() can release the channel during cleanup."
|
|
943
|
+
},
|
|
944
|
+
schema: [],
|
|
945
|
+
type: "problem"
|
|
946
|
+
},
|
|
947
|
+
name: "no-floating-broadcast-channels"
|
|
948
|
+
});
|
|
949
|
+
var no_floating_broadcast_channels_default = noFloatingBroadcastChannels;
|
|
950
|
+
|
|
951
|
+
// dist/rules/no-floating-child-processes.js
|
|
952
|
+
var import_utils7 = require("@typescript-eslint/utils");
|
|
953
|
+
var childProcessFactoryNames = [
|
|
954
|
+
"exec",
|
|
955
|
+
"execFile",
|
|
956
|
+
"fork",
|
|
957
|
+
"spawn"
|
|
958
|
+
];
|
|
959
|
+
var childProcessModuleNames = [
|
|
960
|
+
"child_process",
|
|
961
|
+
"node:child_process"
|
|
962
|
+
];
|
|
963
|
+
var immediateCleanupMethodNames = [
|
|
964
|
+
"disconnect",
|
|
965
|
+
"kill"
|
|
966
|
+
];
|
|
967
|
+
var childProcessFactoryNameSet = new Set(childProcessFactoryNames);
|
|
968
|
+
var childProcessModuleNameSet = new Set(childProcessModuleNames);
|
|
969
|
+
var immediateCleanupMethodNameSet = new Set(immediateCleanupMethodNames);
|
|
970
|
+
var isChildProcessFactoryName = (name) => childProcessFactoryNameSet.has(name);
|
|
971
|
+
var isImmediateCleanupMethodName = (name) => immediateCleanupMethodNameSet.has(name);
|
|
972
|
+
var getTransparentWrappedExpression4 = (node) => {
|
|
973
|
+
if (node.type === import_utils7.AST_NODE_TYPES.ChainExpression) {
|
|
974
|
+
return node.expression;
|
|
975
|
+
}
|
|
976
|
+
if (node.type === import_utils7.AST_NODE_TYPES.TSAsExpression) {
|
|
977
|
+
return node.expression;
|
|
978
|
+
}
|
|
979
|
+
if (node.type === import_utils7.AST_NODE_TYPES.TSNonNullExpression) {
|
|
980
|
+
return node.expression;
|
|
981
|
+
}
|
|
982
|
+
if (node.type === import_utils7.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
983
|
+
return node.expression;
|
|
984
|
+
}
|
|
985
|
+
if (node.type === import_utils7.AST_NODE_TYPES.TSTypeAssertion) {
|
|
986
|
+
return node.expression;
|
|
987
|
+
}
|
|
988
|
+
return void 0;
|
|
989
|
+
};
|
|
990
|
+
var getStaticPropertyName4 = (node) => {
|
|
991
|
+
if (node.type === import_utils7.AST_NODE_TYPES.Identifier) {
|
|
992
|
+
return node.name;
|
|
993
|
+
}
|
|
994
|
+
if (node.type === import_utils7.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
995
|
+
return node.value;
|
|
996
|
+
}
|
|
997
|
+
return void 0;
|
|
998
|
+
};
|
|
999
|
+
var getImportSourceValue = (node) => {
|
|
1000
|
+
const parent = getParentNode(node);
|
|
1001
|
+
if (parent?.type === import_utils7.AST_NODE_TYPES.ImportDeclaration && typeof parent.source.value === "string") {
|
|
1002
|
+
return parent.source.value;
|
|
1003
|
+
}
|
|
1004
|
+
return void 0;
|
|
1005
|
+
};
|
|
1006
|
+
var getRequireSourceValue = (expression) => {
|
|
1007
|
+
if (expression?.type !== import_utils7.AST_NODE_TYPES.CallExpression || expression.callee.type !== import_utils7.AST_NODE_TYPES.Identifier || expression.callee.name !== "require") {
|
|
1008
|
+
return void 0;
|
|
1009
|
+
}
|
|
1010
|
+
const [source] = expression.arguments;
|
|
1011
|
+
return source?.type === import_utils7.AST_NODE_TYPES.Literal && typeof source.value === "string" ? source.value : void 0;
|
|
1012
|
+
};
|
|
1013
|
+
var getDefinitionModuleSource = (node) => {
|
|
1014
|
+
if (node.type === import_utils7.AST_NODE_TYPES.ImportDefaultSpecifier || node.type === import_utils7.AST_NODE_TYPES.ImportNamespaceSpecifier || node.type === import_utils7.AST_NODE_TYPES.ImportSpecifier) {
|
|
1015
|
+
return getImportSourceValue(node);
|
|
1016
|
+
}
|
|
1017
|
+
if (node.type === import_utils7.AST_NODE_TYPES.VariableDeclarator) {
|
|
1018
|
+
return getRequireSourceValue(node.init);
|
|
1019
|
+
}
|
|
1020
|
+
return void 0;
|
|
1021
|
+
};
|
|
1022
|
+
var getImportedSpecifierName = (node) => getStaticPropertyName4(node.imported);
|
|
1023
|
+
var getObjectPatternPropertyNameForIdentifier = (objectPattern, identifierName) => {
|
|
1024
|
+
for (const property of objectPattern.properties) {
|
|
1025
|
+
if (property.type !== import_utils7.AST_NODE_TYPES.Property || property.value.type !== import_utils7.AST_NODE_TYPES.Identifier || property.value.name !== identifierName) {
|
|
1026
|
+
continue;
|
|
1027
|
+
}
|
|
1028
|
+
return getStaticPropertyName4(property.key);
|
|
1029
|
+
}
|
|
1030
|
+
return void 0;
|
|
1031
|
+
};
|
|
1032
|
+
var isChildProcessModuleSource = (source) => source !== void 0 && childProcessModuleNameSet.has(source);
|
|
1033
|
+
var getDefinitionForIdentifier = (context, identifier) => {
|
|
1034
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1035
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1036
|
+
return variable?.defs[0];
|
|
1037
|
+
};
|
|
1038
|
+
var isChildProcessModuleBinding = (context, identifier) => {
|
|
1039
|
+
const definition = getDefinitionForIdentifier(context, identifier);
|
|
1040
|
+
if (definition === void 0) {
|
|
1041
|
+
return false;
|
|
1042
|
+
}
|
|
1043
|
+
return isChildProcessModuleSource(getDefinitionModuleSource(definition.node));
|
|
1044
|
+
};
|
|
1045
|
+
var getNamedChildProcessFactoryBindingName = (context, identifier) => {
|
|
1046
|
+
const definition = getDefinitionForIdentifier(context, identifier);
|
|
1047
|
+
if (definition === void 0) {
|
|
1048
|
+
return void 0;
|
|
1049
|
+
}
|
|
1050
|
+
const source = getDefinitionModuleSource(definition.node);
|
|
1051
|
+
if (!isChildProcessModuleSource(source)) {
|
|
1052
|
+
return void 0;
|
|
1053
|
+
}
|
|
1054
|
+
if (definition.node.type === import_utils7.AST_NODE_TYPES.ImportSpecifier) {
|
|
1055
|
+
const importedName = getImportedSpecifierName(definition.node);
|
|
1056
|
+
return importedName !== void 0 && isChildProcessFactoryName(importedName) ? importedName : void 0;
|
|
1057
|
+
}
|
|
1058
|
+
if (definition.node.type === import_utils7.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils7.AST_NODE_TYPES.ObjectPattern) {
|
|
1059
|
+
const propertyName = getObjectPatternPropertyNameForIdentifier(definition.node.id, identifier.name);
|
|
1060
|
+
return propertyName !== void 0 && isChildProcessFactoryName(propertyName) ? propertyName : void 0;
|
|
1061
|
+
}
|
|
1062
|
+
return void 0;
|
|
1063
|
+
};
|
|
1064
|
+
var getRequireMemberFactoryName = (callee) => {
|
|
1065
|
+
if (callee.type !== import_utils7.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils7.AST_NODE_TYPES.Identifier || !isChildProcessFactoryName(callee.property.name) || callee.object.type !== import_utils7.AST_NODE_TYPES.CallExpression || !isChildProcessModuleSource(getRequireSourceValue(callee.object))) {
|
|
1066
|
+
return void 0;
|
|
1067
|
+
}
|
|
1068
|
+
return callee.property.name;
|
|
1069
|
+
};
|
|
1070
|
+
var getModuleMemberFactoryName = (context, callee) => {
|
|
1071
|
+
if (callee.type !== import_utils7.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils7.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils7.AST_NODE_TYPES.Identifier || !isChildProcessFactoryName(callee.property.name) || !isChildProcessModuleBinding(context, callee.object)) {
|
|
1072
|
+
return void 0;
|
|
1073
|
+
}
|
|
1074
|
+
return callee.property.name;
|
|
1075
|
+
};
|
|
1076
|
+
var getChildProcessFactoryName = (context, callee) => {
|
|
1077
|
+
if (callee.type === import_utils7.AST_NODE_TYPES.Identifier) {
|
|
1078
|
+
return getNamedChildProcessFactoryBindingName(context, callee);
|
|
1079
|
+
}
|
|
1080
|
+
return getModuleMemberFactoryName(context, callee) ?? getRequireMemberFactoryName(callee);
|
|
1081
|
+
};
|
|
1082
|
+
var isDiscardedChildProcessHandle = (node) => {
|
|
1083
|
+
let current = node;
|
|
1084
|
+
let parent = getParentNode(current);
|
|
1085
|
+
while (parent !== void 0) {
|
|
1086
|
+
const wrappedExpression = getTransparentWrappedExpression4(parent);
|
|
1087
|
+
if (wrappedExpression === current) {
|
|
1088
|
+
current = parent;
|
|
1089
|
+
parent = getParentNode(current);
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1093
|
+
return true;
|
|
1094
|
+
}
|
|
1095
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1096
|
+
const unaryParent = getParentNode(parent);
|
|
1097
|
+
return unaryParent?.type === import_utils7.AST_NODE_TYPES.ExpressionStatement;
|
|
1098
|
+
}
|
|
1099
|
+
return false;
|
|
1100
|
+
}
|
|
1101
|
+
return false;
|
|
1102
|
+
};
|
|
1103
|
+
var isImmediateChildProcessMethodReceiver = (node) => {
|
|
1104
|
+
let current = node;
|
|
1105
|
+
let parent = getParentNode(current);
|
|
1106
|
+
while (parent !== void 0) {
|
|
1107
|
+
const wrappedExpression = getTransparentWrappedExpression4(parent);
|
|
1108
|
+
if (wrappedExpression === current) {
|
|
1109
|
+
current = parent;
|
|
1110
|
+
parent = getParentNode(current);
|
|
1111
|
+
continue;
|
|
1112
|
+
}
|
|
1113
|
+
if (parent.type !== import_utils7.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.computed || parent.property.type !== import_utils7.AST_NODE_TYPES.Identifier || isImmediateCleanupMethodName(parent.property.name)) {
|
|
1114
|
+
return false;
|
|
1115
|
+
}
|
|
1116
|
+
const callExpression = getParentNode(parent);
|
|
1117
|
+
return callExpression?.type === import_utils7.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
1118
|
+
}
|
|
1119
|
+
return false;
|
|
1120
|
+
};
|
|
1121
|
+
var noFloatingChildProcesses = createTypedRule({
|
|
1122
|
+
create(context) {
|
|
1123
|
+
return {
|
|
1124
|
+
CallExpression(node) {
|
|
1125
|
+
const factoryName = getChildProcessFactoryName(context, node.callee);
|
|
1126
|
+
if (factoryName === void 0 || !isDiscardedChildProcessHandle(node) && !isImmediateChildProcessMethodReceiver(node)) {
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
context.report({
|
|
1130
|
+
data: { factoryName },
|
|
1131
|
+
messageId: "floatingChildProcess",
|
|
1132
|
+
node
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
},
|
|
1137
|
+
defaultOptions: [],
|
|
1138
|
+
meta: {
|
|
1139
|
+
docs: {
|
|
1140
|
+
description: "require child process handles to be retained so they can be killed during cleanup.",
|
|
1141
|
+
recommended: true,
|
|
1142
|
+
requiresTypeChecking: false,
|
|
1143
|
+
runtimeCleanupConfigs: [
|
|
1144
|
+
"runtime-cleanup.configs.recommended",
|
|
1145
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
1146
|
+
"runtime-cleanup.configs.strict",
|
|
1147
|
+
"runtime-cleanup.configs.all"
|
|
1148
|
+
],
|
|
1149
|
+
url: createRuleDocsUrl("no-floating-child-processes")
|
|
1150
|
+
},
|
|
1151
|
+
messages: {
|
|
1152
|
+
floatingChildProcess: "Store or return the child process handle from {{factoryName}} so it can be killed during cleanup."
|
|
1153
|
+
},
|
|
1154
|
+
schema: [],
|
|
1155
|
+
type: "problem"
|
|
1156
|
+
},
|
|
1157
|
+
name: "no-floating-child-processes"
|
|
1158
|
+
});
|
|
1159
|
+
var no_floating_child_processes_default = noFloatingChildProcesses;
|
|
1160
|
+
|
|
1161
|
+
// dist/rules/no-floating-disposable-stacks.js
|
|
1162
|
+
var import_utils8 = require("@typescript-eslint/utils");
|
|
1163
|
+
var disposableStackConstructorNames = [
|
|
1164
|
+
"AsyncDisposableStack",
|
|
1165
|
+
"DisposableStack"
|
|
1166
|
+
];
|
|
1167
|
+
var cleanupMethodNames = [
|
|
1168
|
+
"dispose",
|
|
1169
|
+
"disposeAsync"
|
|
1170
|
+
];
|
|
1171
|
+
var globalReceiverNames4 = [
|
|
1172
|
+
"globalThis",
|
|
1173
|
+
"self",
|
|
1174
|
+
"window"
|
|
1175
|
+
];
|
|
1176
|
+
var disposableStackConstructorNameSet = new Set(disposableStackConstructorNames);
|
|
1177
|
+
var cleanupMethodNameSet = new Set(cleanupMethodNames);
|
|
1178
|
+
var globalReceiverNameSet4 = new Set(globalReceiverNames4);
|
|
1179
|
+
var isDisposableStackConstructorName = (name) => disposableStackConstructorNameSet.has(name);
|
|
1180
|
+
var isCleanupMethodName = (name) => cleanupMethodNameSet.has(name);
|
|
1181
|
+
var isGlobalReceiverName3 = (name) => globalReceiverNameSet4.has(name);
|
|
1182
|
+
var getTransparentWrappedExpression5 = (node) => {
|
|
1183
|
+
if (node.type === import_utils8.AST_NODE_TYPES.ChainExpression) {
|
|
1184
|
+
return node.expression;
|
|
1185
|
+
}
|
|
1186
|
+
if (node.type === import_utils8.AST_NODE_TYPES.TSAsExpression) {
|
|
1187
|
+
return node.expression;
|
|
1188
|
+
}
|
|
1189
|
+
if (node.type === import_utils8.AST_NODE_TYPES.TSNonNullExpression) {
|
|
1190
|
+
return node.expression;
|
|
1191
|
+
}
|
|
1192
|
+
if (node.type === import_utils8.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1193
|
+
return node.expression;
|
|
1194
|
+
}
|
|
1195
|
+
if (node.type === import_utils8.AST_NODE_TYPES.TSTypeAssertion) {
|
|
1196
|
+
return node.expression;
|
|
1197
|
+
}
|
|
1198
|
+
return void 0;
|
|
1199
|
+
};
|
|
1200
|
+
var getStaticPropertyName5 = (node, computed) => {
|
|
1201
|
+
if (!computed && node.type === import_utils8.AST_NODE_TYPES.Identifier) {
|
|
1202
|
+
return node.name;
|
|
1203
|
+
}
|
|
1204
|
+
if (computed && node.type === import_utils8.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
1205
|
+
return node.value;
|
|
1206
|
+
}
|
|
1207
|
+
return void 0;
|
|
1208
|
+
};
|
|
1209
|
+
var isShadowedDisposableStackIdentifier = (context, identifier) => {
|
|
1210
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1211
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1212
|
+
return variable !== null && variable.defs.length > 0;
|
|
1213
|
+
};
|
|
1214
|
+
var getDirectDisposableStackConstructorName = (context, callee) => {
|
|
1215
|
+
if (callee.type !== import_utils8.AST_NODE_TYPES.Identifier || !isDisposableStackConstructorName(callee.name) || isShadowedDisposableStackIdentifier(context, callee)) {
|
|
1216
|
+
return void 0;
|
|
1217
|
+
}
|
|
1218
|
+
return callee.name;
|
|
1219
|
+
};
|
|
1220
|
+
var getMemberDisposableStackConstructorName = (callee) => {
|
|
1221
|
+
if (callee.type !== import_utils8.AST_NODE_TYPES.MemberExpression || callee.optional || callee.object.type !== import_utils8.AST_NODE_TYPES.Identifier || !isGlobalReceiverName3(callee.object.name)) {
|
|
1222
|
+
return void 0;
|
|
1223
|
+
}
|
|
1224
|
+
const constructorName = getStaticPropertyName5(callee.property, callee.computed);
|
|
1225
|
+
return constructorName !== void 0 && isDisposableStackConstructorName(constructorName) ? constructorName : void 0;
|
|
1226
|
+
};
|
|
1227
|
+
var getDisposableStackConstructorName = (context, callee) => getDirectDisposableStackConstructorName(context, callee) ?? getMemberDisposableStackConstructorName(callee);
|
|
1228
|
+
var isDiscardedDisposableStack = (node) => {
|
|
1229
|
+
let current = node;
|
|
1230
|
+
let parent = getParentNode(current);
|
|
1231
|
+
while (parent !== void 0) {
|
|
1232
|
+
const wrappedExpression = getTransparentWrappedExpression5(parent);
|
|
1233
|
+
if (wrappedExpression === current) {
|
|
1234
|
+
current = parent;
|
|
1235
|
+
parent = getParentNode(current);
|
|
1236
|
+
continue;
|
|
1237
|
+
}
|
|
1238
|
+
if (parent.type === import_utils8.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1239
|
+
return true;
|
|
1240
|
+
}
|
|
1241
|
+
if (parent.type === import_utils8.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1242
|
+
const unaryParent = getParentNode(parent);
|
|
1243
|
+
return unaryParent?.type === import_utils8.AST_NODE_TYPES.ExpressionStatement;
|
|
1244
|
+
}
|
|
1245
|
+
return false;
|
|
1246
|
+
}
|
|
1247
|
+
return false;
|
|
1248
|
+
};
|
|
1249
|
+
var isImmediateDisposableStackMethodReceiver = (node) => {
|
|
1250
|
+
let current = node;
|
|
1251
|
+
let parent = getParentNode(current);
|
|
1252
|
+
while (parent !== void 0) {
|
|
1253
|
+
const wrappedExpression = getTransparentWrappedExpression5(parent);
|
|
1254
|
+
if (wrappedExpression === current) {
|
|
1255
|
+
current = parent;
|
|
1256
|
+
parent = getParentNode(current);
|
|
1257
|
+
continue;
|
|
1258
|
+
}
|
|
1259
|
+
if (parent.type !== import_utils8.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
const methodName = getStaticPropertyName5(parent.property, parent.computed);
|
|
1263
|
+
if (methodName === void 0 || isCleanupMethodName(methodName)) {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
const callExpression = getParentNode(parent);
|
|
1267
|
+
return callExpression?.type === import_utils8.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
1268
|
+
}
|
|
1269
|
+
return false;
|
|
1270
|
+
};
|
|
1271
|
+
var noFloatingDisposableStacks = createTypedRule({
|
|
1272
|
+
create(context) {
|
|
1273
|
+
return {
|
|
1274
|
+
NewExpression(node) {
|
|
1275
|
+
const constructorName = getDisposableStackConstructorName(context, node.callee);
|
|
1276
|
+
if (constructorName === void 0 || !isDiscardedDisposableStack(node) && !isImmediateDisposableStackMethodReceiver(node)) {
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
context.report({
|
|
1280
|
+
data: { constructorName },
|
|
1281
|
+
messageId: "floatingDisposableStack",
|
|
1282
|
+
node
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
},
|
|
1287
|
+
defaultOptions: [],
|
|
1288
|
+
meta: {
|
|
1289
|
+
docs: {
|
|
1290
|
+
description: "require DisposableStack handles to be retained so registered disposers run.",
|
|
1291
|
+
recommended: true,
|
|
1292
|
+
requiresTypeChecking: false,
|
|
1293
|
+
runtimeCleanupConfigs: [
|
|
1294
|
+
"runtime-cleanup.configs.recommended",
|
|
1295
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
1296
|
+
"runtime-cleanup.configs.strict",
|
|
1297
|
+
"runtime-cleanup.configs.all"
|
|
1298
|
+
],
|
|
1299
|
+
url: createRuleDocsUrl("no-floating-disposable-stacks")
|
|
1300
|
+
},
|
|
1301
|
+
messages: {
|
|
1302
|
+
floatingDisposableStack: "Store, return, or use the {{constructorName}} handle so registered disposers run during cleanup."
|
|
1303
|
+
},
|
|
1304
|
+
schema: [],
|
|
1305
|
+
type: "problem"
|
|
1306
|
+
},
|
|
1307
|
+
name: "no-floating-disposable-stacks"
|
|
1308
|
+
});
|
|
1309
|
+
var no_floating_disposable_stacks_default = noFloatingDisposableStacks;
|
|
1310
|
+
|
|
1311
|
+
// dist/rules/no-floating-file-watchers.js
|
|
1312
|
+
var import_utils9 = require("@typescript-eslint/utils");
|
|
1313
|
+
var fileWatcherFactoryName = "watch";
|
|
1314
|
+
var fsModuleNames = ["fs", "node:fs"];
|
|
1315
|
+
var immediateCleanupMethodNames2 = ["close"];
|
|
1316
|
+
var fsModuleNameSet = new Set(fsModuleNames);
|
|
1317
|
+
var immediateCleanupMethodNameSet2 = new Set(immediateCleanupMethodNames2);
|
|
1318
|
+
var isImmediateCleanupMethodName2 = (name) => immediateCleanupMethodNameSet2.has(name);
|
|
1319
|
+
var getTransparentWrappedExpression6 = (node) => {
|
|
1320
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ChainExpression) {
|
|
1321
|
+
return node.expression;
|
|
1322
|
+
}
|
|
1323
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSAsExpression) {
|
|
1324
|
+
return node.expression;
|
|
1325
|
+
}
|
|
1326
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSNonNullExpression) {
|
|
1327
|
+
return node.expression;
|
|
1328
|
+
}
|
|
1329
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1330
|
+
return node.expression;
|
|
1331
|
+
}
|
|
1332
|
+
if (node.type === import_utils9.AST_NODE_TYPES.TSTypeAssertion) {
|
|
1333
|
+
return node.expression;
|
|
1334
|
+
}
|
|
1335
|
+
return void 0;
|
|
1336
|
+
};
|
|
1337
|
+
var getStaticPropertyName6 = (node) => {
|
|
1338
|
+
if (node.type === import_utils9.AST_NODE_TYPES.Identifier) {
|
|
1339
|
+
return node.name;
|
|
1340
|
+
}
|
|
1341
|
+
if (node.type === import_utils9.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
1342
|
+
return node.value;
|
|
1343
|
+
}
|
|
1344
|
+
return void 0;
|
|
1345
|
+
};
|
|
1346
|
+
var getImportSourceValue2 = (node) => {
|
|
1347
|
+
const parent = getParentNode(node);
|
|
1348
|
+
if (parent?.type === import_utils9.AST_NODE_TYPES.ImportDeclaration && typeof parent.source.value === "string") {
|
|
1349
|
+
return parent.source.value;
|
|
1350
|
+
}
|
|
1351
|
+
return void 0;
|
|
1352
|
+
};
|
|
1353
|
+
var getRequireSourceValue2 = (expression) => {
|
|
1354
|
+
if (expression?.type !== import_utils9.AST_NODE_TYPES.CallExpression || expression.callee.type !== import_utils9.AST_NODE_TYPES.Identifier || expression.callee.name !== "require") {
|
|
1355
|
+
return void 0;
|
|
1356
|
+
}
|
|
1357
|
+
const [source] = expression.arguments;
|
|
1358
|
+
return source?.type === import_utils9.AST_NODE_TYPES.Literal && typeof source.value === "string" ? source.value : void 0;
|
|
1359
|
+
};
|
|
1360
|
+
var getDefinitionModuleSource2 = (node) => {
|
|
1361
|
+
if (node.type === import_utils9.AST_NODE_TYPES.ImportDefaultSpecifier || node.type === import_utils9.AST_NODE_TYPES.ImportNamespaceSpecifier || node.type === import_utils9.AST_NODE_TYPES.ImportSpecifier) {
|
|
1362
|
+
return getImportSourceValue2(node);
|
|
1363
|
+
}
|
|
1364
|
+
if (node.type === import_utils9.AST_NODE_TYPES.VariableDeclarator) {
|
|
1365
|
+
return getRequireSourceValue2(node.init);
|
|
1366
|
+
}
|
|
1367
|
+
return void 0;
|
|
1368
|
+
};
|
|
1369
|
+
var isFsModuleSource = (source) => source !== void 0 && fsModuleNameSet.has(source);
|
|
1370
|
+
var getDefinitionForIdentifier2 = (context, identifier) => {
|
|
1371
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1372
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1373
|
+
return variable?.defs[0];
|
|
1374
|
+
};
|
|
1375
|
+
var isFsModuleBinding = (context, identifier) => {
|
|
1376
|
+
const definition = getDefinitionForIdentifier2(context, identifier);
|
|
1377
|
+
return definition !== void 0 && isFsModuleSource(getDefinitionModuleSource2(definition.node));
|
|
1378
|
+
};
|
|
1379
|
+
var getImportedSpecifierName2 = (node) => getStaticPropertyName6(node.imported);
|
|
1380
|
+
var getObjectPatternPropertyNameForIdentifier2 = (objectPattern, identifierName) => {
|
|
1381
|
+
for (const property of objectPattern.properties) {
|
|
1382
|
+
if (property.type !== import_utils9.AST_NODE_TYPES.Property || property.value.type !== import_utils9.AST_NODE_TYPES.Identifier || property.value.name !== identifierName) {
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
return getStaticPropertyName6(property.key);
|
|
1386
|
+
}
|
|
1387
|
+
return void 0;
|
|
1388
|
+
};
|
|
1389
|
+
var getNamedFileWatcherBindingName = (context, identifier) => {
|
|
1390
|
+
const definition = getDefinitionForIdentifier2(context, identifier);
|
|
1391
|
+
if (definition === void 0) {
|
|
1392
|
+
return void 0;
|
|
1393
|
+
}
|
|
1394
|
+
const source = getDefinitionModuleSource2(definition.node);
|
|
1395
|
+
if (!isFsModuleSource(source)) {
|
|
1396
|
+
return void 0;
|
|
1397
|
+
}
|
|
1398
|
+
if (definition.node.type === import_utils9.AST_NODE_TYPES.ImportSpecifier) {
|
|
1399
|
+
return getImportedSpecifierName2(definition.node) === fileWatcherFactoryName ? fileWatcherFactoryName : void 0;
|
|
1400
|
+
}
|
|
1401
|
+
if (definition.node.type === import_utils9.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils9.AST_NODE_TYPES.ObjectPattern) {
|
|
1402
|
+
return getObjectPatternPropertyNameForIdentifier2(definition.node.id, identifier.name) === fileWatcherFactoryName ? fileWatcherFactoryName : void 0;
|
|
1403
|
+
}
|
|
1404
|
+
return void 0;
|
|
1405
|
+
};
|
|
1406
|
+
var getRequireMemberFactoryName2 = (callee) => {
|
|
1407
|
+
if (callee.type !== import_utils9.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils9.AST_NODE_TYPES.Identifier || callee.property.name !== fileWatcherFactoryName || callee.object.type !== import_utils9.AST_NODE_TYPES.CallExpression || !isFsModuleSource(getRequireSourceValue2(callee.object))) {
|
|
1408
|
+
return void 0;
|
|
1409
|
+
}
|
|
1410
|
+
return callee.property.name;
|
|
1411
|
+
};
|
|
1412
|
+
var getModuleMemberFactoryName2 = (context, callee) => {
|
|
1413
|
+
if (callee.type !== import_utils9.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils9.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils9.AST_NODE_TYPES.Identifier || callee.property.name !== fileWatcherFactoryName || !isFsModuleBinding(context, callee.object)) {
|
|
1414
|
+
return void 0;
|
|
1415
|
+
}
|
|
1416
|
+
return callee.property.name;
|
|
1417
|
+
};
|
|
1418
|
+
var getFileWatcherFactoryName = (context, callee) => {
|
|
1419
|
+
if (callee.type === import_utils9.AST_NODE_TYPES.Identifier) {
|
|
1420
|
+
return getNamedFileWatcherBindingName(context, callee);
|
|
1421
|
+
}
|
|
1422
|
+
return getModuleMemberFactoryName2(context, callee) ?? getRequireMemberFactoryName2(callee);
|
|
1423
|
+
};
|
|
1424
|
+
var isDiscardedFileWatcherHandle = (node) => {
|
|
1425
|
+
let current = node;
|
|
1426
|
+
let parent = getParentNode(current);
|
|
1427
|
+
while (parent !== void 0) {
|
|
1428
|
+
const wrappedExpression = getTransparentWrappedExpression6(parent);
|
|
1429
|
+
if (wrappedExpression === current) {
|
|
1430
|
+
current = parent;
|
|
1431
|
+
parent = getParentNode(current);
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1434
|
+
if (parent.type === import_utils9.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1435
|
+
return true;
|
|
1436
|
+
}
|
|
1437
|
+
if (parent.type === import_utils9.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1438
|
+
const unaryParent = getParentNode(parent);
|
|
1439
|
+
return unaryParent?.type === import_utils9.AST_NODE_TYPES.ExpressionStatement;
|
|
1440
|
+
}
|
|
1441
|
+
return false;
|
|
1442
|
+
}
|
|
1443
|
+
return false;
|
|
1444
|
+
};
|
|
1445
|
+
var isImmediateFileWatcherMethodReceiver = (node) => {
|
|
1446
|
+
let current = node;
|
|
1447
|
+
let parent = getParentNode(current);
|
|
1448
|
+
while (parent !== void 0) {
|
|
1449
|
+
const wrappedExpression = getTransparentWrappedExpression6(parent);
|
|
1450
|
+
if (wrappedExpression === current) {
|
|
1451
|
+
current = parent;
|
|
1452
|
+
parent = getParentNode(current);
|
|
1453
|
+
continue;
|
|
1454
|
+
}
|
|
1455
|
+
if (parent.type !== import_utils9.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.computed || parent.property.type !== import_utils9.AST_NODE_TYPES.Identifier || isImmediateCleanupMethodName2(parent.property.name)) {
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
const callExpression = getParentNode(parent);
|
|
1459
|
+
return callExpression?.type === import_utils9.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
1460
|
+
}
|
|
1461
|
+
return false;
|
|
1462
|
+
};
|
|
1463
|
+
var noFloatingFileWatchers = createTypedRule({
|
|
1464
|
+
create(context) {
|
|
1465
|
+
return {
|
|
1466
|
+
CallExpression(node) {
|
|
1467
|
+
const factoryName = getFileWatcherFactoryName(context, node.callee);
|
|
1468
|
+
if (factoryName === void 0 || !isDiscardedFileWatcherHandle(node) && !isImmediateFileWatcherMethodReceiver(node)) {
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
context.report({
|
|
1472
|
+
data: { factoryName },
|
|
1473
|
+
messageId: "floatingFileWatcher",
|
|
1474
|
+
node
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
},
|
|
1479
|
+
defaultOptions: [],
|
|
1480
|
+
meta: {
|
|
1481
|
+
docs: {
|
|
1482
|
+
description: "require Node.js file watcher handles to be retained so they can be closed.",
|
|
1483
|
+
recommended: true,
|
|
1484
|
+
requiresTypeChecking: false,
|
|
1485
|
+
runtimeCleanupConfigs: [
|
|
1486
|
+
"runtime-cleanup.configs.recommended",
|
|
1487
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
1488
|
+
"runtime-cleanup.configs.strict",
|
|
1489
|
+
"runtime-cleanup.configs.all"
|
|
1490
|
+
],
|
|
1491
|
+
url: createRuleDocsUrl("no-floating-file-watchers")
|
|
1492
|
+
},
|
|
1493
|
+
messages: {
|
|
1494
|
+
floatingFileWatcher: "Store or return the file watcher from {{factoryName}} so close() can stop watching during cleanup."
|
|
1495
|
+
},
|
|
1496
|
+
schema: [],
|
|
1497
|
+
type: "problem"
|
|
1498
|
+
},
|
|
1499
|
+
name: "no-floating-file-watchers"
|
|
1500
|
+
});
|
|
1501
|
+
var no_floating_file_watchers_default = noFloatingFileWatchers;
|
|
1502
|
+
|
|
1503
|
+
// dist/rules/no-floating-geolocation-watches.js
|
|
1504
|
+
var import_utils10 = require("@typescript-eslint/utils");
|
|
1505
|
+
var geolocationWatchFunctionName = "watchPosition";
|
|
1506
|
+
var globalNavigatorReceiverNames = ["globalThis", "window"];
|
|
1507
|
+
var globalNavigatorReceiverNameSet = new Set(globalNavigatorReceiverNames);
|
|
1508
|
+
var getTransparentWrappedExpression7 = (node) => {
|
|
1509
|
+
if (node.type === import_utils10.AST_NODE_TYPES.ChainExpression) {
|
|
1510
|
+
return node.expression;
|
|
1511
|
+
}
|
|
1512
|
+
if (node.type === import_utils10.AST_NODE_TYPES.TSAsExpression) {
|
|
1513
|
+
return node.expression;
|
|
1514
|
+
}
|
|
1515
|
+
if (node.type === import_utils10.AST_NODE_TYPES.TSNonNullExpression) {
|
|
1516
|
+
return node.expression;
|
|
1517
|
+
}
|
|
1518
|
+
if (node.type === import_utils10.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1519
|
+
return node.expression;
|
|
1520
|
+
}
|
|
1521
|
+
if (node.type === import_utils10.AST_NODE_TYPES.TSTypeAssertion) {
|
|
1522
|
+
return node.expression;
|
|
1523
|
+
}
|
|
1524
|
+
return void 0;
|
|
1525
|
+
};
|
|
1526
|
+
var getStaticPropertyName7 = (node, computed) => {
|
|
1527
|
+
if (!computed && node.type === import_utils10.AST_NODE_TYPES.Identifier) {
|
|
1528
|
+
return node.name;
|
|
1529
|
+
}
|
|
1530
|
+
if (computed && node.type === import_utils10.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
1531
|
+
return node.value;
|
|
1532
|
+
}
|
|
1533
|
+
return void 0;
|
|
1534
|
+
};
|
|
1535
|
+
var collectStaticMemberPath2 = (node) => {
|
|
1536
|
+
if (node.type === import_utils10.AST_NODE_TYPES.Identifier) {
|
|
1537
|
+
return [node.name];
|
|
1538
|
+
}
|
|
1539
|
+
if (node.type !== import_utils10.AST_NODE_TYPES.MemberExpression || node.optional) {
|
|
1540
|
+
return void 0;
|
|
1541
|
+
}
|
|
1542
|
+
const objectPath = collectStaticMemberPath2(node.object);
|
|
1543
|
+
const propertyName = getStaticPropertyName7(node.property, node.computed);
|
|
1544
|
+
return objectPath === void 0 || propertyName === void 0 ? void 0 : [...objectPath, propertyName];
|
|
1545
|
+
};
|
|
1546
|
+
var isShadowedNavigatorIdentifier = (context, identifier) => {
|
|
1547
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1548
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1549
|
+
return variable !== null && variable.defs.length > 0;
|
|
1550
|
+
};
|
|
1551
|
+
var getRootIdentifier = (node) => {
|
|
1552
|
+
if (node.type === import_utils10.AST_NODE_TYPES.Identifier) {
|
|
1553
|
+
return node;
|
|
1554
|
+
}
|
|
1555
|
+
return node.type === import_utils10.AST_NODE_TYPES.MemberExpression ? getRootIdentifier(node.object) : void 0;
|
|
1556
|
+
};
|
|
1557
|
+
var isNavigatorPathShadowed = (context, callee) => {
|
|
1558
|
+
if (callee.type !== import_utils10.AST_NODE_TYPES.MemberExpression) {
|
|
1559
|
+
return false;
|
|
1560
|
+
}
|
|
1561
|
+
const rootIdentifier = getRootIdentifier(callee.object);
|
|
1562
|
+
return rootIdentifier?.name === "navigator" && isShadowedNavigatorIdentifier(context, rootIdentifier);
|
|
1563
|
+
};
|
|
1564
|
+
var isGeolocationWatchPath = (path) => path.length === 3 && path[0] === "navigator" && path[1] === "geolocation" && path[2] === geolocationWatchFunctionName || path.length === 4 && globalNavigatorReceiverNameSet.has(path[0] ?? "") && path[1] === "navigator" && path[2] === "geolocation" && path[3] === geolocationWatchFunctionName;
|
|
1565
|
+
var isGeolocationWatchCall = (context, callee) => {
|
|
1566
|
+
if (callee.type !== import_utils10.AST_NODE_TYPES.MemberExpression || isNavigatorPathShadowed(context, callee)) {
|
|
1567
|
+
return false;
|
|
1568
|
+
}
|
|
1569
|
+
const path = collectStaticMemberPath2(callee);
|
|
1570
|
+
return path !== void 0 && isGeolocationWatchPath(path);
|
|
1571
|
+
};
|
|
1572
|
+
var isDiscardedWatchId = (node) => {
|
|
1573
|
+
let current = node;
|
|
1574
|
+
let parent = getParentNode(current);
|
|
1575
|
+
while (parent !== void 0) {
|
|
1576
|
+
const wrappedExpression = getTransparentWrappedExpression7(parent);
|
|
1577
|
+
if (wrappedExpression === current) {
|
|
1578
|
+
current = parent;
|
|
1579
|
+
parent = getParentNode(current);
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
if (parent.type === import_utils10.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1583
|
+
return true;
|
|
1584
|
+
}
|
|
1585
|
+
if (parent.type === import_utils10.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1586
|
+
const unaryParent = getParentNode(parent);
|
|
1587
|
+
return unaryParent?.type === import_utils10.AST_NODE_TYPES.ExpressionStatement;
|
|
1588
|
+
}
|
|
1589
|
+
return false;
|
|
1590
|
+
}
|
|
1591
|
+
return false;
|
|
1592
|
+
};
|
|
1593
|
+
var noFloatingGeolocationWatches = createTypedRule({
|
|
1594
|
+
create(context) {
|
|
1595
|
+
return {
|
|
1596
|
+
CallExpression(node) {
|
|
1597
|
+
if (!isGeolocationWatchCall(context, node.callee) || !isDiscardedWatchId(node)) {
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
context.report({
|
|
1601
|
+
messageId: "floatingGeolocationWatch",
|
|
1602
|
+
node
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
},
|
|
1607
|
+
defaultOptions: [],
|
|
1608
|
+
meta: {
|
|
1609
|
+
docs: {
|
|
1610
|
+
description: "require geolocation watch IDs to be retained so they can be cleared.",
|
|
1611
|
+
recommended: true,
|
|
1612
|
+
requiresTypeChecking: false,
|
|
1613
|
+
runtimeCleanupConfigs: [
|
|
1614
|
+
"runtime-cleanup.configs.recommended",
|
|
1615
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
1616
|
+
"runtime-cleanup.configs.strict",
|
|
1617
|
+
"runtime-cleanup.configs.all"
|
|
1618
|
+
],
|
|
1619
|
+
url: createRuleDocsUrl("no-floating-geolocation-watches")
|
|
1620
|
+
},
|
|
1621
|
+
messages: {
|
|
1622
|
+
floatingGeolocationWatch: "Store or return the geolocation watch ID so navigator.geolocation.clearWatch() can remove the location watcher during cleanup."
|
|
1623
|
+
},
|
|
1624
|
+
schema: [],
|
|
1625
|
+
type: "problem"
|
|
1626
|
+
},
|
|
1627
|
+
name: "no-floating-geolocation-watches"
|
|
1628
|
+
});
|
|
1629
|
+
var no_floating_geolocation_watches_default = noFloatingGeolocationWatches;
|
|
1630
|
+
|
|
1631
|
+
// dist/rules/no-floating-infinite-animations.js
|
|
1632
|
+
var import_utils11 = require("@typescript-eslint/utils");
|
|
1633
|
+
|
|
1634
|
+
// dist/_internal/type-checker.js
|
|
1635
|
+
var hasTypeNameInHierarchy = (checker, type, expectedTypeName, seenTypes = /* @__PURE__ */ new Set()) => {
|
|
1636
|
+
if (seenTypes.has(type)) {
|
|
1637
|
+
return false;
|
|
1638
|
+
}
|
|
1639
|
+
const nextSeenTypes = new Set(seenTypes);
|
|
1640
|
+
nextSeenTypes.add(type);
|
|
1641
|
+
if (type.isUnionOrIntersection()) {
|
|
1642
|
+
return type.types.some((entry) => hasTypeNameInHierarchy(checker, entry, expectedTypeName, nextSeenTypes));
|
|
1643
|
+
}
|
|
1644
|
+
const apparentType = checker.getApparentType(type);
|
|
1645
|
+
const typeName = apparentType.symbol.getName();
|
|
1646
|
+
if (typeName === expectedTypeName) {
|
|
1647
|
+
return true;
|
|
1648
|
+
}
|
|
1649
|
+
if (!apparentType.isClassOrInterface()) {
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
const baseTypes = checker.getBaseTypes(apparentType);
|
|
1653
|
+
return baseTypes.some((baseType) => hasTypeNameInHierarchy(checker, baseType, expectedTypeName, nextSeenTypes));
|
|
1654
|
+
};
|
|
1655
|
+
|
|
1656
|
+
// dist/rules/no-floating-infinite-animations.js
|
|
1657
|
+
var animationCleanupMemberNames = /* @__PURE__ */ new Set([
|
|
1658
|
+
"cancel",
|
|
1659
|
+
"finish"
|
|
1660
|
+
]);
|
|
1661
|
+
var isShadowedIdentifier2 = (context, identifier) => {
|
|
1662
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1663
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1664
|
+
return variable !== null && variable.defs.length > 0;
|
|
1665
|
+
};
|
|
1666
|
+
var isGlobalInfinityIdentifier = (context, node) => node.name === "Infinity" && !isShadowedIdentifier2(context, node);
|
|
1667
|
+
var isNumberPositiveInfinity = (node) => {
|
|
1668
|
+
if (node.optional) {
|
|
1669
|
+
return false;
|
|
1670
|
+
}
|
|
1671
|
+
const propertyName = getStaticPropertyName2(node.property, node.computed);
|
|
1672
|
+
if (propertyName !== "POSITIVE_INFINITY") {
|
|
1673
|
+
return false;
|
|
1674
|
+
}
|
|
1675
|
+
if (node.object.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1676
|
+
return node.object.name === "Number";
|
|
1677
|
+
}
|
|
1678
|
+
if (node.object.type !== import_utils11.AST_NODE_TYPES.MemberExpression) {
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
const objectPropertyName = getStaticPropertyName2(node.object.property, node.object.computed);
|
|
1682
|
+
return objectPropertyName === "Number" && node.object.object.type === import_utils11.AST_NODE_TYPES.Identifier && (node.object.object.name === "globalThis" || node.object.object.name === "window");
|
|
1683
|
+
};
|
|
1684
|
+
var isInfinityExpression = (context, node) => {
|
|
1685
|
+
if (node.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1686
|
+
return isGlobalInfinityIdentifier(context, node);
|
|
1687
|
+
}
|
|
1688
|
+
if (node.type === import_utils11.AST_NODE_TYPES.UnaryExpression && node.operator === "+" && node.argument.type === import_utils11.AST_NODE_TYPES.Identifier) {
|
|
1689
|
+
return isGlobalInfinityIdentifier(context, node.argument);
|
|
1690
|
+
}
|
|
1691
|
+
return node.type === import_utils11.AST_NODE_TYPES.MemberExpression && isNumberPositiveInfinity(node);
|
|
1692
|
+
};
|
|
1693
|
+
var getPropertyKeyName = (property) => getStaticPropertyName2(property.key, property.computed);
|
|
1694
|
+
var isExpressionPropertyValue = (node) => node.type !== import_utils11.AST_NODE_TYPES.ArrayPattern && node.type !== import_utils11.AST_NODE_TYPES.AssignmentPattern && node.type !== import_utils11.AST_NODE_TYPES.ObjectPattern && node.type !== import_utils11.AST_NODE_TYPES.TSEmptyBodyFunctionExpression;
|
|
1695
|
+
var hasInfiniteIterationsOption = (context, options) => {
|
|
1696
|
+
if (options.type !== import_utils11.AST_NODE_TYPES.ObjectExpression) {
|
|
1697
|
+
return false;
|
|
1698
|
+
}
|
|
1699
|
+
return options.properties.some((property) => {
|
|
1700
|
+
if (property.type !== import_utils11.AST_NODE_TYPES.Property || property.kind !== "init" || !isExpressionPropertyValue(property.value) || getPropertyKeyName(property) !== "iterations") {
|
|
1701
|
+
return false;
|
|
1702
|
+
}
|
|
1703
|
+
return isInfinityExpression(context, property.value);
|
|
1704
|
+
});
|
|
1705
|
+
};
|
|
1706
|
+
var getAnimationReceiver = (callee) => {
|
|
1707
|
+
if (callee.type !== import_utils11.AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
1708
|
+
return void 0;
|
|
1709
|
+
}
|
|
1710
|
+
if (callee.object.type === import_utils11.AST_NODE_TYPES.Super) {
|
|
1711
|
+
return void 0;
|
|
1712
|
+
}
|
|
1713
|
+
const propertyName = getStaticPropertyName2(callee.property, callee.computed);
|
|
1714
|
+
return propertyName === "animate" ? callee.object : void 0;
|
|
1715
|
+
};
|
|
1716
|
+
var isReceiverElement = (context, receiver) => {
|
|
1717
|
+
const { checker, parserServices } = getTypedRuleServices(context);
|
|
1718
|
+
const receiverType = checker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(receiver));
|
|
1719
|
+
return hasTypeNameInHierarchy(checker, receiverType, "Element");
|
|
1720
|
+
};
|
|
1721
|
+
var noFloatingInfiniteAnimations = createTypedRule({
|
|
1722
|
+
create(context) {
|
|
1723
|
+
return {
|
|
1724
|
+
CallExpression(node) {
|
|
1725
|
+
const receiver = getAnimationReceiver(node.callee);
|
|
1726
|
+
const timingOptions = node.arguments.at(1);
|
|
1727
|
+
if (receiver === void 0 || timingOptions === void 0 || !hasInfiniteIterationsOption(context, timingOptions) || !isReceiverElement(context, receiver) || !isDiscardedResourceExpression(node) && !isImmediateUnownedMemberReceiver(node, animationCleanupMemberNames)) {
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
context.report({
|
|
1731
|
+
messageId: "floatingInfiniteAnimation",
|
|
1732
|
+
node
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
},
|
|
1737
|
+
defaultOptions: [],
|
|
1738
|
+
meta: {
|
|
1739
|
+
docs: {
|
|
1740
|
+
description: "require infinite Web Animations to be retained so they can be canceled.",
|
|
1741
|
+
recommended: true,
|
|
1742
|
+
requiresTypeChecking: true,
|
|
1743
|
+
runtimeCleanupConfigs: [
|
|
1744
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
1745
|
+
"runtime-cleanup.configs.strict",
|
|
1746
|
+
"runtime-cleanup.configs.all"
|
|
1747
|
+
],
|
|
1748
|
+
url: createRuleDocsUrl("no-floating-infinite-animations")
|
|
1749
|
+
},
|
|
1750
|
+
messages: {
|
|
1751
|
+
floatingInfiniteAnimation: "Store or return the infinite Animation so cancel() can stop it during cleanup."
|
|
1752
|
+
},
|
|
1753
|
+
schema: [],
|
|
1754
|
+
type: "problem"
|
|
1755
|
+
},
|
|
1756
|
+
name: "no-floating-infinite-animations"
|
|
1757
|
+
});
|
|
1758
|
+
var no_floating_infinite_animations_default = noFloatingInfiniteAnimations;
|
|
1759
|
+
|
|
1760
|
+
// dist/rules/no-floating-media-streams.js
|
|
1761
|
+
var import_utils12 = require("@typescript-eslint/utils");
|
|
1762
|
+
var mediaCaptureFunctionNames = [
|
|
1763
|
+
"getDisplayMedia",
|
|
1764
|
+
"getUserMedia"
|
|
1765
|
+
];
|
|
1766
|
+
var globalNavigatorReceiverNames2 = ["globalThis", "window"];
|
|
1767
|
+
var mediaCaptureFunctionNameSet = new Set(mediaCaptureFunctionNames);
|
|
1768
|
+
var globalNavigatorReceiverNameSet2 = new Set(globalNavigatorReceiverNames2);
|
|
1769
|
+
var isMediaCaptureFunctionName = (name) => mediaCaptureFunctionNameSet.has(name);
|
|
1770
|
+
var getTransparentWrappedExpression8 = (node) => {
|
|
1771
|
+
if (node.type === import_utils12.AST_NODE_TYPES.AwaitExpression) {
|
|
1772
|
+
return node.argument;
|
|
1773
|
+
}
|
|
1774
|
+
if (node.type === import_utils12.AST_NODE_TYPES.ChainExpression) {
|
|
1775
|
+
return node.expression;
|
|
1776
|
+
}
|
|
1777
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSAsExpression) {
|
|
1778
|
+
return node.expression;
|
|
1779
|
+
}
|
|
1780
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSNonNullExpression) {
|
|
1781
|
+
return node.expression;
|
|
1782
|
+
}
|
|
1783
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1784
|
+
return node.expression;
|
|
1785
|
+
}
|
|
1786
|
+
if (node.type === import_utils12.AST_NODE_TYPES.TSTypeAssertion) {
|
|
1787
|
+
return node.expression;
|
|
1788
|
+
}
|
|
1789
|
+
return void 0;
|
|
1790
|
+
};
|
|
1791
|
+
var getStaticPropertyName8 = (node, computed) => {
|
|
1792
|
+
if (!computed && node.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1793
|
+
return node.name;
|
|
1794
|
+
}
|
|
1795
|
+
if (computed && node.type === import_utils12.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
1796
|
+
return node.value;
|
|
1797
|
+
}
|
|
1798
|
+
return void 0;
|
|
1799
|
+
};
|
|
1800
|
+
var collectStaticMemberPath3 = (node) => {
|
|
1801
|
+
if (node.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1802
|
+
return [node.name];
|
|
1803
|
+
}
|
|
1804
|
+
if (node.type !== import_utils12.AST_NODE_TYPES.MemberExpression || node.optional) {
|
|
1805
|
+
return void 0;
|
|
1806
|
+
}
|
|
1807
|
+
const objectPath = collectStaticMemberPath3(node.object);
|
|
1808
|
+
const propertyName = getStaticPropertyName8(node.property, node.computed);
|
|
1809
|
+
return objectPath === void 0 || propertyName === void 0 ? void 0 : [...objectPath, propertyName];
|
|
1810
|
+
};
|
|
1811
|
+
var isShadowedNavigatorIdentifier2 = (context, identifier) => {
|
|
1812
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1813
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1814
|
+
return variable !== null && variable.defs.length > 0;
|
|
1815
|
+
};
|
|
1816
|
+
var getRootIdentifier2 = (node) => {
|
|
1817
|
+
if (node.type === import_utils12.AST_NODE_TYPES.Identifier) {
|
|
1818
|
+
return node;
|
|
1819
|
+
}
|
|
1820
|
+
return node.type === import_utils12.AST_NODE_TYPES.MemberExpression ? getRootIdentifier2(node.object) : void 0;
|
|
1821
|
+
};
|
|
1822
|
+
var isNavigatorPathShadowed2 = (context, callee) => {
|
|
1823
|
+
if (callee.type !== import_utils12.AST_NODE_TYPES.MemberExpression) {
|
|
1824
|
+
return false;
|
|
1825
|
+
}
|
|
1826
|
+
const rootIdentifier = getRootIdentifier2(callee.object);
|
|
1827
|
+
return rootIdentifier?.name === "navigator" && isShadowedNavigatorIdentifier2(context, rootIdentifier);
|
|
1828
|
+
};
|
|
1829
|
+
var getMediaCaptureNameFromPath = (path) => {
|
|
1830
|
+
const captureName = path.at(-1);
|
|
1831
|
+
if (captureName === void 0 || !isMediaCaptureFunctionName(captureName)) {
|
|
1832
|
+
return void 0;
|
|
1833
|
+
}
|
|
1834
|
+
if (path.length === 3 && path[0] === "navigator" && path[1] === "mediaDevices") {
|
|
1835
|
+
return captureName;
|
|
1836
|
+
}
|
|
1837
|
+
if (path.length === 4 && globalNavigatorReceiverNameSet2.has(path[0] ?? "") && path[1] === "navigator" && path[2] === "mediaDevices") {
|
|
1838
|
+
return captureName;
|
|
1839
|
+
}
|
|
1840
|
+
return void 0;
|
|
1841
|
+
};
|
|
1842
|
+
var getMediaCaptureFunctionName = (context, callee) => {
|
|
1843
|
+
if (callee.type !== import_utils12.AST_NODE_TYPES.MemberExpression || isNavigatorPathShadowed2(context, callee)) {
|
|
1844
|
+
return void 0;
|
|
1845
|
+
}
|
|
1846
|
+
const path = collectStaticMemberPath3(callee);
|
|
1847
|
+
return path === void 0 ? void 0 : getMediaCaptureNameFromPath(path);
|
|
1848
|
+
};
|
|
1849
|
+
var isDiscardedMediaStreamRequest = (node) => {
|
|
1850
|
+
let current = node;
|
|
1851
|
+
let parent = getParentNode(current);
|
|
1852
|
+
while (parent !== void 0) {
|
|
1853
|
+
const wrappedExpression = getTransparentWrappedExpression8(parent);
|
|
1854
|
+
if (wrappedExpression === current) {
|
|
1855
|
+
current = parent;
|
|
1856
|
+
parent = getParentNode(current);
|
|
1857
|
+
continue;
|
|
1858
|
+
}
|
|
1859
|
+
if (parent.type === import_utils12.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1860
|
+
return true;
|
|
1861
|
+
}
|
|
1862
|
+
if (parent.type === import_utils12.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1863
|
+
const unaryParent = getParentNode(parent);
|
|
1864
|
+
return unaryParent?.type === import_utils12.AST_NODE_TYPES.ExpressionStatement;
|
|
1865
|
+
}
|
|
1866
|
+
return false;
|
|
1867
|
+
}
|
|
1868
|
+
return false;
|
|
1869
|
+
};
|
|
1870
|
+
var noFloatingMediaStreams = createTypedRule({
|
|
1871
|
+
create(context) {
|
|
1872
|
+
return {
|
|
1873
|
+
CallExpression(node) {
|
|
1874
|
+
const captureName = getMediaCaptureFunctionName(context, node.callee);
|
|
1875
|
+
if (captureName === void 0 || !isDiscardedMediaStreamRequest(node)) {
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
context.report({
|
|
1879
|
+
data: { captureName },
|
|
1880
|
+
messageId: "floatingMediaStream",
|
|
1881
|
+
node
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
};
|
|
1885
|
+
},
|
|
1886
|
+
defaultOptions: [],
|
|
1887
|
+
meta: {
|
|
1888
|
+
docs: {
|
|
1889
|
+
description: "require captured MediaStream handles to be retained so their tracks can be stopped.",
|
|
1890
|
+
recommended: true,
|
|
1891
|
+
requiresTypeChecking: false,
|
|
1892
|
+
runtimeCleanupConfigs: [
|
|
1893
|
+
"runtime-cleanup.configs.recommended",
|
|
1894
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
1895
|
+
"runtime-cleanup.configs.strict",
|
|
1896
|
+
"runtime-cleanup.configs.all"
|
|
1897
|
+
],
|
|
1898
|
+
url: createRuleDocsUrl("no-floating-media-streams")
|
|
1899
|
+
},
|
|
1900
|
+
messages: {
|
|
1901
|
+
floatingMediaStream: "Store or return the MediaStream from {{captureName}} so its tracks can be stopped during cleanup."
|
|
1902
|
+
},
|
|
1903
|
+
schema: [],
|
|
1904
|
+
type: "problem"
|
|
1905
|
+
},
|
|
1906
|
+
name: "no-floating-media-streams"
|
|
1907
|
+
});
|
|
1908
|
+
var no_floating_media_streams_default = noFloatingMediaStreams;
|
|
1909
|
+
|
|
1910
|
+
// dist/rules/no-floating-message-channels.js
|
|
1911
|
+
var import_utils13 = require("@typescript-eslint/utils");
|
|
1912
|
+
var messageChannelConstructorName = "MessageChannel";
|
|
1913
|
+
var messagePortPropertyNames = ["port1", "port2"];
|
|
1914
|
+
var globalReceiverNames5 = [
|
|
1915
|
+
"globalThis",
|
|
1916
|
+
"self",
|
|
1917
|
+
"window"
|
|
1918
|
+
];
|
|
1919
|
+
var globalReceiverNameSet5 = new Set(globalReceiverNames5);
|
|
1920
|
+
var messagePortPropertyNameSet = new Set(messagePortPropertyNames);
|
|
1921
|
+
var isGlobalReceiverName4 = (name) => globalReceiverNameSet5.has(name);
|
|
1922
|
+
var isMessagePortPropertyName = (name) => messagePortPropertyNameSet.has(name);
|
|
1923
|
+
var getTransparentWrappedExpression9 = (node) => {
|
|
1924
|
+
if (node.type === import_utils13.AST_NODE_TYPES.ChainExpression) {
|
|
1925
|
+
return node.expression;
|
|
1926
|
+
}
|
|
1927
|
+
if (node.type === import_utils13.AST_NODE_TYPES.TSAsExpression) {
|
|
1928
|
+
return node.expression;
|
|
1929
|
+
}
|
|
1930
|
+
if (node.type === import_utils13.AST_NODE_TYPES.TSNonNullExpression) {
|
|
1931
|
+
return node.expression;
|
|
1932
|
+
}
|
|
1933
|
+
if (node.type === import_utils13.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
1934
|
+
return node.expression;
|
|
1935
|
+
}
|
|
1936
|
+
if (node.type === import_utils13.AST_NODE_TYPES.TSTypeAssertion) {
|
|
1937
|
+
return node.expression;
|
|
1938
|
+
}
|
|
1939
|
+
return void 0;
|
|
1940
|
+
};
|
|
1941
|
+
var getStaticPropertyName9 = (node, computed) => {
|
|
1942
|
+
if (!computed && node.type === import_utils13.AST_NODE_TYPES.Identifier) {
|
|
1943
|
+
return node.name;
|
|
1944
|
+
}
|
|
1945
|
+
if (computed && node.type === import_utils13.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
1946
|
+
return node.value;
|
|
1947
|
+
}
|
|
1948
|
+
return void 0;
|
|
1949
|
+
};
|
|
1950
|
+
var isShadowedMessageChannelIdentifier = (context, identifier) => {
|
|
1951
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
1952
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1953
|
+
return variable !== null && variable.defs.length > 0;
|
|
1954
|
+
};
|
|
1955
|
+
var isDirectMessageChannelConstructor = (context, callee) => callee.type === import_utils13.AST_NODE_TYPES.Identifier && callee.name === messageChannelConstructorName && !isShadowedMessageChannelIdentifier(context, callee);
|
|
1956
|
+
var isMemberMessageChannelConstructor = (callee) => callee.type === import_utils13.AST_NODE_TYPES.MemberExpression && !callee.optional && callee.object.type === import_utils13.AST_NODE_TYPES.Identifier && isGlobalReceiverName4(callee.object.name) && getStaticPropertyName9(callee.property, callee.computed) === messageChannelConstructorName;
|
|
1957
|
+
var isMessageChannelConstructor = (context, callee) => isDirectMessageChannelConstructor(context, callee) || isMemberMessageChannelConstructor(callee);
|
|
1958
|
+
var isDiscardedMessageChannel = (node) => {
|
|
1959
|
+
let current = node;
|
|
1960
|
+
let parent = getParentNode(current);
|
|
1961
|
+
while (parent !== void 0) {
|
|
1962
|
+
const wrappedExpression = getTransparentWrappedExpression9(parent);
|
|
1963
|
+
if (wrappedExpression === current) {
|
|
1964
|
+
current = parent;
|
|
1965
|
+
parent = getParentNode(current);
|
|
1966
|
+
continue;
|
|
1967
|
+
}
|
|
1968
|
+
if (parent.type === import_utils13.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1969
|
+
return true;
|
|
1970
|
+
}
|
|
1971
|
+
if (parent.type === import_utils13.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1972
|
+
const unaryParent = getParentNode(parent);
|
|
1973
|
+
return unaryParent?.type === import_utils13.AST_NODE_TYPES.ExpressionStatement;
|
|
1974
|
+
}
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
return false;
|
|
1978
|
+
};
|
|
1979
|
+
var isImmediateMessagePortAccess = (node) => {
|
|
1980
|
+
let current = node;
|
|
1981
|
+
let parent = getParentNode(current);
|
|
1982
|
+
while (parent !== void 0) {
|
|
1983
|
+
const wrappedExpression = getTransparentWrappedExpression9(parent);
|
|
1984
|
+
if (wrappedExpression === current) {
|
|
1985
|
+
current = parent;
|
|
1986
|
+
parent = getParentNode(current);
|
|
1987
|
+
continue;
|
|
1988
|
+
}
|
|
1989
|
+
if (parent.type !== import_utils13.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
1990
|
+
return false;
|
|
1991
|
+
}
|
|
1992
|
+
const propertyName = getStaticPropertyName9(parent.property, parent.computed);
|
|
1993
|
+
return propertyName !== void 0 && isMessagePortPropertyName(propertyName);
|
|
1994
|
+
}
|
|
1995
|
+
return false;
|
|
1996
|
+
};
|
|
1997
|
+
var noFloatingMessageChannels = createTypedRule({
|
|
1998
|
+
create(context) {
|
|
1999
|
+
return {
|
|
2000
|
+
NewExpression(node) {
|
|
2001
|
+
if (!isMessageChannelConstructor(context, node.callee) || !isDiscardedMessageChannel(node) && !isImmediateMessagePortAccess(node)) {
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
2004
|
+
context.report({
|
|
2005
|
+
messageId: "floatingMessageChannel",
|
|
2006
|
+
node
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
},
|
|
2011
|
+
defaultOptions: [],
|
|
2012
|
+
meta: {
|
|
2013
|
+
docs: {
|
|
2014
|
+
description: "require MessageChannel ports to be retained so they can be closed.",
|
|
2015
|
+
recommended: true,
|
|
2016
|
+
requiresTypeChecking: false,
|
|
2017
|
+
runtimeCleanupConfigs: [
|
|
2018
|
+
"runtime-cleanup.configs.recommended",
|
|
2019
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2020
|
+
"runtime-cleanup.configs.strict",
|
|
2021
|
+
"runtime-cleanup.configs.all"
|
|
2022
|
+
],
|
|
2023
|
+
url: createRuleDocsUrl("no-floating-message-channels")
|
|
2024
|
+
},
|
|
2025
|
+
messages: {
|
|
2026
|
+
floatingMessageChannel: "Store or return the MessageChannel handle or both MessagePort handles so the ports can be closed during cleanup."
|
|
2027
|
+
},
|
|
2028
|
+
schema: [],
|
|
2029
|
+
type: "problem"
|
|
2030
|
+
},
|
|
2031
|
+
name: "no-floating-message-channels"
|
|
2032
|
+
});
|
|
2033
|
+
var no_floating_message_channels_default = noFloatingMessageChannels;
|
|
2034
|
+
|
|
2035
|
+
// dist/rules/no-floating-network-connections.js
|
|
2036
|
+
var import_utils14 = require("@typescript-eslint/utils");
|
|
2037
|
+
var networkConnectionConstructorNames = [
|
|
2038
|
+
"EventSource",
|
|
2039
|
+
"WebSocket"
|
|
2040
|
+
];
|
|
2041
|
+
var globalReceiverNames6 = [
|
|
2042
|
+
"globalThis",
|
|
2043
|
+
"self",
|
|
2044
|
+
"window"
|
|
2045
|
+
];
|
|
2046
|
+
var networkConnectionConstructorNameSet = new Set(networkConnectionConstructorNames);
|
|
2047
|
+
var globalReceiverNameSet6 = new Set(globalReceiverNames6);
|
|
2048
|
+
var isNetworkConnectionConstructorName = (name) => networkConnectionConstructorNameSet.has(name);
|
|
2049
|
+
var isGlobalReceiverName5 = (name) => globalReceiverNameSet6.has(name);
|
|
2050
|
+
var getTransparentWrappedExpression10 = (node) => {
|
|
2051
|
+
if (node.type === import_utils14.AST_NODE_TYPES.ChainExpression) {
|
|
2052
|
+
return node.expression;
|
|
2053
|
+
}
|
|
2054
|
+
if (node.type === import_utils14.AST_NODE_TYPES.TSAsExpression) {
|
|
2055
|
+
return node.expression;
|
|
2056
|
+
}
|
|
2057
|
+
if (node.type === import_utils14.AST_NODE_TYPES.TSNonNullExpression) {
|
|
2058
|
+
return node.expression;
|
|
2059
|
+
}
|
|
2060
|
+
if (node.type === import_utils14.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2061
|
+
return node.expression;
|
|
2062
|
+
}
|
|
2063
|
+
if (node.type === import_utils14.AST_NODE_TYPES.TSTypeAssertion) {
|
|
2064
|
+
return node.expression;
|
|
2065
|
+
}
|
|
2066
|
+
return void 0;
|
|
2067
|
+
};
|
|
2068
|
+
var getStaticPropertyName10 = (node, computed) => {
|
|
2069
|
+
if (!computed && node.type === import_utils14.AST_NODE_TYPES.Identifier) {
|
|
2070
|
+
return node.name;
|
|
2071
|
+
}
|
|
2072
|
+
if (computed && node.type === import_utils14.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
2073
|
+
return node.value;
|
|
2074
|
+
}
|
|
2075
|
+
return void 0;
|
|
2076
|
+
};
|
|
2077
|
+
var isShadowedNetworkConnectionIdentifier = (context, identifier) => {
|
|
2078
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2079
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2080
|
+
return variable !== null && variable.defs.length > 0;
|
|
2081
|
+
};
|
|
2082
|
+
var getDirectNetworkConnectionConstructorName = (context, callee) => {
|
|
2083
|
+
if (callee.type !== import_utils14.AST_NODE_TYPES.Identifier || !isNetworkConnectionConstructorName(callee.name) || isShadowedNetworkConnectionIdentifier(context, callee)) {
|
|
2084
|
+
return void 0;
|
|
2085
|
+
}
|
|
2086
|
+
return callee.name;
|
|
2087
|
+
};
|
|
2088
|
+
var getMemberNetworkConnectionConstructorName = (callee) => {
|
|
2089
|
+
if (callee.type !== import_utils14.AST_NODE_TYPES.MemberExpression || callee.optional || callee.object.type !== import_utils14.AST_NODE_TYPES.Identifier || !isGlobalReceiverName5(callee.object.name)) {
|
|
2090
|
+
return void 0;
|
|
2091
|
+
}
|
|
2092
|
+
const constructorName = getStaticPropertyName10(callee.property, callee.computed);
|
|
2093
|
+
return constructorName !== void 0 && isNetworkConnectionConstructorName(constructorName) ? constructorName : void 0;
|
|
2094
|
+
};
|
|
2095
|
+
var getNetworkConnectionConstructorName = (context, callee) => getDirectNetworkConnectionConstructorName(context, callee) ?? getMemberNetworkConnectionConstructorName(callee);
|
|
2096
|
+
var isDiscardedNetworkConnection = (node) => {
|
|
2097
|
+
let current = node;
|
|
2098
|
+
let parent = getParentNode(current);
|
|
2099
|
+
while (parent !== void 0) {
|
|
2100
|
+
const wrappedExpression = getTransparentWrappedExpression10(parent);
|
|
2101
|
+
if (wrappedExpression === current) {
|
|
2102
|
+
current = parent;
|
|
2103
|
+
parent = getParentNode(current);
|
|
2104
|
+
continue;
|
|
2105
|
+
}
|
|
2106
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2107
|
+
return true;
|
|
2108
|
+
}
|
|
2109
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2110
|
+
const unaryParent = getParentNode(parent);
|
|
2111
|
+
return unaryParent?.type === import_utils14.AST_NODE_TYPES.ExpressionStatement;
|
|
2112
|
+
}
|
|
2113
|
+
return false;
|
|
2114
|
+
}
|
|
2115
|
+
return false;
|
|
2116
|
+
};
|
|
2117
|
+
var isImmediateNetworkConnectionMethodReceiver = (node) => {
|
|
2118
|
+
let current = node;
|
|
2119
|
+
let parent = getParentNode(current);
|
|
2120
|
+
while (parent !== void 0) {
|
|
2121
|
+
const wrappedExpression = getTransparentWrappedExpression10(parent);
|
|
2122
|
+
if (wrappedExpression === current) {
|
|
2123
|
+
current = parent;
|
|
2124
|
+
parent = getParentNode(current);
|
|
2125
|
+
continue;
|
|
2126
|
+
}
|
|
2127
|
+
if (parent.type !== import_utils14.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
2128
|
+
return false;
|
|
2129
|
+
}
|
|
2130
|
+
if (getStaticPropertyName10(parent.property, parent.computed) === "close") {
|
|
2131
|
+
return false;
|
|
2132
|
+
}
|
|
2133
|
+
const callExpression = getParentNode(parent);
|
|
2134
|
+
return callExpression?.type === import_utils14.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
2135
|
+
}
|
|
2136
|
+
return false;
|
|
2137
|
+
};
|
|
2138
|
+
var noFloatingNetworkConnections = createTypedRule({
|
|
2139
|
+
create(context) {
|
|
2140
|
+
return {
|
|
2141
|
+
NewExpression(node) {
|
|
2142
|
+
const connectionName = getNetworkConnectionConstructorName(context, node.callee);
|
|
2143
|
+
if (connectionName === void 0 || !isDiscardedNetworkConnection(node) && !isImmediateNetworkConnectionMethodReceiver(node)) {
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
context.report({
|
|
2147
|
+
data: { connectionName },
|
|
2148
|
+
messageId: "floatingNetworkConnection",
|
|
2149
|
+
node
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2153
|
+
},
|
|
2154
|
+
defaultOptions: [],
|
|
2155
|
+
meta: {
|
|
2156
|
+
docs: {
|
|
2157
|
+
description: "require browser network connection handles to be retained so they can be closed.",
|
|
2158
|
+
recommended: true,
|
|
2159
|
+
requiresTypeChecking: false,
|
|
2160
|
+
runtimeCleanupConfigs: [
|
|
2161
|
+
"runtime-cleanup.configs.recommended",
|
|
2162
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2163
|
+
"runtime-cleanup.configs.strict",
|
|
2164
|
+
"runtime-cleanup.configs.all"
|
|
2165
|
+
],
|
|
2166
|
+
url: createRuleDocsUrl("no-floating-network-connections")
|
|
2167
|
+
},
|
|
2168
|
+
messages: {
|
|
2169
|
+
floatingNetworkConnection: "Store or return the {{connectionName}} handle so close() can release the connection during cleanup."
|
|
2170
|
+
},
|
|
2171
|
+
schema: [],
|
|
2172
|
+
type: "problem"
|
|
2173
|
+
},
|
|
2174
|
+
name: "no-floating-network-connections"
|
|
2175
|
+
});
|
|
2176
|
+
var no_floating_network_connections_default = noFloatingNetworkConnections;
|
|
2177
|
+
|
|
2178
|
+
// dist/rules/no-floating-object-urls.js
|
|
2179
|
+
var import_utils15 = require("@typescript-eslint/utils");
|
|
2180
|
+
var globalUrlReceiverNames = ["globalThis", "self", "window"];
|
|
2181
|
+
var globalUrlReceiverNameSet = new Set(globalUrlReceiverNames);
|
|
2182
|
+
var getRootIdentifier3 = (node) => {
|
|
2183
|
+
if (node.type === import_utils15.AST_NODE_TYPES.Identifier) {
|
|
2184
|
+
return node;
|
|
2185
|
+
}
|
|
2186
|
+
return node.type === import_utils15.AST_NODE_TYPES.MemberExpression ? getRootIdentifier3(node.object) : void 0;
|
|
2187
|
+
};
|
|
2188
|
+
var isShadowedIdentifier3 = (context, identifier) => {
|
|
2189
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2190
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2191
|
+
return variable !== null && variable.defs.length > 0;
|
|
2192
|
+
};
|
|
2193
|
+
var isDirectUrlPath = (path) => path.length === 2 && path[0] === "URL" && path[1] === "createObjectURL";
|
|
2194
|
+
var isGlobalUrlPath = (path) => path.length === 3 && globalUrlReceiverNameSet.has(path[0] ?? "") && path[1] === "URL" && path[2] === "createObjectURL";
|
|
2195
|
+
var isObjectUrlCreateCall = (context, callee) => {
|
|
2196
|
+
if (callee.type !== import_utils15.AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
const path = collectStaticMemberPath(callee);
|
|
2200
|
+
if (path === void 0 || !isDirectUrlPath(path) && !isGlobalUrlPath(path)) {
|
|
2201
|
+
return false;
|
|
2202
|
+
}
|
|
2203
|
+
const rootIdentifier = getRootIdentifier3(callee.object);
|
|
2204
|
+
return rootIdentifier?.name !== "URL" || !isShadowedIdentifier3(context, rootIdentifier);
|
|
2205
|
+
};
|
|
2206
|
+
var noFloatingObjectUrls = createTypedRule({
|
|
2207
|
+
create(context) {
|
|
2208
|
+
return {
|
|
2209
|
+
CallExpression(node) {
|
|
2210
|
+
if (!isObjectUrlCreateCall(context, node.callee) || !isDiscardedResourceExpression(node)) {
|
|
2211
|
+
return;
|
|
2212
|
+
}
|
|
2213
|
+
context.report({
|
|
2214
|
+
messageId: "floatingObjectUrl",
|
|
2215
|
+
node
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
},
|
|
2220
|
+
defaultOptions: [],
|
|
2221
|
+
meta: {
|
|
2222
|
+
docs: {
|
|
2223
|
+
description: "require object URLs to be retained so they can be revoked.",
|
|
2224
|
+
recommended: true,
|
|
2225
|
+
requiresTypeChecking: false,
|
|
2226
|
+
runtimeCleanupConfigs: [
|
|
2227
|
+
"runtime-cleanup.configs.recommended",
|
|
2228
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2229
|
+
"runtime-cleanup.configs.strict",
|
|
2230
|
+
"runtime-cleanup.configs.all"
|
|
2231
|
+
],
|
|
2232
|
+
url: createRuleDocsUrl("no-floating-object-urls")
|
|
2233
|
+
},
|
|
2234
|
+
messages: {
|
|
2235
|
+
floatingObjectUrl: "Store or return the object URL so URL.revokeObjectURL() can release the Blob or File when cleanup runs."
|
|
2236
|
+
},
|
|
2237
|
+
schema: [],
|
|
2238
|
+
type: "problem"
|
|
2239
|
+
},
|
|
2240
|
+
name: "no-floating-object-urls"
|
|
2241
|
+
});
|
|
2242
|
+
var no_floating_object_urls_default = noFloatingObjectUrls;
|
|
2243
|
+
|
|
2244
|
+
// dist/rules/no-floating-observers.js
|
|
2245
|
+
var import_utils16 = require("@typescript-eslint/utils");
|
|
2246
|
+
var observerConstructorNames = [
|
|
2247
|
+
"IntersectionObserver",
|
|
2248
|
+
"MutationObserver",
|
|
2249
|
+
"PerformanceObserver",
|
|
2250
|
+
"ReportingObserver",
|
|
2251
|
+
"ResizeObserver"
|
|
2252
|
+
];
|
|
2253
|
+
var globalReceiverNames7 = [
|
|
2254
|
+
"globalThis",
|
|
2255
|
+
"self",
|
|
2256
|
+
"window"
|
|
2257
|
+
];
|
|
2258
|
+
var globalReceiverNameSet7 = new Set(globalReceiverNames7);
|
|
2259
|
+
var observerConstructorNameSet = new Set(observerConstructorNames);
|
|
2260
|
+
var isGlobalReceiverName6 = (name) => globalReceiverNameSet7.has(name);
|
|
2261
|
+
var isObserverConstructorName = (name) => observerConstructorNameSet.has(name);
|
|
2262
|
+
var getTransparentWrappedExpression11 = (node) => {
|
|
2263
|
+
if (node.type === import_utils16.AST_NODE_TYPES.ChainExpression) {
|
|
2264
|
+
return node.expression;
|
|
2265
|
+
}
|
|
2266
|
+
if (node.type === import_utils16.AST_NODE_TYPES.TSAsExpression) {
|
|
2267
|
+
return node.expression;
|
|
2268
|
+
}
|
|
2269
|
+
if (node.type === import_utils16.AST_NODE_TYPES.TSNonNullExpression) {
|
|
2270
|
+
return node.expression;
|
|
2271
|
+
}
|
|
2272
|
+
if (node.type === import_utils16.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2273
|
+
return node.expression;
|
|
2274
|
+
}
|
|
2275
|
+
if (node.type === import_utils16.AST_NODE_TYPES.TSTypeAssertion) {
|
|
2276
|
+
return node.expression;
|
|
2277
|
+
}
|
|
2278
|
+
return void 0;
|
|
2279
|
+
};
|
|
2280
|
+
var isShadowedIdentifier4 = (context, identifier) => {
|
|
2281
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2282
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2283
|
+
return variable !== null && variable.defs.length > 0;
|
|
2284
|
+
};
|
|
2285
|
+
var getDirectObserverConstructorName = (context, callee) => {
|
|
2286
|
+
if (callee.type !== import_utils16.AST_NODE_TYPES.Identifier || !isObserverConstructorName(callee.name) || isShadowedIdentifier4(context, callee)) {
|
|
2287
|
+
return void 0;
|
|
2288
|
+
}
|
|
2289
|
+
return callee.name;
|
|
2290
|
+
};
|
|
2291
|
+
var getMemberObserverConstructorName = (callee) => {
|
|
2292
|
+
if (callee.type !== import_utils16.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils16.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils16.AST_NODE_TYPES.Identifier || !isGlobalReceiverName6(callee.object.name) || !isObserverConstructorName(callee.property.name)) {
|
|
2293
|
+
return void 0;
|
|
2294
|
+
}
|
|
2295
|
+
return callee.property.name;
|
|
2296
|
+
};
|
|
2297
|
+
var getObserverConstructorName = (context, callee) => getDirectObserverConstructorName(context, callee) ?? getMemberObserverConstructorName(callee);
|
|
2298
|
+
var isObserveMethodCallReceiver = (node) => {
|
|
2299
|
+
let current = node;
|
|
2300
|
+
let parent = getParentNode(current);
|
|
2301
|
+
while (parent !== void 0) {
|
|
2302
|
+
const wrappedExpression = getTransparentWrappedExpression11(parent);
|
|
2303
|
+
if (wrappedExpression === current) {
|
|
2304
|
+
current = parent;
|
|
2305
|
+
parent = getParentNode(current);
|
|
2306
|
+
continue;
|
|
2307
|
+
}
|
|
2308
|
+
if (parent.type !== import_utils16.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.computed || parent.property.type !== import_utils16.AST_NODE_TYPES.Identifier || parent.property.name !== "observe") {
|
|
2309
|
+
return false;
|
|
2310
|
+
}
|
|
2311
|
+
const callExpression = getParentNode(parent);
|
|
2312
|
+
return callExpression?.type === import_utils16.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
2313
|
+
}
|
|
2314
|
+
return false;
|
|
2315
|
+
};
|
|
2316
|
+
var isDiscardedObserverInstance = (node) => {
|
|
2317
|
+
let current = node;
|
|
2318
|
+
let parent = getParentNode(current);
|
|
2319
|
+
while (parent !== void 0) {
|
|
2320
|
+
const wrappedExpression = getTransparentWrappedExpression11(parent);
|
|
2321
|
+
if (wrappedExpression === current) {
|
|
2322
|
+
current = parent;
|
|
2323
|
+
parent = getParentNode(current);
|
|
2324
|
+
continue;
|
|
2325
|
+
}
|
|
2326
|
+
if (parent.type === import_utils16.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2327
|
+
return true;
|
|
2328
|
+
}
|
|
2329
|
+
if (parent.type === import_utils16.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2330
|
+
const unaryParent = getParentNode(parent);
|
|
2331
|
+
return unaryParent?.type === import_utils16.AST_NODE_TYPES.ExpressionStatement;
|
|
2332
|
+
}
|
|
2333
|
+
return false;
|
|
2334
|
+
}
|
|
2335
|
+
return false;
|
|
2336
|
+
};
|
|
2337
|
+
var noFloatingObservers = createTypedRule({
|
|
2338
|
+
create(context) {
|
|
2339
|
+
return {
|
|
2340
|
+
NewExpression(node) {
|
|
2341
|
+
const observerName = getObserverConstructorName(context, node.callee);
|
|
2342
|
+
if (observerName === void 0 || !isDiscardedObserverInstance(node) && !isObserveMethodCallReceiver(node)) {
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
context.report({
|
|
2346
|
+
data: { observerName },
|
|
2347
|
+
messageId: "floatingObserver",
|
|
2348
|
+
node
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
},
|
|
2353
|
+
defaultOptions: [],
|
|
2354
|
+
meta: {
|
|
2355
|
+
docs: {
|
|
2356
|
+
description: "require observer instances to be retained so they can be disconnected during cleanup.",
|
|
2357
|
+
recommended: true,
|
|
2358
|
+
requiresTypeChecking: false,
|
|
2359
|
+
runtimeCleanupConfigs: [
|
|
2360
|
+
"runtime-cleanup.configs.recommended",
|
|
2361
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2362
|
+
"runtime-cleanup.configs.strict",
|
|
2363
|
+
"runtime-cleanup.configs.all"
|
|
2364
|
+
],
|
|
2365
|
+
url: createRuleDocsUrl("no-floating-observers")
|
|
2366
|
+
},
|
|
2367
|
+
messages: {
|
|
2368
|
+
floatingObserver: "Store or return the {{observerName}} instance so it can be disconnected during cleanup."
|
|
2369
|
+
},
|
|
2370
|
+
schema: [],
|
|
2371
|
+
type: "problem"
|
|
2372
|
+
},
|
|
2373
|
+
name: "no-floating-observers"
|
|
2374
|
+
});
|
|
2375
|
+
var no_floating_observers_default = noFloatingObservers;
|
|
2376
|
+
|
|
2377
|
+
// dist/rules/no-floating-servers.js
|
|
2378
|
+
var import_utils17 = require("@typescript-eslint/utils");
|
|
2379
|
+
var serverFactoryNames = [
|
|
2380
|
+
"createSecureServer",
|
|
2381
|
+
"createServer"
|
|
2382
|
+
];
|
|
2383
|
+
var http2OnlyServerFactoryNames = ["createSecureServer"];
|
|
2384
|
+
var serverModuleNames = [
|
|
2385
|
+
"http",
|
|
2386
|
+
"http2",
|
|
2387
|
+
"https",
|
|
2388
|
+
"net",
|
|
2389
|
+
"node:http",
|
|
2390
|
+
"node:http2",
|
|
2391
|
+
"node:https",
|
|
2392
|
+
"node:net"
|
|
2393
|
+
];
|
|
2394
|
+
var http2ServerModuleNames = ["http2", "node:http2"];
|
|
2395
|
+
var immediateCleanupMethodNames3 = ["close"];
|
|
2396
|
+
var serverFactoryNameSet = new Set(serverFactoryNames);
|
|
2397
|
+
var http2OnlyServerFactoryNameSet = new Set(http2OnlyServerFactoryNames);
|
|
2398
|
+
var serverModuleNameSet = new Set(serverModuleNames);
|
|
2399
|
+
var http2ServerModuleNameSet = new Set(http2ServerModuleNames);
|
|
2400
|
+
var immediateCleanupMethodNameSet3 = new Set(immediateCleanupMethodNames3);
|
|
2401
|
+
var isServerFactoryName = (name) => serverFactoryNameSet.has(name);
|
|
2402
|
+
var isHttp2OnlyServerFactoryName = (name) => http2OnlyServerFactoryNameSet.has(name);
|
|
2403
|
+
var isServerModuleSource = (source) => source !== void 0 && serverModuleNameSet.has(source);
|
|
2404
|
+
var isHttp2ServerModuleSource = (source) => source !== void 0 && http2ServerModuleNameSet.has(source);
|
|
2405
|
+
var isImmediateCleanupMethodName3 = (name) => immediateCleanupMethodNameSet3.has(name);
|
|
2406
|
+
var isValidServerFactoryForSource = (source, factoryName) => isServerModuleSource(source) && isServerFactoryName(factoryName) && (!isHttp2OnlyServerFactoryName(factoryName) || isHttp2ServerModuleSource(source));
|
|
2407
|
+
var getTransparentWrappedExpression12 = (node) => {
|
|
2408
|
+
if (node.type === import_utils17.AST_NODE_TYPES.ChainExpression) {
|
|
2409
|
+
return node.expression;
|
|
2410
|
+
}
|
|
2411
|
+
if (node.type === import_utils17.AST_NODE_TYPES.TSAsExpression) {
|
|
2412
|
+
return node.expression;
|
|
2413
|
+
}
|
|
2414
|
+
if (node.type === import_utils17.AST_NODE_TYPES.TSNonNullExpression) {
|
|
2415
|
+
return node.expression;
|
|
2416
|
+
}
|
|
2417
|
+
if (node.type === import_utils17.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2418
|
+
return node.expression;
|
|
2419
|
+
}
|
|
2420
|
+
if (node.type === import_utils17.AST_NODE_TYPES.TSTypeAssertion) {
|
|
2421
|
+
return node.expression;
|
|
2422
|
+
}
|
|
2423
|
+
return void 0;
|
|
2424
|
+
};
|
|
2425
|
+
var getStaticPropertyName11 = (node) => {
|
|
2426
|
+
if (node.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2427
|
+
return node.name;
|
|
2428
|
+
}
|
|
2429
|
+
if (node.type === import_utils17.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
2430
|
+
return node.value;
|
|
2431
|
+
}
|
|
2432
|
+
return void 0;
|
|
2433
|
+
};
|
|
2434
|
+
var getImportSourceValue3 = (node) => {
|
|
2435
|
+
const parent = getParentNode(node);
|
|
2436
|
+
if (parent?.type === import_utils17.AST_NODE_TYPES.ImportDeclaration && typeof parent.source.value === "string") {
|
|
2437
|
+
return parent.source.value;
|
|
2438
|
+
}
|
|
2439
|
+
return void 0;
|
|
2440
|
+
};
|
|
2441
|
+
var getRequireSourceValue3 = (expression) => {
|
|
2442
|
+
if (expression?.type !== import_utils17.AST_NODE_TYPES.CallExpression || expression.callee.type !== import_utils17.AST_NODE_TYPES.Identifier || expression.callee.name !== "require") {
|
|
2443
|
+
return void 0;
|
|
2444
|
+
}
|
|
2445
|
+
const [source] = expression.arguments;
|
|
2446
|
+
return source?.type === import_utils17.AST_NODE_TYPES.Literal && typeof source.value === "string" ? source.value : void 0;
|
|
2447
|
+
};
|
|
2448
|
+
var getDefinitionModuleSource3 = (node) => {
|
|
2449
|
+
if (node.type === import_utils17.AST_NODE_TYPES.ImportDefaultSpecifier || node.type === import_utils17.AST_NODE_TYPES.ImportNamespaceSpecifier || node.type === import_utils17.AST_NODE_TYPES.ImportSpecifier) {
|
|
2450
|
+
return getImportSourceValue3(node);
|
|
2451
|
+
}
|
|
2452
|
+
if (node.type === import_utils17.AST_NODE_TYPES.VariableDeclarator) {
|
|
2453
|
+
return getRequireSourceValue3(node.init);
|
|
2454
|
+
}
|
|
2455
|
+
return void 0;
|
|
2456
|
+
};
|
|
2457
|
+
var getDefinitionForIdentifier3 = (context, identifier) => {
|
|
2458
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2459
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2460
|
+
return variable?.defs[0];
|
|
2461
|
+
};
|
|
2462
|
+
var getImportedSpecifierName3 = (node) => getStaticPropertyName11(node.imported);
|
|
2463
|
+
var getObjectPatternPropertyNameForIdentifier3 = (objectPattern, identifierName) => {
|
|
2464
|
+
for (const property of objectPattern.properties) {
|
|
2465
|
+
if (property.type !== import_utils17.AST_NODE_TYPES.Property || property.value.type !== import_utils17.AST_NODE_TYPES.Identifier || property.value.name !== identifierName) {
|
|
2466
|
+
continue;
|
|
2467
|
+
}
|
|
2468
|
+
return getStaticPropertyName11(property.key);
|
|
2469
|
+
}
|
|
2470
|
+
return void 0;
|
|
2471
|
+
};
|
|
2472
|
+
var getModuleSourceForBinding = (context, identifier) => {
|
|
2473
|
+
const definition = getDefinitionForIdentifier3(context, identifier);
|
|
2474
|
+
return definition === void 0 ? void 0 : getDefinitionModuleSource3(definition.node);
|
|
2475
|
+
};
|
|
2476
|
+
var getNamedServerFactoryBindingName = (context, identifier) => {
|
|
2477
|
+
const definition = getDefinitionForIdentifier3(context, identifier);
|
|
2478
|
+
if (definition === void 0) {
|
|
2479
|
+
return void 0;
|
|
2480
|
+
}
|
|
2481
|
+
const source = getDefinitionModuleSource3(definition.node);
|
|
2482
|
+
if (definition.node.type === import_utils17.AST_NODE_TYPES.ImportSpecifier) {
|
|
2483
|
+
const importedName = getImportedSpecifierName3(definition.node);
|
|
2484
|
+
return importedName !== void 0 && isValidServerFactoryForSource(source, importedName) ? importedName : void 0;
|
|
2485
|
+
}
|
|
2486
|
+
if (definition.node.type === import_utils17.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils17.AST_NODE_TYPES.ObjectPattern) {
|
|
2487
|
+
const propertyName = getObjectPatternPropertyNameForIdentifier3(definition.node.id, identifier.name);
|
|
2488
|
+
return propertyName !== void 0 && isValidServerFactoryForSource(source, propertyName) ? propertyName : void 0;
|
|
2489
|
+
}
|
|
2490
|
+
return void 0;
|
|
2491
|
+
};
|
|
2492
|
+
var getRequireMemberFactoryName3 = (callee) => {
|
|
2493
|
+
if (callee.type !== import_utils17.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils17.AST_NODE_TYPES.Identifier || callee.object.type !== import_utils17.AST_NODE_TYPES.CallExpression) {
|
|
2494
|
+
return void 0;
|
|
2495
|
+
}
|
|
2496
|
+
const source = getRequireSourceValue3(callee.object);
|
|
2497
|
+
const factoryName = callee.property.name;
|
|
2498
|
+
return isValidServerFactoryForSource(source, factoryName) ? factoryName : void 0;
|
|
2499
|
+
};
|
|
2500
|
+
var getModuleMemberFactoryName3 = (context, callee) => {
|
|
2501
|
+
if (callee.type !== import_utils17.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils17.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2502
|
+
return void 0;
|
|
2503
|
+
}
|
|
2504
|
+
const source = getModuleSourceForBinding(context, callee.object);
|
|
2505
|
+
const factoryName = callee.property.name;
|
|
2506
|
+
return isValidServerFactoryForSource(source, factoryName) ? factoryName : void 0;
|
|
2507
|
+
};
|
|
2508
|
+
var getServerFactoryName = (context, callee) => {
|
|
2509
|
+
if (callee.type === import_utils17.AST_NODE_TYPES.Identifier) {
|
|
2510
|
+
return getNamedServerFactoryBindingName(context, callee);
|
|
2511
|
+
}
|
|
2512
|
+
return getModuleMemberFactoryName3(context, callee) ?? getRequireMemberFactoryName3(callee);
|
|
2513
|
+
};
|
|
2514
|
+
var isDiscardedExpression = (node) => {
|
|
2515
|
+
let current = node;
|
|
2516
|
+
let parent = getParentNode(current);
|
|
2517
|
+
while (parent !== void 0) {
|
|
2518
|
+
const wrappedExpression = getTransparentWrappedExpression12(parent);
|
|
2519
|
+
if (wrappedExpression === current) {
|
|
2520
|
+
current = parent;
|
|
2521
|
+
parent = getParentNode(current);
|
|
2522
|
+
continue;
|
|
2523
|
+
}
|
|
2524
|
+
if (parent.type === import_utils17.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2525
|
+
return true;
|
|
2526
|
+
}
|
|
2527
|
+
if (parent.type === import_utils17.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2528
|
+
const unaryParent = getParentNode(parent);
|
|
2529
|
+
return unaryParent?.type === import_utils17.AST_NODE_TYPES.ExpressionStatement;
|
|
2530
|
+
}
|
|
2531
|
+
return false;
|
|
2532
|
+
}
|
|
2533
|
+
return false;
|
|
2534
|
+
};
|
|
2535
|
+
var getImmediateServerMethodCall = (node) => {
|
|
2536
|
+
let current = node;
|
|
2537
|
+
let parent = getParentNode(current);
|
|
2538
|
+
while (parent !== void 0) {
|
|
2539
|
+
const wrappedExpression = getTransparentWrappedExpression12(parent);
|
|
2540
|
+
if (wrappedExpression === current) {
|
|
2541
|
+
current = parent;
|
|
2542
|
+
parent = getParentNode(current);
|
|
2543
|
+
continue;
|
|
2544
|
+
}
|
|
2545
|
+
if (parent.type !== import_utils17.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.computed || parent.property.type !== import_utils17.AST_NODE_TYPES.Identifier || isImmediateCleanupMethodName3(parent.property.name)) {
|
|
2546
|
+
return void 0;
|
|
2547
|
+
}
|
|
2548
|
+
const callExpression = getParentNode(parent);
|
|
2549
|
+
return callExpression?.type === import_utils17.AST_NODE_TYPES.CallExpression && callExpression.callee === parent ? callExpression : void 0;
|
|
2550
|
+
}
|
|
2551
|
+
return void 0;
|
|
2552
|
+
};
|
|
2553
|
+
var isDiscardedImmediateServerMethodChain = (node) => {
|
|
2554
|
+
let currentCall = getImmediateServerMethodCall(node);
|
|
2555
|
+
while (currentCall !== void 0) {
|
|
2556
|
+
if (isDiscardedExpression(currentCall)) {
|
|
2557
|
+
return true;
|
|
2558
|
+
}
|
|
2559
|
+
currentCall = getImmediateServerMethodCall(currentCall);
|
|
2560
|
+
}
|
|
2561
|
+
return false;
|
|
2562
|
+
};
|
|
2563
|
+
var isDiscardedServerHandle = (node) => isDiscardedExpression(node) || isDiscardedImmediateServerMethodChain(node);
|
|
2564
|
+
var noFloatingServers = createTypedRule({
|
|
2565
|
+
create(context) {
|
|
2566
|
+
return {
|
|
2567
|
+
CallExpression(node) {
|
|
2568
|
+
const factoryName = getServerFactoryName(context, node.callee);
|
|
2569
|
+
if (factoryName === void 0 || !isDiscardedServerHandle(node)) {
|
|
2570
|
+
return;
|
|
2571
|
+
}
|
|
2572
|
+
context.report({
|
|
2573
|
+
data: { factoryName },
|
|
2574
|
+
messageId: "floatingServer",
|
|
2575
|
+
node
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
},
|
|
2580
|
+
defaultOptions: [],
|
|
2581
|
+
meta: {
|
|
2582
|
+
docs: {
|
|
2583
|
+
description: "require Node.js server handles to be retained so they can be closed.",
|
|
2584
|
+
recommended: true,
|
|
2585
|
+
requiresTypeChecking: false,
|
|
2586
|
+
runtimeCleanupConfigs: [
|
|
2587
|
+
"runtime-cleanup.configs.recommended",
|
|
2588
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2589
|
+
"runtime-cleanup.configs.strict",
|
|
2590
|
+
"runtime-cleanup.configs.all"
|
|
2591
|
+
],
|
|
2592
|
+
url: createRuleDocsUrl("no-floating-servers")
|
|
2593
|
+
},
|
|
2594
|
+
messages: {
|
|
2595
|
+
floatingServer: "Store or return the server from {{factoryName}} so close() can stop it during cleanup."
|
|
2596
|
+
},
|
|
2597
|
+
schema: [],
|
|
2598
|
+
type: "problem"
|
|
2599
|
+
},
|
|
2600
|
+
name: "no-floating-servers"
|
|
2601
|
+
});
|
|
2602
|
+
var no_floating_servers_default = noFloatingServers;
|
|
2603
|
+
|
|
2604
|
+
// dist/rules/no-floating-streams.js
|
|
2605
|
+
var import_utils18 = require("@typescript-eslint/utils");
|
|
2606
|
+
var fileStreamFactoryNames = [
|
|
2607
|
+
"createReadStream",
|
|
2608
|
+
"createWriteStream"
|
|
2609
|
+
];
|
|
2610
|
+
var fsModuleNames2 = ["fs", "node:fs"];
|
|
2611
|
+
var fileStreamFactoryNameSet = new Set(fileStreamFactoryNames);
|
|
2612
|
+
var fsModuleNameSet2 = new Set(fsModuleNames2);
|
|
2613
|
+
var isFileStreamFactoryName = (name) => fileStreamFactoryNameSet.has(name);
|
|
2614
|
+
var getTransparentWrappedExpression13 = (node) => {
|
|
2615
|
+
if (node.type === import_utils18.AST_NODE_TYPES.ChainExpression) {
|
|
2616
|
+
return node.expression;
|
|
2617
|
+
}
|
|
2618
|
+
if (node.type === import_utils18.AST_NODE_TYPES.TSAsExpression) {
|
|
2619
|
+
return node.expression;
|
|
2620
|
+
}
|
|
2621
|
+
if (node.type === import_utils18.AST_NODE_TYPES.TSNonNullExpression) {
|
|
2622
|
+
return node.expression;
|
|
2623
|
+
}
|
|
2624
|
+
if (node.type === import_utils18.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2625
|
+
return node.expression;
|
|
2626
|
+
}
|
|
2627
|
+
if (node.type === import_utils18.AST_NODE_TYPES.TSTypeAssertion) {
|
|
2628
|
+
return node.expression;
|
|
2629
|
+
}
|
|
2630
|
+
return void 0;
|
|
2631
|
+
};
|
|
2632
|
+
var getStaticPropertyName12 = (node) => {
|
|
2633
|
+
if (node.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
2634
|
+
return node.name;
|
|
2635
|
+
}
|
|
2636
|
+
if (node.type === import_utils18.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
2637
|
+
return node.value;
|
|
2638
|
+
}
|
|
2639
|
+
return void 0;
|
|
2640
|
+
};
|
|
2641
|
+
var getImportSourceValue4 = (node) => {
|
|
2642
|
+
const parent = getParentNode(node);
|
|
2643
|
+
if (parent?.type === import_utils18.AST_NODE_TYPES.ImportDeclaration && typeof parent.source.value === "string") {
|
|
2644
|
+
return parent.source.value;
|
|
2645
|
+
}
|
|
2646
|
+
return void 0;
|
|
2647
|
+
};
|
|
2648
|
+
var getRequireSourceValue4 = (expression) => {
|
|
2649
|
+
if (expression?.type !== import_utils18.AST_NODE_TYPES.CallExpression || expression.callee.type !== import_utils18.AST_NODE_TYPES.Identifier || expression.callee.name !== "require") {
|
|
2650
|
+
return void 0;
|
|
2651
|
+
}
|
|
2652
|
+
const [source] = expression.arguments;
|
|
2653
|
+
return source?.type === import_utils18.AST_NODE_TYPES.Literal && typeof source.value === "string" ? source.value : void 0;
|
|
2654
|
+
};
|
|
2655
|
+
var getDefinitionModuleSource4 = (node) => {
|
|
2656
|
+
if (node.type === import_utils18.AST_NODE_TYPES.ImportDefaultSpecifier || node.type === import_utils18.AST_NODE_TYPES.ImportNamespaceSpecifier || node.type === import_utils18.AST_NODE_TYPES.ImportSpecifier) {
|
|
2657
|
+
return getImportSourceValue4(node);
|
|
2658
|
+
}
|
|
2659
|
+
if (node.type === import_utils18.AST_NODE_TYPES.VariableDeclarator) {
|
|
2660
|
+
return getRequireSourceValue4(node.init);
|
|
2661
|
+
}
|
|
2662
|
+
return void 0;
|
|
2663
|
+
};
|
|
2664
|
+
var getImportedSpecifierName4 = (node) => getStaticPropertyName12(node.imported);
|
|
2665
|
+
var getObjectPatternPropertyNameForIdentifier4 = (objectPattern, identifierName) => {
|
|
2666
|
+
for (const property of objectPattern.properties) {
|
|
2667
|
+
if (property.type !== import_utils18.AST_NODE_TYPES.Property || property.value.type !== import_utils18.AST_NODE_TYPES.Identifier || property.value.name !== identifierName) {
|
|
2668
|
+
continue;
|
|
2669
|
+
}
|
|
2670
|
+
return getStaticPropertyName12(property.key);
|
|
2671
|
+
}
|
|
2672
|
+
return void 0;
|
|
2673
|
+
};
|
|
2674
|
+
var isFsModuleSource2 = (source) => source !== void 0 && fsModuleNameSet2.has(source);
|
|
2675
|
+
var getDefinitionForIdentifier4 = (context, identifier) => {
|
|
2676
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2677
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2678
|
+
return variable?.defs[0];
|
|
2679
|
+
};
|
|
2680
|
+
var isFsModuleBinding2 = (context, identifier) => {
|
|
2681
|
+
const definition = getDefinitionForIdentifier4(context, identifier);
|
|
2682
|
+
return definition !== void 0 && isFsModuleSource2(getDefinitionModuleSource4(definition.node));
|
|
2683
|
+
};
|
|
2684
|
+
var getNamedFileStreamFactoryBindingName = (context, identifier) => {
|
|
2685
|
+
const definition = getDefinitionForIdentifier4(context, identifier);
|
|
2686
|
+
if (definition === void 0) {
|
|
2687
|
+
return void 0;
|
|
2688
|
+
}
|
|
2689
|
+
const source = getDefinitionModuleSource4(definition.node);
|
|
2690
|
+
if (!isFsModuleSource2(source)) {
|
|
2691
|
+
return void 0;
|
|
2692
|
+
}
|
|
2693
|
+
if (definition.node.type === import_utils18.AST_NODE_TYPES.ImportSpecifier) {
|
|
2694
|
+
const importedName = getImportedSpecifierName4(definition.node);
|
|
2695
|
+
return importedName !== void 0 && isFileStreamFactoryName(importedName) ? importedName : void 0;
|
|
2696
|
+
}
|
|
2697
|
+
if (definition.node.type === import_utils18.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils18.AST_NODE_TYPES.ObjectPattern) {
|
|
2698
|
+
const propertyName = getObjectPatternPropertyNameForIdentifier4(definition.node.id, identifier.name);
|
|
2699
|
+
return propertyName !== void 0 && isFileStreamFactoryName(propertyName) ? propertyName : void 0;
|
|
2700
|
+
}
|
|
2701
|
+
return void 0;
|
|
2702
|
+
};
|
|
2703
|
+
var getRequireMemberFactoryName4 = (callee) => {
|
|
2704
|
+
if (callee.type !== import_utils18.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.property.type !== import_utils18.AST_NODE_TYPES.Identifier || !isFileStreamFactoryName(callee.property.name) || callee.object.type !== import_utils18.AST_NODE_TYPES.CallExpression || !isFsModuleSource2(getRequireSourceValue4(callee.object))) {
|
|
2705
|
+
return void 0;
|
|
2706
|
+
}
|
|
2707
|
+
return callee.property.name;
|
|
2708
|
+
};
|
|
2709
|
+
var getModuleMemberFactoryName4 = (context, callee) => {
|
|
2710
|
+
if (callee.type !== import_utils18.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils18.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils18.AST_NODE_TYPES.Identifier || !isFileStreamFactoryName(callee.property.name) || !isFsModuleBinding2(context, callee.object)) {
|
|
2711
|
+
return void 0;
|
|
2712
|
+
}
|
|
2713
|
+
return callee.property.name;
|
|
2714
|
+
};
|
|
2715
|
+
var getFileStreamFactoryName = (context, callee) => {
|
|
2716
|
+
if (callee.type === import_utils18.AST_NODE_TYPES.Identifier) {
|
|
2717
|
+
return getNamedFileStreamFactoryBindingName(context, callee);
|
|
2718
|
+
}
|
|
2719
|
+
return getModuleMemberFactoryName4(context, callee) ?? getRequireMemberFactoryName4(callee);
|
|
2720
|
+
};
|
|
2721
|
+
var isDiscardedFileStreamHandle = (node) => {
|
|
2722
|
+
let current = node;
|
|
2723
|
+
let parent = getParentNode(current);
|
|
2724
|
+
while (parent !== void 0) {
|
|
2725
|
+
const wrappedExpression = getTransparentWrappedExpression13(parent);
|
|
2726
|
+
if (wrappedExpression === current) {
|
|
2727
|
+
current = parent;
|
|
2728
|
+
parent = getParentNode(current);
|
|
2729
|
+
continue;
|
|
2730
|
+
}
|
|
2731
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2732
|
+
return true;
|
|
2733
|
+
}
|
|
2734
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2735
|
+
const unaryParent = getParentNode(parent);
|
|
2736
|
+
return unaryParent?.type === import_utils18.AST_NODE_TYPES.ExpressionStatement;
|
|
2737
|
+
}
|
|
2738
|
+
return false;
|
|
2739
|
+
}
|
|
2740
|
+
return false;
|
|
2741
|
+
};
|
|
2742
|
+
var noFloatingStreams = createTypedRule({
|
|
2743
|
+
create(context) {
|
|
2744
|
+
return {
|
|
2745
|
+
CallExpression(node) {
|
|
2746
|
+
const factoryName = getFileStreamFactoryName(context, node.callee);
|
|
2747
|
+
if (factoryName === void 0 || !isDiscardedFileStreamHandle(node)) {
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
context.report({
|
|
2751
|
+
data: { factoryName },
|
|
2752
|
+
messageId: "floatingStream",
|
|
2753
|
+
node
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
};
|
|
2757
|
+
},
|
|
2758
|
+
defaultOptions: [],
|
|
2759
|
+
meta: {
|
|
2760
|
+
docs: {
|
|
2761
|
+
description: "require Node.js file stream handles to be retained so they can be closed during cleanup.",
|
|
2762
|
+
recommended: true,
|
|
2763
|
+
requiresTypeChecking: false,
|
|
2764
|
+
runtimeCleanupConfigs: [
|
|
2765
|
+
"runtime-cleanup.configs.recommended",
|
|
2766
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2767
|
+
"runtime-cleanup.configs.strict",
|
|
2768
|
+
"runtime-cleanup.configs.all"
|
|
2769
|
+
],
|
|
2770
|
+
url: createRuleDocsUrl("no-floating-streams")
|
|
2771
|
+
},
|
|
2772
|
+
messages: {
|
|
2773
|
+
floatingStream: "Store, return, pipe, or destroy the stream from {{factoryName}} so cleanup can close its underlying resource."
|
|
2774
|
+
},
|
|
2775
|
+
schema: [],
|
|
2776
|
+
type: "problem"
|
|
2777
|
+
},
|
|
2778
|
+
name: "no-floating-streams"
|
|
2779
|
+
});
|
|
2780
|
+
var no_floating_streams_default = noFloatingStreams;
|
|
2781
|
+
|
|
2782
|
+
// dist/rules/no-floating-timers.js
|
|
2783
|
+
var import_utils19 = require("@typescript-eslint/utils");
|
|
2784
|
+
var timerFunctionNames = [
|
|
2785
|
+
"requestAnimationFrame",
|
|
2786
|
+
"requestIdleCallback",
|
|
2787
|
+
"setImmediate",
|
|
2788
|
+
"setInterval",
|
|
2789
|
+
"setTimeout"
|
|
2790
|
+
];
|
|
2791
|
+
var globalReceiverNames8 = [
|
|
2792
|
+
"global",
|
|
2793
|
+
"globalThis",
|
|
2794
|
+
"self",
|
|
2795
|
+
"window"
|
|
2796
|
+
];
|
|
2797
|
+
var timerFunctionNameSet = new Set(timerFunctionNames);
|
|
2798
|
+
var globalReceiverNameSet8 = new Set(globalReceiverNames8);
|
|
2799
|
+
var isTimerFunctionName = (name) => timerFunctionNameSet.has(name);
|
|
2800
|
+
var isGlobalReceiverName7 = (name) => globalReceiverNameSet8.has(name);
|
|
2801
|
+
var getTransparentWrappedExpression14 = (node) => {
|
|
2802
|
+
if (node.type === import_utils19.AST_NODE_TYPES.ChainExpression) {
|
|
2803
|
+
return node.expression;
|
|
2804
|
+
}
|
|
2805
|
+
if (node.type === import_utils19.AST_NODE_TYPES.TSAsExpression) {
|
|
2806
|
+
return node.expression;
|
|
2807
|
+
}
|
|
2808
|
+
if (node.type === import_utils19.AST_NODE_TYPES.TSNonNullExpression) {
|
|
2809
|
+
return node.expression;
|
|
2810
|
+
}
|
|
2811
|
+
if (node.type === import_utils19.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2812
|
+
return node.expression;
|
|
2813
|
+
}
|
|
2814
|
+
if (node.type === import_utils19.AST_NODE_TYPES.TSTypeAssertion) {
|
|
2815
|
+
return node.expression;
|
|
2816
|
+
}
|
|
2817
|
+
return void 0;
|
|
2818
|
+
};
|
|
2819
|
+
var isDiscardedTimerHandle = (node) => {
|
|
2820
|
+
let current = node;
|
|
2821
|
+
let parent = getParentNode(current);
|
|
2822
|
+
while (parent !== void 0) {
|
|
2823
|
+
const wrappedExpression = getTransparentWrappedExpression14(parent);
|
|
2824
|
+
if (wrappedExpression === current) {
|
|
2825
|
+
current = parent;
|
|
2826
|
+
parent = getParentNode(current);
|
|
2827
|
+
continue;
|
|
2828
|
+
}
|
|
2829
|
+
if (parent.type === import_utils19.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2830
|
+
return true;
|
|
2831
|
+
}
|
|
2832
|
+
if (parent.type === import_utils19.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2833
|
+
const unaryParent = getParentNode(parent);
|
|
2834
|
+
return unaryParent?.type === import_utils19.AST_NODE_TYPES.ExpressionStatement;
|
|
2835
|
+
}
|
|
2836
|
+
return false;
|
|
2837
|
+
}
|
|
2838
|
+
return false;
|
|
2839
|
+
};
|
|
2840
|
+
var isShadowedIdentifier5 = (context, identifier) => {
|
|
2841
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2842
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2843
|
+
return variable !== null && variable.defs.length > 0;
|
|
2844
|
+
};
|
|
2845
|
+
var getDirectTimerName = (context, callee) => {
|
|
2846
|
+
if (callee.type !== import_utils19.AST_NODE_TYPES.Identifier || !isTimerFunctionName(callee.name) || isShadowedIdentifier5(context, callee)) {
|
|
2847
|
+
return void 0;
|
|
2848
|
+
}
|
|
2849
|
+
return callee.name;
|
|
2850
|
+
};
|
|
2851
|
+
var getMemberTimerName = (callee) => {
|
|
2852
|
+
if (callee.type !== import_utils19.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils19.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils19.AST_NODE_TYPES.Identifier || !isGlobalReceiverName7(callee.object.name) || !isTimerFunctionName(callee.property.name)) {
|
|
2853
|
+
return void 0;
|
|
2854
|
+
}
|
|
2855
|
+
return callee.property.name;
|
|
2856
|
+
};
|
|
2857
|
+
var noFloatingTimers = createTypedRule({
|
|
2858
|
+
create(context) {
|
|
2859
|
+
const reportFloatingTimer = (node, timerName) => {
|
|
2860
|
+
if (!isDiscardedTimerHandle(node)) {
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
context.report({
|
|
2864
|
+
data: { timerName },
|
|
2865
|
+
messageId: "floatingTimer",
|
|
2866
|
+
node
|
|
2867
|
+
});
|
|
2868
|
+
};
|
|
2869
|
+
return {
|
|
2870
|
+
'CallExpression[callee.type="Identifier"]'(node) {
|
|
2871
|
+
const timerName = getDirectTimerName(context, node.callee);
|
|
2872
|
+
if (timerName !== void 0) {
|
|
2873
|
+
reportFloatingTimer(node, timerName);
|
|
2874
|
+
}
|
|
2875
|
+
},
|
|
2876
|
+
'CallExpression[callee.type="MemberExpression"]'(node) {
|
|
2877
|
+
const timerName = getMemberTimerName(node.callee);
|
|
2878
|
+
if (timerName !== void 0) {
|
|
2879
|
+
reportFloatingTimer(node, timerName);
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
};
|
|
2883
|
+
},
|
|
2884
|
+
defaultOptions: [],
|
|
2885
|
+
meta: {
|
|
2886
|
+
docs: {
|
|
2887
|
+
description: "require timer handles to be retained so they can be cleared during cleanup.",
|
|
2888
|
+
recommended: true,
|
|
2889
|
+
requiresTypeChecking: false,
|
|
2890
|
+
runtimeCleanupConfigs: [
|
|
2891
|
+
"runtime-cleanup.configs.recommended",
|
|
2892
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
2893
|
+
"runtime-cleanup.configs.strict",
|
|
2894
|
+
"runtime-cleanup.configs.all"
|
|
2895
|
+
],
|
|
2896
|
+
url: createRuleDocsUrl("no-floating-timers")
|
|
2897
|
+
},
|
|
2898
|
+
messages: {
|
|
2899
|
+
floatingTimer: "Store or return the {{timerName}} handle so it can be cleared during cleanup."
|
|
2900
|
+
},
|
|
2901
|
+
schema: [],
|
|
2902
|
+
type: "problem"
|
|
2903
|
+
},
|
|
2904
|
+
name: "no-floating-timers"
|
|
2905
|
+
});
|
|
2906
|
+
var no_floating_timers_default = noFloatingTimers;
|
|
2907
|
+
|
|
2908
|
+
// dist/rules/no-floating-wake-locks.js
|
|
2909
|
+
var import_utils20 = require("@typescript-eslint/utils");
|
|
2910
|
+
var wakeLockRequestFunctionName = "request";
|
|
2911
|
+
var globalNavigatorReceiverNames3 = ["globalThis", "window"];
|
|
2912
|
+
var globalNavigatorReceiverNameSet3 = new Set(globalNavigatorReceiverNames3);
|
|
2913
|
+
var getTransparentWrappedExpression15 = (node) => {
|
|
2914
|
+
if (node.type === import_utils20.AST_NODE_TYPES.AwaitExpression) {
|
|
2915
|
+
return node.argument;
|
|
2916
|
+
}
|
|
2917
|
+
if (node.type === import_utils20.AST_NODE_TYPES.ChainExpression) {
|
|
2918
|
+
return node.expression;
|
|
2919
|
+
}
|
|
2920
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSAsExpression) {
|
|
2921
|
+
return node.expression;
|
|
2922
|
+
}
|
|
2923
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSNonNullExpression) {
|
|
2924
|
+
return node.expression;
|
|
2925
|
+
}
|
|
2926
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
2927
|
+
return node.expression;
|
|
2928
|
+
}
|
|
2929
|
+
if (node.type === import_utils20.AST_NODE_TYPES.TSTypeAssertion) {
|
|
2930
|
+
return node.expression;
|
|
2931
|
+
}
|
|
2932
|
+
return void 0;
|
|
2933
|
+
};
|
|
2934
|
+
var getStaticPropertyName13 = (node, computed) => {
|
|
2935
|
+
if (!computed && node.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2936
|
+
return node.name;
|
|
2937
|
+
}
|
|
2938
|
+
if (computed && node.type === import_utils20.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
2939
|
+
return node.value;
|
|
2940
|
+
}
|
|
2941
|
+
return void 0;
|
|
2942
|
+
};
|
|
2943
|
+
var collectStaticMemberPath4 = (node) => {
|
|
2944
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2945
|
+
return [node.name];
|
|
2946
|
+
}
|
|
2947
|
+
if (node.type !== import_utils20.AST_NODE_TYPES.MemberExpression || node.optional) {
|
|
2948
|
+
return void 0;
|
|
2949
|
+
}
|
|
2950
|
+
const objectPath = collectStaticMemberPath4(node.object);
|
|
2951
|
+
const propertyName = getStaticPropertyName13(node.property, node.computed);
|
|
2952
|
+
return objectPath === void 0 || propertyName === void 0 ? void 0 : [...objectPath, propertyName];
|
|
2953
|
+
};
|
|
2954
|
+
var isShadowedNavigatorIdentifier3 = (context, identifier) => {
|
|
2955
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
2956
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2957
|
+
return variable !== null && variable.defs.length > 0;
|
|
2958
|
+
};
|
|
2959
|
+
var getRootIdentifier4 = (node) => {
|
|
2960
|
+
if (node.type === import_utils20.AST_NODE_TYPES.Identifier) {
|
|
2961
|
+
return node;
|
|
2962
|
+
}
|
|
2963
|
+
return node.type === import_utils20.AST_NODE_TYPES.MemberExpression ? getRootIdentifier4(node.object) : void 0;
|
|
2964
|
+
};
|
|
2965
|
+
var isNavigatorPathShadowed3 = (context, callee) => {
|
|
2966
|
+
if (callee.type !== import_utils20.AST_NODE_TYPES.MemberExpression) {
|
|
2967
|
+
return false;
|
|
2968
|
+
}
|
|
2969
|
+
const rootIdentifier = getRootIdentifier4(callee.object);
|
|
2970
|
+
return rootIdentifier?.name === "navigator" && isShadowedNavigatorIdentifier3(context, rootIdentifier);
|
|
2971
|
+
};
|
|
2972
|
+
var isWakeLockRequestPath = (path) => path.length === 3 && path[0] === "navigator" && path[1] === "wakeLock" && path[2] === wakeLockRequestFunctionName || path.length === 4 && globalNavigatorReceiverNameSet3.has(path[0] ?? "") && path[1] === "navigator" && path[2] === "wakeLock" && path[3] === wakeLockRequestFunctionName;
|
|
2973
|
+
var isWakeLockRequestCall = (context, callee) => {
|
|
2974
|
+
if (callee.type !== import_utils20.AST_NODE_TYPES.MemberExpression || isNavigatorPathShadowed3(context, callee)) {
|
|
2975
|
+
return false;
|
|
2976
|
+
}
|
|
2977
|
+
const path = collectStaticMemberPath4(callee);
|
|
2978
|
+
return path !== void 0 && isWakeLockRequestPath(path);
|
|
2979
|
+
};
|
|
2980
|
+
var isDiscardedWakeLockRequest = (node) => {
|
|
2981
|
+
let current = node;
|
|
2982
|
+
let parent = getParentNode(current);
|
|
2983
|
+
while (parent !== void 0) {
|
|
2984
|
+
const wrappedExpression = getTransparentWrappedExpression15(parent);
|
|
2985
|
+
if (wrappedExpression === current) {
|
|
2986
|
+
current = parent;
|
|
2987
|
+
parent = getParentNode(current);
|
|
2988
|
+
continue;
|
|
2989
|
+
}
|
|
2990
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2991
|
+
return true;
|
|
2992
|
+
}
|
|
2993
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2994
|
+
const unaryParent = getParentNode(parent);
|
|
2995
|
+
return unaryParent?.type === import_utils20.AST_NODE_TYPES.ExpressionStatement;
|
|
2996
|
+
}
|
|
2997
|
+
return false;
|
|
2998
|
+
}
|
|
2999
|
+
return false;
|
|
3000
|
+
};
|
|
3001
|
+
var noFloatingWakeLocks = createTypedRule({
|
|
3002
|
+
create(context) {
|
|
3003
|
+
return {
|
|
3004
|
+
CallExpression(node) {
|
|
3005
|
+
if (!isWakeLockRequestCall(context, node.callee) || !isDiscardedWakeLockRequest(node)) {
|
|
3006
|
+
return;
|
|
3007
|
+
}
|
|
3008
|
+
context.report({
|
|
3009
|
+
messageId: "floatingWakeLock",
|
|
3010
|
+
node
|
|
3011
|
+
});
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
},
|
|
3015
|
+
defaultOptions: [],
|
|
3016
|
+
meta: {
|
|
3017
|
+
docs: {
|
|
3018
|
+
description: "require WakeLockSentinel handles to be retained so they can be released.",
|
|
3019
|
+
recommended: true,
|
|
3020
|
+
requiresTypeChecking: false,
|
|
3021
|
+
runtimeCleanupConfigs: [
|
|
3022
|
+
"runtime-cleanup.configs.recommended",
|
|
3023
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
3024
|
+
"runtime-cleanup.configs.strict",
|
|
3025
|
+
"runtime-cleanup.configs.all"
|
|
3026
|
+
],
|
|
3027
|
+
url: createRuleDocsUrl("no-floating-wake-locks")
|
|
3028
|
+
},
|
|
3029
|
+
messages: {
|
|
3030
|
+
floatingWakeLock: "Store or return the WakeLockSentinel so release() can release the wake lock during cleanup."
|
|
3031
|
+
},
|
|
3032
|
+
schema: [],
|
|
3033
|
+
type: "problem"
|
|
3034
|
+
},
|
|
3035
|
+
name: "no-floating-wake-locks"
|
|
3036
|
+
});
|
|
3037
|
+
var no_floating_wake_locks_default = noFloatingWakeLocks;
|
|
3038
|
+
|
|
3039
|
+
// dist/rules/no-floating-web-stream-locks.js
|
|
3040
|
+
var import_utils21 = require("@typescript-eslint/utils");
|
|
3041
|
+
var lockFactoryNames = ["getReader", "getWriter"];
|
|
3042
|
+
var cleanupMemberNames2 = /* @__PURE__ */ new Set(["releaseLock"]);
|
|
3043
|
+
var lockFactoryMetadataByName = {
|
|
3044
|
+
getReader: {
|
|
3045
|
+
lockKind: "reader",
|
|
3046
|
+
streamTypeName: "ReadableStream"
|
|
3047
|
+
},
|
|
3048
|
+
getWriter: {
|
|
3049
|
+
lockKind: "writer",
|
|
3050
|
+
streamTypeName: "WritableStream"
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
var lockFactoryNameSet = new Set(lockFactoryNames);
|
|
3054
|
+
var isLockFactoryName = (name) => lockFactoryNameSet.has(name);
|
|
3055
|
+
var getLockFactoryMetadata = (callee) => {
|
|
3056
|
+
if (callee.type !== import_utils21.AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
3057
|
+
return void 0;
|
|
3058
|
+
}
|
|
3059
|
+
if (callee.object.type === import_utils21.AST_NODE_TYPES.Super) {
|
|
3060
|
+
return void 0;
|
|
3061
|
+
}
|
|
3062
|
+
const factoryName = getStaticPropertyName2(callee.property, callee.computed);
|
|
3063
|
+
if (factoryName === void 0 || !isLockFactoryName(factoryName)) {
|
|
3064
|
+
return void 0;
|
|
3065
|
+
}
|
|
3066
|
+
return {
|
|
3067
|
+
...lockFactoryMetadataByName[factoryName],
|
|
3068
|
+
receiver: callee.object
|
|
3069
|
+
};
|
|
3070
|
+
};
|
|
3071
|
+
var isReceiverExpectedWebStream = (context, receiver, streamTypeName) => {
|
|
3072
|
+
const { checker, parserServices } = getTypedRuleServices(context);
|
|
3073
|
+
const receiverType = checker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(receiver));
|
|
3074
|
+
return hasTypeNameInHierarchy(checker, receiverType, streamTypeName);
|
|
3075
|
+
};
|
|
3076
|
+
var noFloatingWebStreamLocks = createTypedRule({
|
|
3077
|
+
create(context) {
|
|
3078
|
+
return {
|
|
3079
|
+
CallExpression(node) {
|
|
3080
|
+
const metadata = getLockFactoryMetadata(node.callee);
|
|
3081
|
+
if (metadata === void 0 || !isReceiverExpectedWebStream(context, metadata.receiver, metadata.streamTypeName) || !isDiscardedResourceExpression(node) && !isImmediateUnownedMemberReceiver(node, cleanupMemberNames2)) {
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3084
|
+
context.report({
|
|
3085
|
+
data: { lockKind: metadata.lockKind },
|
|
3086
|
+
messageId: "floatingWebStreamLock",
|
|
3087
|
+
node
|
|
3088
|
+
});
|
|
3089
|
+
}
|
|
3090
|
+
};
|
|
3091
|
+
},
|
|
3092
|
+
defaultOptions: [],
|
|
3093
|
+
meta: {
|
|
3094
|
+
docs: {
|
|
3095
|
+
description: "require Web Stream readers and writers to be retained so their locks can be released.",
|
|
3096
|
+
recommended: true,
|
|
3097
|
+
requiresTypeChecking: true,
|
|
3098
|
+
runtimeCleanupConfigs: [
|
|
3099
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
3100
|
+
"runtime-cleanup.configs.strict",
|
|
3101
|
+
"runtime-cleanup.configs.all"
|
|
3102
|
+
],
|
|
3103
|
+
url: createRuleDocsUrl("no-floating-web-stream-locks")
|
|
3104
|
+
},
|
|
3105
|
+
messages: {
|
|
3106
|
+
floatingWebStreamLock: "Store or return the Web Stream {{lockKind}} so releaseLock() can release the stream lock during cleanup."
|
|
3107
|
+
},
|
|
3108
|
+
schema: [],
|
|
3109
|
+
type: "problem"
|
|
3110
|
+
},
|
|
3111
|
+
name: "no-floating-web-stream-locks"
|
|
3112
|
+
});
|
|
3113
|
+
var no_floating_web_stream_locks_default = noFloatingWebStreamLocks;
|
|
3114
|
+
|
|
3115
|
+
// dist/rules/no-floating-workers.js
|
|
3116
|
+
var import_utils22 = require("@typescript-eslint/utils");
|
|
3117
|
+
var browserWorkerConstructorNames = [
|
|
3118
|
+
"SharedWorker",
|
|
3119
|
+
"Worker"
|
|
3120
|
+
];
|
|
3121
|
+
var globalReceiverNames9 = [
|
|
3122
|
+
"globalThis",
|
|
3123
|
+
"self",
|
|
3124
|
+
"window"
|
|
3125
|
+
];
|
|
3126
|
+
var workerThreadsModuleNames = [
|
|
3127
|
+
"node:worker_threads",
|
|
3128
|
+
"worker_threads"
|
|
3129
|
+
];
|
|
3130
|
+
var browserWorkerConstructorNameSet = new Set(browserWorkerConstructorNames);
|
|
3131
|
+
var globalReceiverNameSet9 = new Set(globalReceiverNames9);
|
|
3132
|
+
var workerThreadsModuleNameSet = new Set(workerThreadsModuleNames);
|
|
3133
|
+
var isBrowserWorkerConstructorName = (name) => browserWorkerConstructorNameSet.has(name);
|
|
3134
|
+
var isGlobalReceiverName8 = (name) => globalReceiverNameSet9.has(name);
|
|
3135
|
+
var getTransparentWrappedExpression16 = (node) => {
|
|
3136
|
+
if (node.type === import_utils22.AST_NODE_TYPES.ChainExpression) {
|
|
3137
|
+
return node.expression;
|
|
3138
|
+
}
|
|
3139
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSAsExpression) {
|
|
3140
|
+
return node.expression;
|
|
3141
|
+
}
|
|
3142
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSNonNullExpression) {
|
|
3143
|
+
return node.expression;
|
|
3144
|
+
}
|
|
3145
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
3146
|
+
return node.expression;
|
|
3147
|
+
}
|
|
3148
|
+
if (node.type === import_utils22.AST_NODE_TYPES.TSTypeAssertion) {
|
|
3149
|
+
return node.expression;
|
|
3150
|
+
}
|
|
3151
|
+
return void 0;
|
|
3152
|
+
};
|
|
3153
|
+
var getImportSourceValue5 = (node) => {
|
|
3154
|
+
const parent = getParentNode(node);
|
|
3155
|
+
if (parent?.type === import_utils22.AST_NODE_TYPES.ImportDeclaration && typeof parent.source.value === "string") {
|
|
3156
|
+
return parent.source.value;
|
|
3157
|
+
}
|
|
3158
|
+
return void 0;
|
|
3159
|
+
};
|
|
3160
|
+
var isWorkerThreadsImportBinding = (context, identifier) => {
|
|
3161
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
3162
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
3163
|
+
const definition = variable?.defs[0];
|
|
3164
|
+
const importSource = definition === void 0 ? void 0 : getImportSourceValue5(definition.node);
|
|
3165
|
+
return identifier.name === "Worker" && importSource !== void 0 && workerThreadsModuleNameSet.has(importSource);
|
|
3166
|
+
};
|
|
3167
|
+
var isShadowedBrowserWorkerIdentifier = (context, identifier) => {
|
|
3168
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
3169
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
3170
|
+
return variable !== null && variable.defs.length > 0;
|
|
3171
|
+
};
|
|
3172
|
+
var getDirectWorkerConstructorName = (context, callee) => {
|
|
3173
|
+
if (callee.type !== import_utils22.AST_NODE_TYPES.Identifier || !isBrowserWorkerConstructorName(callee.name)) {
|
|
3174
|
+
return void 0;
|
|
3175
|
+
}
|
|
3176
|
+
if (isWorkerThreadsImportBinding(context, callee)) {
|
|
3177
|
+
return "Worker";
|
|
3178
|
+
}
|
|
3179
|
+
return isShadowedBrowserWorkerIdentifier(context, callee) ? void 0 : callee.name;
|
|
3180
|
+
};
|
|
3181
|
+
var getMemberWorkerConstructorName = (callee) => {
|
|
3182
|
+
if (callee.type !== import_utils22.AST_NODE_TYPES.MemberExpression || callee.computed || callee.optional || callee.object.type !== import_utils22.AST_NODE_TYPES.Identifier || callee.property.type !== import_utils22.AST_NODE_TYPES.Identifier || !isGlobalReceiverName8(callee.object.name) || !isBrowserWorkerConstructorName(callee.property.name)) {
|
|
3183
|
+
return void 0;
|
|
3184
|
+
}
|
|
3185
|
+
return callee.property.name;
|
|
3186
|
+
};
|
|
3187
|
+
var getWorkerConstructorName = (context, callee) => getDirectWorkerConstructorName(context, callee) ?? getMemberWorkerConstructorName(callee);
|
|
3188
|
+
var isDiscardedWorkerInstance = (node) => {
|
|
3189
|
+
let current = node;
|
|
3190
|
+
let parent = getParentNode(current);
|
|
3191
|
+
while (parent !== void 0) {
|
|
3192
|
+
const wrappedExpression = getTransparentWrappedExpression16(parent);
|
|
3193
|
+
if (wrappedExpression === current) {
|
|
3194
|
+
current = parent;
|
|
3195
|
+
parent = getParentNode(current);
|
|
3196
|
+
continue;
|
|
3197
|
+
}
|
|
3198
|
+
if (parent.type === import_utils22.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
3199
|
+
return true;
|
|
3200
|
+
}
|
|
3201
|
+
if (parent.type === import_utils22.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
3202
|
+
const unaryParent = getParentNode(parent);
|
|
3203
|
+
return unaryParent?.type === import_utils22.AST_NODE_TYPES.ExpressionStatement;
|
|
3204
|
+
}
|
|
3205
|
+
return false;
|
|
3206
|
+
}
|
|
3207
|
+
return false;
|
|
3208
|
+
};
|
|
3209
|
+
var isImmediateWorkerMethodReceiver = (node) => {
|
|
3210
|
+
let current = node;
|
|
3211
|
+
let parent = getParentNode(current);
|
|
3212
|
+
while (parent !== void 0) {
|
|
3213
|
+
const wrappedExpression = getTransparentWrappedExpression16(parent);
|
|
3214
|
+
if (wrappedExpression === current) {
|
|
3215
|
+
current = parent;
|
|
3216
|
+
parent = getParentNode(current);
|
|
3217
|
+
continue;
|
|
3218
|
+
}
|
|
3219
|
+
if (parent.type !== import_utils22.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.computed || parent.property.type !== import_utils22.AST_NODE_TYPES.Identifier || parent.property.name === "terminate") {
|
|
3220
|
+
return false;
|
|
3221
|
+
}
|
|
3222
|
+
const callExpression = getParentNode(parent);
|
|
3223
|
+
return callExpression?.type === import_utils22.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
3224
|
+
}
|
|
3225
|
+
return false;
|
|
3226
|
+
};
|
|
3227
|
+
var noFloatingWorkers = createTypedRule({
|
|
3228
|
+
create(context) {
|
|
3229
|
+
return {
|
|
3230
|
+
NewExpression(node) {
|
|
3231
|
+
const workerName = getWorkerConstructorName(context, node.callee);
|
|
3232
|
+
if (workerName === void 0 || !isDiscardedWorkerInstance(node) && !isImmediateWorkerMethodReceiver(node)) {
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3235
|
+
context.report({
|
|
3236
|
+
data: { workerName },
|
|
3237
|
+
messageId: "floatingWorker",
|
|
3238
|
+
node
|
|
3239
|
+
});
|
|
3240
|
+
}
|
|
3241
|
+
};
|
|
3242
|
+
},
|
|
3243
|
+
defaultOptions: [],
|
|
3244
|
+
meta: {
|
|
3245
|
+
docs: {
|
|
3246
|
+
description: "require worker handles to be retained so they can be terminated during cleanup.",
|
|
3247
|
+
recommended: true,
|
|
3248
|
+
requiresTypeChecking: false,
|
|
3249
|
+
runtimeCleanupConfigs: [
|
|
3250
|
+
"runtime-cleanup.configs.recommended",
|
|
3251
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
3252
|
+
"runtime-cleanup.configs.strict",
|
|
3253
|
+
"runtime-cleanup.configs.all"
|
|
3254
|
+
],
|
|
3255
|
+
url: createRuleDocsUrl("no-floating-workers")
|
|
3256
|
+
},
|
|
3257
|
+
messages: {
|
|
3258
|
+
floatingWorker: "Store or return the {{workerName}} handle so it can be terminated during cleanup."
|
|
3259
|
+
},
|
|
3260
|
+
schema: [],
|
|
3261
|
+
type: "problem"
|
|
3262
|
+
},
|
|
3263
|
+
name: "no-floating-workers"
|
|
3264
|
+
});
|
|
3265
|
+
var no_floating_workers_default = noFloatingWorkers;
|
|
3266
|
+
|
|
3267
|
+
// dist/rules/no-unmanaged-event-listeners.js
|
|
3268
|
+
var import_utils23 = require("@typescript-eslint/utils");
|
|
3269
|
+
var unknownCaptureKey = "*";
|
|
3270
|
+
var isCleanupBoundary = (node) => node.type === import_utils23.AST_NODE_TYPES.Program || node.type === import_utils23.AST_NODE_TYPES.FunctionDeclaration || node.type === import_utils23.AST_NODE_TYPES.FunctionExpression || node.type === import_utils23.AST_NODE_TYPES.ArrowFunctionExpression;
|
|
3271
|
+
var getCleanupBoundary = (node) => {
|
|
3272
|
+
let current = node;
|
|
3273
|
+
while (current !== void 0) {
|
|
3274
|
+
if (isCleanupBoundary(current)) {
|
|
3275
|
+
return current;
|
|
3276
|
+
}
|
|
3277
|
+
current = getParentNode(current);
|
|
3278
|
+
}
|
|
3279
|
+
throw new TypeError("Expected an addEventListener call to have a program.");
|
|
3280
|
+
};
|
|
3281
|
+
var getStaticPropertyName14 = (property) => {
|
|
3282
|
+
if (property.type === import_utils23.AST_NODE_TYPES.Identifier) {
|
|
3283
|
+
return property.name;
|
|
3284
|
+
}
|
|
3285
|
+
if (property.type === import_utils23.AST_NODE_TYPES.Literal && typeof property.value === "string") {
|
|
3286
|
+
return property.value;
|
|
3287
|
+
}
|
|
3288
|
+
return void 0;
|
|
3289
|
+
};
|
|
3290
|
+
var isMethodCallNamed = (callee, methodName) => callee.type === import_utils23.AST_NODE_TYPES.MemberExpression && !callee.computed && callee.property.type === import_utils23.AST_NODE_TYPES.Identifier && callee.property.name === methodName;
|
|
3291
|
+
var isUnknownRecord = (value) => typeof value === "object" && value !== null;
|
|
3292
|
+
var isVariableDeclarator = (node) => isUnknownRecord(node) && node["type"] === import_utils23.AST_NODE_TYPES.VariableDeclarator;
|
|
3293
|
+
var getVariableInitializer = (context, identifier) => {
|
|
3294
|
+
const scope = context.sourceCode.getScope(identifier);
|
|
3295
|
+
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
3296
|
+
const definition = variable?.defs[0];
|
|
3297
|
+
const definitionNode = definition?.node;
|
|
3298
|
+
if (!isVariableDeclarator(definitionNode)) {
|
|
3299
|
+
return void 0;
|
|
3300
|
+
}
|
|
3301
|
+
return definitionNode.init ?? void 0;
|
|
3302
|
+
};
|
|
3303
|
+
var resolveOptionsExpression = (context, argument) => {
|
|
3304
|
+
if (argument.type === import_utils23.AST_NODE_TYPES.SpreadElement) {
|
|
3305
|
+
return void 0;
|
|
3306
|
+
}
|
|
3307
|
+
if (argument.type === import_utils23.AST_NODE_TYPES.Identifier) {
|
|
3308
|
+
return getVariableInitializer(context, argument);
|
|
3309
|
+
}
|
|
3310
|
+
return argument;
|
|
3311
|
+
};
|
|
3312
|
+
var objectExpressionHasProperty = (objectExpression, propertyName) => objectExpression.properties.some((property) => {
|
|
3313
|
+
if (property.type === import_utils23.AST_NODE_TYPES.SpreadElement) {
|
|
3314
|
+
return true;
|
|
3315
|
+
}
|
|
3316
|
+
return getStaticPropertyName14(property.key) === propertyName;
|
|
3317
|
+
});
|
|
3318
|
+
var getBooleanPropertyValue = (objectExpression, propertyName) => {
|
|
3319
|
+
for (const property of objectExpression.properties) {
|
|
3320
|
+
if (property.type === import_utils23.AST_NODE_TYPES.Property && getStaticPropertyName14(property.key) === propertyName && property.value.type === import_utils23.AST_NODE_TYPES.Literal && typeof property.value.value === "boolean") {
|
|
3321
|
+
return property.value.value;
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
return void 0;
|
|
3325
|
+
};
|
|
3326
|
+
var hasAbortSignalOption = (context, argument) => {
|
|
3327
|
+
if (argument === void 0) {
|
|
3328
|
+
return false;
|
|
3329
|
+
}
|
|
3330
|
+
const resolvedOptions = resolveOptionsExpression(context, argument);
|
|
3331
|
+
return resolvedOptions?.type === import_utils23.AST_NODE_TYPES.ObjectExpression && objectExpressionHasProperty(resolvedOptions, "signal");
|
|
3332
|
+
};
|
|
3333
|
+
var getCaptureKey = (context, argument) => {
|
|
3334
|
+
if (argument === void 0) {
|
|
3335
|
+
return "false";
|
|
3336
|
+
}
|
|
3337
|
+
const resolvedOptions = resolveOptionsExpression(context, argument);
|
|
3338
|
+
if (resolvedOptions === void 0) {
|
|
3339
|
+
return unknownCaptureKey;
|
|
3340
|
+
}
|
|
3341
|
+
if (resolvedOptions.type === import_utils23.AST_NODE_TYPES.Literal && typeof resolvedOptions.value === "boolean") {
|
|
3342
|
+
return String(resolvedOptions.value);
|
|
3343
|
+
}
|
|
3344
|
+
if (resolvedOptions.type === import_utils23.AST_NODE_TYPES.ObjectExpression) {
|
|
3345
|
+
const captureValue = getBooleanPropertyValue(resolvedOptions, "capture");
|
|
3346
|
+
return captureValue === void 0 ? "false" : String(captureValue);
|
|
3347
|
+
}
|
|
3348
|
+
return unknownCaptureKey;
|
|
3349
|
+
};
|
|
3350
|
+
var getCleanupKey = (context, node) => {
|
|
3351
|
+
if (node.arguments.length < 2 || node.callee.type !== import_utils23.AST_NODE_TYPES.MemberExpression) {
|
|
3352
|
+
return void 0;
|
|
3353
|
+
}
|
|
3354
|
+
const [eventType, listener, options] = node.arguments;
|
|
3355
|
+
if (eventType === void 0 || listener === void 0 || eventType.type === import_utils23.AST_NODE_TYPES.SpreadElement || listener.type === import_utils23.AST_NODE_TYPES.SpreadElement) {
|
|
3356
|
+
return void 0;
|
|
3357
|
+
}
|
|
3358
|
+
const targetText = context.sourceCode.getText(node.callee.object);
|
|
3359
|
+
const eventTypeText = context.sourceCode.getText(eventType);
|
|
3360
|
+
const listenerText = context.sourceCode.getText(listener);
|
|
3361
|
+
const captureKey = getCaptureKey(context, options);
|
|
3362
|
+
return `${targetText}\0${eventTypeText}\0${listenerText}\0${captureKey}`;
|
|
3363
|
+
};
|
|
3364
|
+
var getWildcardCleanupKey = (cleanupKey) => {
|
|
3365
|
+
const [targetText, eventTypeText, listenerText] = cleanupKey.split("\0", 3);
|
|
3366
|
+
if (targetText === void 0 || eventTypeText === void 0 || listenerText === void 0) {
|
|
3367
|
+
throw new TypeError("Expected a complete event listener cleanup key.");
|
|
3368
|
+
}
|
|
3369
|
+
return `${targetText}\0${eventTypeText}\0${listenerText}\0${unknownCaptureKey}`;
|
|
3370
|
+
};
|
|
3371
|
+
var noUnmanagedEventListeners = createTypedRule({
|
|
3372
|
+
create(context) {
|
|
3373
|
+
const addsByBoundary = /* @__PURE__ */ new Map();
|
|
3374
|
+
const removesByBoundary = /* @__PURE__ */ new Map();
|
|
3375
|
+
const addRecord = (boundary, record) => {
|
|
3376
|
+
const records = addsByBoundary.get(boundary);
|
|
3377
|
+
if (records === void 0) {
|
|
3378
|
+
addsByBoundary.set(boundary, [record]);
|
|
3379
|
+
return;
|
|
3380
|
+
}
|
|
3381
|
+
records.push(record);
|
|
3382
|
+
};
|
|
3383
|
+
const addRemoveKey = (boundary, cleanupKey) => {
|
|
3384
|
+
const cleanupKeys = removesByBoundary.get(boundary);
|
|
3385
|
+
if (cleanupKeys === void 0) {
|
|
3386
|
+
removesByBoundary.set(boundary, /* @__PURE__ */ new Set([cleanupKey]));
|
|
3387
|
+
return;
|
|
3388
|
+
}
|
|
3389
|
+
cleanupKeys.add(cleanupKey);
|
|
3390
|
+
};
|
|
3391
|
+
return {
|
|
3392
|
+
'CallExpression[callee.type="MemberExpression"]'(node) {
|
|
3393
|
+
if (isMethodCallNamed(node.callee, "addEventListener") && !hasAbortSignalOption(context, node.arguments[2])) {
|
|
3394
|
+
const cleanupKey = getCleanupKey(context, node);
|
|
3395
|
+
if (cleanupKey !== void 0) {
|
|
3396
|
+
addRecord(getCleanupBoundary(node), {
|
|
3397
|
+
cleanupKey,
|
|
3398
|
+
node
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
if (isMethodCallNamed(node.callee, "removeEventListener")) {
|
|
3403
|
+
const cleanupKey = getCleanupKey(context, node);
|
|
3404
|
+
if (cleanupKey !== void 0) {
|
|
3405
|
+
addRemoveKey(getCleanupBoundary(node), cleanupKey);
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
},
|
|
3409
|
+
"Program:exit"() {
|
|
3410
|
+
for (const [boundary, addRecords] of addsByBoundary) {
|
|
3411
|
+
const removeKeys = removesByBoundary.get(boundary) ?? /* @__PURE__ */ new Set();
|
|
3412
|
+
for (const { cleanupKey, node } of addRecords) {
|
|
3413
|
+
if (removeKeys.has(cleanupKey) || removeKeys.has(getWildcardCleanupKey(cleanupKey))) {
|
|
3414
|
+
continue;
|
|
3415
|
+
}
|
|
3416
|
+
context.report({
|
|
3417
|
+
messageId: "unmanagedEventListener",
|
|
3418
|
+
node
|
|
3419
|
+
});
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
};
|
|
3424
|
+
},
|
|
3425
|
+
defaultOptions: [],
|
|
3426
|
+
meta: {
|
|
3427
|
+
docs: {
|
|
3428
|
+
description: "require event listeners to have an abort signal or a matching cleanup call.",
|
|
3429
|
+
recommended: true,
|
|
3430
|
+
requiresTypeChecking: false,
|
|
3431
|
+
runtimeCleanupConfigs: [
|
|
3432
|
+
"runtime-cleanup.configs.recommended",
|
|
3433
|
+
"runtime-cleanup.configs.recommended-type-checked",
|
|
3434
|
+
"runtime-cleanup.configs.strict",
|
|
3435
|
+
"runtime-cleanup.configs.all"
|
|
3436
|
+
],
|
|
3437
|
+
url: createRuleDocsUrl("no-unmanaged-event-listeners")
|
|
3438
|
+
},
|
|
3439
|
+
messages: {
|
|
3440
|
+
unmanagedEventListener: "Add an AbortSignal option or a matching removeEventListener call for this listener."
|
|
3441
|
+
},
|
|
3442
|
+
schema: [],
|
|
3443
|
+
type: "problem"
|
|
3444
|
+
},
|
|
3445
|
+
name: "no-unmanaged-event-listeners"
|
|
3446
|
+
});
|
|
3447
|
+
var no_unmanaged_event_listeners_default = noUnmanagedEventListeners;
|
|
3448
|
+
|
|
3449
|
+
// dist/_internal/rules-registry.js
|
|
3450
|
+
var runtimeCleanupRuleRegistry = {
|
|
3451
|
+
"no-floating-abort-controllers": no_floating_abort_controllers_default,
|
|
3452
|
+
"no-floating-audio-contexts": no_floating_audio_contexts_default,
|
|
3453
|
+
"no-floating-broadcast-channels": no_floating_broadcast_channels_default,
|
|
3454
|
+
"no-floating-child-processes": no_floating_child_processes_default,
|
|
3455
|
+
"no-floating-disposable-stacks": no_floating_disposable_stacks_default,
|
|
3456
|
+
"no-floating-file-watchers": no_floating_file_watchers_default,
|
|
3457
|
+
"no-floating-geolocation-watches": no_floating_geolocation_watches_default,
|
|
3458
|
+
"no-floating-infinite-animations": no_floating_infinite_animations_default,
|
|
3459
|
+
"no-floating-media-streams": no_floating_media_streams_default,
|
|
3460
|
+
"no-floating-message-channels": no_floating_message_channels_default,
|
|
3461
|
+
"no-floating-network-connections": no_floating_network_connections_default,
|
|
3462
|
+
"no-floating-object-urls": no_floating_object_urls_default,
|
|
3463
|
+
"no-floating-observers": no_floating_observers_default,
|
|
3464
|
+
"no-floating-servers": no_floating_servers_default,
|
|
3465
|
+
"no-floating-streams": no_floating_streams_default,
|
|
3466
|
+
"no-floating-timers": no_floating_timers_default,
|
|
3467
|
+
"no-floating-wake-locks": no_floating_wake_locks_default,
|
|
3468
|
+
"no-floating-web-stream-locks": no_floating_web_stream_locks_default,
|
|
3469
|
+
"no-floating-workers": no_floating_workers_default,
|
|
3470
|
+
"no-unmanaged-event-listeners": no_unmanaged_event_listeners_default
|
|
3471
|
+
};
|
|
3472
|
+
var runtimeCleanupRules = runtimeCleanupRuleRegistry;
|
|
3473
|
+
|
|
3474
|
+
// dist/_internal/runtime-cleanup-config-references.js
|
|
3475
|
+
var runtimeCleanupConfigNames = [
|
|
3476
|
+
"all",
|
|
3477
|
+
"experimental",
|
|
3478
|
+
"minimal",
|
|
3479
|
+
"recommended",
|
|
3480
|
+
"recommended-type-checked",
|
|
3481
|
+
"strict"
|
|
3482
|
+
];
|
|
3483
|
+
var runtimeCleanupConfigMetadataByName = {
|
|
3484
|
+
all: {
|
|
3485
|
+
icon: "A",
|
|
3486
|
+
presetName: "runtime-cleanup:all",
|
|
3487
|
+
readmeOrder: 5,
|
|
3488
|
+
requiresTypeChecking: true
|
|
3489
|
+
},
|
|
3490
|
+
experimental: {
|
|
3491
|
+
icon: "E",
|
|
3492
|
+
presetName: "runtime-cleanup:experimental",
|
|
3493
|
+
readmeOrder: 6,
|
|
3494
|
+
requiresTypeChecking: false
|
|
3495
|
+
},
|
|
3496
|
+
minimal: {
|
|
3497
|
+
icon: "M",
|
|
3498
|
+
presetName: "runtime-cleanup:minimal",
|
|
3499
|
+
readmeOrder: 1,
|
|
3500
|
+
requiresTypeChecking: false
|
|
3501
|
+
},
|
|
3502
|
+
recommended: {
|
|
3503
|
+
icon: "R",
|
|
3504
|
+
presetName: "runtime-cleanup:recommended",
|
|
3505
|
+
readmeOrder: 2,
|
|
3506
|
+
requiresTypeChecking: false
|
|
3507
|
+
},
|
|
3508
|
+
"recommended-type-checked": {
|
|
3509
|
+
icon: "T",
|
|
3510
|
+
presetName: "runtime-cleanup:recommended-type-checked",
|
|
3511
|
+
readmeOrder: 3,
|
|
3512
|
+
requiresTypeChecking: true
|
|
3513
|
+
},
|
|
3514
|
+
strict: {
|
|
3515
|
+
icon: "S",
|
|
3516
|
+
presetName: "runtime-cleanup:strict",
|
|
3517
|
+
readmeOrder: 4,
|
|
3518
|
+
requiresTypeChecking: true
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3521
|
+
|
|
3522
|
+
// dist/plugin.js
|
|
3523
|
+
var TYPE_SCRIPT_FILES = ["**/*.{ts,tsx,mts,cts}"];
|
|
3524
|
+
function getPackageVersion(pkg) {
|
|
3525
|
+
if (typeof pkg !== "object" || pkg === null) {
|
|
3526
|
+
return "0.0.0";
|
|
3527
|
+
}
|
|
3528
|
+
const version = Reflect.get(pkg, "version");
|
|
3529
|
+
return typeof version === "string" ? version : "0.0.0";
|
|
3530
|
+
}
|
|
3531
|
+
var typeScriptParserValue = import_parser.default;
|
|
3532
|
+
var defaultParserOptions = {
|
|
3533
|
+
ecmaVersion: "latest",
|
|
3534
|
+
sourceType: "module"
|
|
3535
|
+
};
|
|
3536
|
+
var normalizeParserOptions = (parserOptions) => parserOptions !== null && typeof parserOptions === "object" && !Array.isArray(parserOptions) ? { ...parserOptions } : { ...defaultParserOptions };
|
|
3537
|
+
var runtimeCleanupEslintRules = (
|
|
3538
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Internal registry is intentionally narrowed to ESLint's plugin rule map contract.
|
|
3539
|
+
runtimeCleanupRules
|
|
3540
|
+
);
|
|
3541
|
+
function errorRulesFor(ruleNames) {
|
|
3542
|
+
const rules = {};
|
|
3543
|
+
for (const ruleName of ruleNames) {
|
|
3544
|
+
rules[`runtime-cleanup/${ruleName}`] = "error";
|
|
3545
|
+
}
|
|
3546
|
+
return rules;
|
|
3547
|
+
}
|
|
3548
|
+
var effectivePresetRuleNamesByConfig = {
|
|
3549
|
+
all: [
|
|
3550
|
+
"no-floating-abort-controllers",
|
|
3551
|
+
"no-floating-audio-contexts",
|
|
3552
|
+
"no-floating-broadcast-channels",
|
|
3553
|
+
"no-floating-child-processes",
|
|
3554
|
+
"no-floating-disposable-stacks",
|
|
3555
|
+
"no-floating-file-watchers",
|
|
3556
|
+
"no-floating-geolocation-watches",
|
|
3557
|
+
"no-floating-infinite-animations",
|
|
3558
|
+
"no-floating-media-streams",
|
|
3559
|
+
"no-floating-message-channels",
|
|
3560
|
+
"no-floating-network-connections",
|
|
3561
|
+
"no-floating-object-urls",
|
|
3562
|
+
"no-floating-observers",
|
|
3563
|
+
"no-floating-servers",
|
|
3564
|
+
"no-floating-streams",
|
|
3565
|
+
"no-floating-timers",
|
|
3566
|
+
"no-floating-wake-locks",
|
|
3567
|
+
"no-floating-web-stream-locks",
|
|
3568
|
+
"no-floating-workers",
|
|
3569
|
+
"no-unmanaged-event-listeners"
|
|
3570
|
+
],
|
|
3571
|
+
experimental: [],
|
|
3572
|
+
minimal: [],
|
|
3573
|
+
recommended: [
|
|
3574
|
+
"no-floating-abort-controllers",
|
|
3575
|
+
"no-floating-audio-contexts",
|
|
3576
|
+
"no-floating-broadcast-channels",
|
|
3577
|
+
"no-floating-child-processes",
|
|
3578
|
+
"no-floating-disposable-stacks",
|
|
3579
|
+
"no-floating-file-watchers",
|
|
3580
|
+
"no-floating-geolocation-watches",
|
|
3581
|
+
"no-floating-media-streams",
|
|
3582
|
+
"no-floating-message-channels",
|
|
3583
|
+
"no-floating-network-connections",
|
|
3584
|
+
"no-floating-object-urls",
|
|
3585
|
+
"no-floating-observers",
|
|
3586
|
+
"no-floating-servers",
|
|
3587
|
+
"no-floating-streams",
|
|
3588
|
+
"no-floating-timers",
|
|
3589
|
+
"no-floating-wake-locks",
|
|
3590
|
+
"no-floating-workers",
|
|
3591
|
+
"no-unmanaged-event-listeners"
|
|
3592
|
+
],
|
|
3593
|
+
"recommended-type-checked": [
|
|
3594
|
+
"no-floating-abort-controllers",
|
|
3595
|
+
"no-floating-audio-contexts",
|
|
3596
|
+
"no-floating-broadcast-channels",
|
|
3597
|
+
"no-floating-child-processes",
|
|
3598
|
+
"no-floating-disposable-stacks",
|
|
3599
|
+
"no-floating-file-watchers",
|
|
3600
|
+
"no-floating-geolocation-watches",
|
|
3601
|
+
"no-floating-infinite-animations",
|
|
3602
|
+
"no-floating-media-streams",
|
|
3603
|
+
"no-floating-message-channels",
|
|
3604
|
+
"no-floating-network-connections",
|
|
3605
|
+
"no-floating-object-urls",
|
|
3606
|
+
"no-floating-observers",
|
|
3607
|
+
"no-floating-servers",
|
|
3608
|
+
"no-floating-streams",
|
|
3609
|
+
"no-floating-timers",
|
|
3610
|
+
"no-floating-wake-locks",
|
|
3611
|
+
"no-floating-web-stream-locks",
|
|
3612
|
+
"no-floating-workers",
|
|
3613
|
+
"no-unmanaged-event-listeners"
|
|
3614
|
+
],
|
|
3615
|
+
strict: [
|
|
3616
|
+
"no-floating-abort-controllers",
|
|
3617
|
+
"no-floating-audio-contexts",
|
|
3618
|
+
"no-floating-broadcast-channels",
|
|
3619
|
+
"no-floating-child-processes",
|
|
3620
|
+
"no-floating-disposable-stacks",
|
|
3621
|
+
"no-floating-file-watchers",
|
|
3622
|
+
"no-floating-geolocation-watches",
|
|
3623
|
+
"no-floating-infinite-animations",
|
|
3624
|
+
"no-floating-media-streams",
|
|
3625
|
+
"no-floating-message-channels",
|
|
3626
|
+
"no-floating-network-connections",
|
|
3627
|
+
"no-floating-object-urls",
|
|
3628
|
+
"no-floating-observers",
|
|
3629
|
+
"no-floating-servers",
|
|
3630
|
+
"no-floating-streams",
|
|
3631
|
+
"no-floating-timers",
|
|
3632
|
+
"no-floating-wake-locks",
|
|
3633
|
+
"no-floating-web-stream-locks",
|
|
3634
|
+
"no-floating-workers",
|
|
3635
|
+
"no-unmanaged-event-listeners"
|
|
3636
|
+
]
|
|
3637
|
+
};
|
|
3638
|
+
function withRuntimeCleanupPlugin(config, plugin, options) {
|
|
3639
|
+
const existingLanguageOptions = config.languageOptions ?? {};
|
|
3640
|
+
const existingParserOptions = existingLanguageOptions["parserOptions"];
|
|
3641
|
+
const parserOptions = normalizeParserOptions(existingParserOptions);
|
|
3642
|
+
if (options.requiresTypeChecking && !Object.hasOwn(parserOptions, "projectService")) {
|
|
3643
|
+
Reflect.set(parserOptions, "projectService", true);
|
|
3644
|
+
}
|
|
3645
|
+
const languageOptions = {
|
|
3646
|
+
...existingLanguageOptions,
|
|
3647
|
+
parser: existingLanguageOptions["parser"] ?? typeScriptParserValue,
|
|
3648
|
+
parserOptions
|
|
3649
|
+
};
|
|
3650
|
+
return {
|
|
3651
|
+
...config,
|
|
3652
|
+
files: config.files ?? [...TYPE_SCRIPT_FILES],
|
|
3653
|
+
languageOptions,
|
|
3654
|
+
plugins: {
|
|
3655
|
+
...config.plugins,
|
|
3656
|
+
"runtime-cleanup": plugin
|
|
3657
|
+
}
|
|
3658
|
+
};
|
|
3659
|
+
}
|
|
3660
|
+
var pluginForConfigs = {
|
|
3661
|
+
rules: runtimeCleanupEslintRules
|
|
3662
|
+
};
|
|
3663
|
+
var createPresetConfig = (configName) => {
|
|
3664
|
+
const configMetadata = runtimeCleanupConfigMetadataByName[configName];
|
|
3665
|
+
return withRuntimeCleanupPlugin({
|
|
3666
|
+
name: configMetadata.presetName,
|
|
3667
|
+
rules: errorRulesFor(effectivePresetRuleNamesByConfig[configName])
|
|
3668
|
+
}, pluginForConfigs, {
|
|
3669
|
+
requiresTypeChecking: configMetadata.requiresTypeChecking
|
|
3670
|
+
});
|
|
3671
|
+
};
|
|
3672
|
+
var createRuntimeCleanupConfigsDefinition = () => (
|
|
3673
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Object.fromEntries cannot preserve the finite preset-key union.
|
|
3674
|
+
Object.fromEntries(runtimeCleanupConfigNames.map((configName) => [
|
|
3675
|
+
configName,
|
|
3676
|
+
createPresetConfig(configName)
|
|
3677
|
+
]))
|
|
3678
|
+
);
|
|
3679
|
+
var runtimeCleanupConfigsDefinition = createRuntimeCleanupConfigsDefinition();
|
|
3680
|
+
var runtimeCleanupConfigs = runtimeCleanupConfigsDefinition;
|
|
3681
|
+
var runtimeCleanupPlugin = {
|
|
3682
|
+
configs: runtimeCleanupConfigs,
|
|
3683
|
+
meta: {
|
|
3684
|
+
name: "eslint-plugin-runtime-cleanup",
|
|
3685
|
+
namespace: "runtime-cleanup",
|
|
3686
|
+
version: getPackageVersion(package_default)
|
|
3687
|
+
},
|
|
3688
|
+
processors: {},
|
|
3689
|
+
rules: runtimeCleanupEslintRules
|
|
3690
|
+
};
|
|
3691
|
+
var plugin_default = runtimeCleanupPlugin;
|
|
3692
|
+
module.exports = module.exports.default;
|
|
3693
|
+
//# sourceMappingURL=plugin.cjs.map
|