eslint-plugin-runtime-cleanup 1.2.8 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -29
- package/dist/_internal/ast-node.d.ts +5 -1
- package/dist/_internal/ast-node.d.ts.map +1 -1
- package/dist/_internal/ast-node.js +2 -1
- package/dist/_internal/ast-node.js.map +1 -1
- package/dist/_internal/bounded-cache.d.ts.map +1 -1
- package/dist/_internal/bounded-cache.js +2 -1
- package/dist/_internal/bounded-cache.js.map +1 -1
- package/dist/_internal/expression-boolean-memoizer.d.ts.map +1 -1
- package/dist/_internal/expression-boolean-memoizer.js +2 -1
- package/dist/_internal/expression-boolean-memoizer.js.map +1 -1
- package/dist/_internal/filter-callback.d.ts +5 -1
- package/dist/_internal/filter-callback.d.ts.map +1 -1
- package/dist/_internal/filter-callback.js +9 -10
- package/dist/_internal/filter-callback.js.map +1 -1
- package/dist/_internal/floating-resource.d.ts +8 -0
- package/dist/_internal/floating-resource.d.ts.map +1 -1
- package/dist/_internal/floating-resource.js +42 -36
- package/dist/_internal/floating-resource.js.map +1 -1
- package/dist/_internal/normalize-expression-text.d.ts +6 -1
- package/dist/_internal/normalize-expression-text.d.ts.map +1 -1
- package/dist/_internal/normalize-expression-text.js +30 -28
- package/dist/_internal/normalize-expression-text.js.map +1 -1
- package/dist/_internal/nullish-comparison.d.ts +1 -1
- package/dist/_internal/nullish-comparison.d.ts.map +1 -1
- package/dist/_internal/nullish-comparison.js +16 -11
- package/dist/_internal/nullish-comparison.js.map +1 -1
- package/dist/_internal/plugin-settings.d.ts +2 -1
- package/dist/_internal/plugin-settings.d.ts.map +1 -1
- package/dist/_internal/plugin-settings.js +3 -2
- package/dist/_internal/plugin-settings.js.map +1 -1
- package/dist/_internal/report-adapter.d.ts +5 -4
- package/dist/_internal/report-adapter.d.ts.map +1 -1
- package/dist/_internal/report-adapter.js +3 -2
- package/dist/_internal/report-adapter.js.map +1 -1
- package/dist/_internal/rule-catalog.d.ts.map +1 -1
- package/dist/_internal/rule-catalog.js +3 -2
- package/dist/_internal/rule-catalog.js.map +1 -1
- package/dist/_internal/rule-docs-metadata.d.ts +2 -1
- package/dist/_internal/rule-docs-metadata.d.ts.map +1 -1
- package/dist/_internal/rule-docs-metadata.js +36 -33
- package/dist/_internal/rule-docs-metadata.js.map +1 -1
- package/dist/_internal/rules-registry.d.ts +2 -1
- package/dist/_internal/rules-registry.d.ts.map +1 -1
- package/dist/_internal/rules-registry.js.map +1 -1
- package/dist/_internal/runtime-cleanup-config-references.d.ts +2 -1
- package/dist/_internal/runtime-cleanup-config-references.d.ts.map +1 -1
- package/dist/_internal/runtime-cleanup-config-references.js +8 -7
- package/dist/_internal/runtime-cleanup-config-references.js.map +1 -1
- package/dist/_internal/scope-variable.d.ts.map +1 -1
- package/dist/_internal/scope-variable.js +5 -4
- package/dist/_internal/scope-variable.js.map +1 -1
- package/dist/_internal/type-checker.d.ts +2 -2
- package/dist/_internal/type-checker.d.ts.map +1 -1
- package/dist/_internal/type-checker.js +10 -8
- package/dist/_internal/type-checker.js.map +1 -1
- package/dist/_internal/type-predicate-autofix-safety.d.ts +5 -1
- package/dist/_internal/type-predicate-autofix-safety.d.ts.map +1 -1
- package/dist/_internal/type-predicate-autofix-safety.js +9 -10
- package/dist/_internal/type-predicate-autofix-safety.js.map +1 -1
- package/dist/_internal/type-reference-node.d.ts +7 -5
- package/dist/_internal/type-reference-node.d.ts.map +1 -1
- package/dist/_internal/type-reference-node.js +6 -6
- package/dist/_internal/type-reference-node.js.map +1 -1
- package/dist/_internal/typed-rule.d.ts +2 -1
- package/dist/_internal/typed-rule.d.ts.map +1 -1
- package/dist/_internal/typed-rule.js +6 -5
- package/dist/_internal/typed-rule.js.map +1 -1
- package/dist/_internal/value-rewrite-autofix-safety.d.ts +5 -1
- package/dist/_internal/value-rewrite-autofix-safety.d.ts.map +1 -1
- package/dist/_internal/value-rewrite-autofix-safety.js +10 -18
- package/dist/_internal/value-rewrite-autofix-safety.js.map +1 -1
- package/dist/plugin.cjs +571 -662
- package/dist/plugin.cjs.map +4 -4
- package/dist/plugin.d.cts +2 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +8 -7
- package/dist/plugin.js.map +1 -1
- package/dist/rules/no-floating-abort-controllers.d.ts.map +1 -1
- package/dist/rules/no-floating-abort-controllers.js +24 -52
- package/dist/rules/no-floating-abort-controllers.js.map +1 -1
- package/dist/rules/no-floating-audio-contexts.d.ts.map +1 -1
- package/dist/rules/no-floating-audio-contexts.js +7 -6
- package/dist/rules/no-floating-audio-contexts.js.map +1 -1
- package/dist/rules/no-floating-broadcast-channels.d.ts.map +1 -1
- package/dist/rules/no-floating-broadcast-channels.js +31 -59
- package/dist/rules/no-floating-broadcast-channels.js.map +1 -1
- package/dist/rules/no-floating-child-processes.d.ts.map +1 -1
- package/dist/rules/no-floating-child-processes.js +43 -45
- package/dist/rules/no-floating-child-processes.js.map +1 -1
- package/dist/rules/no-floating-disposable-stacks.d.ts.map +1 -1
- package/dist/rules/no-floating-disposable-stacks.js +37 -38
- package/dist/rules/no-floating-disposable-stacks.js.map +1 -1
- package/dist/rules/no-floating-file-watchers.d.ts.map +1 -1
- package/dist/rules/no-floating-file-watchers.js +40 -42
- package/dist/rules/no-floating-file-watchers.js.map +1 -1
- package/dist/rules/no-floating-geolocation-watches.js +20 -20
- package/dist/rules/no-floating-geolocation-watches.js.map +1 -1
- package/dist/rules/no-floating-infinite-animations.d.ts.map +1 -1
- package/dist/rules/no-floating-infinite-animations.js +4 -3
- package/dist/rules/no-floating-infinite-animations.js.map +1 -1
- package/dist/rules/no-floating-media-streams.d.ts.map +1 -1
- package/dist/rules/no-floating-media-streams.js +24 -24
- package/dist/rules/no-floating-media-streams.js.map +1 -1
- package/dist/rules/no-floating-message-channels.js +30 -30
- package/dist/rules/no-floating-message-channels.js.map +1 -1
- package/dist/rules/no-floating-network-connections.d.ts.map +1 -1
- package/dist/rules/no-floating-network-connections.js +36 -36
- package/dist/rules/no-floating-network-connections.js.map +1 -1
- package/dist/rules/no-floating-object-urls.d.ts.map +1 -1
- package/dist/rules/no-floating-object-urls.js +4 -3
- package/dist/rules/no-floating-object-urls.js.map +1 -1
- package/dist/rules/no-floating-observers.d.ts.map +1 -1
- package/dist/rules/no-floating-observers.js +33 -34
- package/dist/rules/no-floating-observers.js.map +1 -1
- package/dist/rules/no-floating-servers.d.ts.map +1 -1
- package/dist/rules/no-floating-servers.js +50 -52
- package/dist/rules/no-floating-servers.js.map +1 -1
- package/dist/rules/no-floating-streams.d.ts.map +1 -1
- package/dist/rules/no-floating-streams.js +28 -29
- package/dist/rules/no-floating-streams.js.map +1 -1
- package/dist/rules/no-floating-timers.d.ts.map +1 -1
- package/dist/rules/no-floating-timers.js +7 -47
- package/dist/rules/no-floating-timers.js.map +1 -1
- package/dist/rules/no-floating-wake-locks.js +20 -20
- package/dist/rules/no-floating-wake-locks.js.map +1 -1
- package/dist/rules/no-floating-web-stream-locks.d.ts.map +1 -1
- package/dist/rules/no-floating-web-stream-locks.js +4 -3
- package/dist/rules/no-floating-web-stream-locks.js.map +1 -1
- package/dist/rules/no-floating-workers.d.ts.map +1 -1
- package/dist/rules/no-floating-workers.js +39 -40
- package/dist/rules/no-floating-workers.js.map +1 -1
- package/dist/rules/no-unmanaged-event-listeners.d.ts.map +1 -1
- package/dist/rules/no-unmanaged-event-listeners.js +23 -23
- package/dist/rules/no-unmanaged-event-listeners.js.map +1 -1
- package/docs/rules/no-floating-audio-contexts.md +1 -2
- package/docs/rules/no-floating-media-streams.md +1 -1
- package/docs/rules/no-floating-object-urls.md +3 -3
- package/docs/rules/no-floating-observers.md +1 -1
- package/docs/rules/no-floating-servers.md +1 -1
- package/docs/rules/no-floating-wake-locks.md +1 -1
- package/docs/rules/no-floating-web-stream-locks.md +1 -2
- package/docs/rules/presets/index.md +28 -28
- package/package.json +7 -4
package/dist/plugin.cjs
CHANGED
|
@@ -34,12 +34,13 @@ __export(plugin_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(plugin_exports);
|
|
36
36
|
var import_parser = __toESM(require("@typescript-eslint/parser"), 1);
|
|
37
|
+
var import_ts_extras29 = require("ts-extras");
|
|
37
38
|
|
|
38
39
|
// package.json
|
|
39
40
|
var package_default = {
|
|
40
41
|
$schema: "https://www.schemastore.org/package.json",
|
|
41
42
|
name: "eslint-plugin-runtime-cleanup",
|
|
42
|
-
version: "1.2.
|
|
43
|
+
version: "1.2.10",
|
|
43
44
|
private: false,
|
|
44
45
|
description: "ESLint rules for requiring cleanup of runtime resources.",
|
|
45
46
|
keywords: [
|
|
@@ -262,10 +263,13 @@ var package_default = {
|
|
|
262
263
|
dependencies: {
|
|
263
264
|
"@typescript-eslint/parser": "^8.59.3",
|
|
264
265
|
"@typescript-eslint/type-utils": "^8.59.3",
|
|
265
|
-
"@typescript-eslint/utils": "^8.59.3"
|
|
266
|
+
"@typescript-eslint/utils": "^8.59.3",
|
|
267
|
+
"ts-extras": "^1.0.0",
|
|
268
|
+
"type-fest": "^5.6.0"
|
|
266
269
|
},
|
|
267
270
|
devDependencies: {
|
|
268
271
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
272
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
269
273
|
"@csstools/stylelint-formatter-github": "^2.0.0",
|
|
270
274
|
"@double-great/remark-lint-alt-text": "^1.1.1",
|
|
271
275
|
"@eslint/config-inspector": "^3.0.2",
|
|
@@ -292,14 +296,14 @@ var package_default = {
|
|
|
292
296
|
"detect-secrets": "^1.0.6",
|
|
293
297
|
esbuild: "^0.28.0",
|
|
294
298
|
eslint: "^10.4.0",
|
|
295
|
-
"eslint-config-nick2bad4u": "^1.0.
|
|
299
|
+
"eslint-config-nick2bad4u": "^1.0.20",
|
|
296
300
|
"eslint-formatter-unix": "^9.0.1",
|
|
297
301
|
"eslint-rule-benchmark": "^0.8.0",
|
|
298
302
|
"fast-check": "^4.8.0",
|
|
299
303
|
"git-cliff": "^2.13.1",
|
|
300
304
|
"gitleaks-secret-scanner": "^2.1.1",
|
|
301
305
|
htmlhint: "^1.9.2",
|
|
302
|
-
jscpd: "^4.2.
|
|
306
|
+
jscpd: "^4.2.3",
|
|
303
307
|
knip: "^6.14.1",
|
|
304
308
|
leasot: "^14.4.0",
|
|
305
309
|
madge: "^8.0.0",
|
|
@@ -361,10 +365,12 @@ var package_default = {
|
|
|
361
365
|
};
|
|
362
366
|
|
|
363
367
|
// dist/rules/no-floating-abort-controllers.js
|
|
364
|
-
var
|
|
368
|
+
var import_utils4 = require("@typescript-eslint/utils");
|
|
369
|
+
var import_ts_extras7 = require("ts-extras");
|
|
365
370
|
|
|
366
371
|
// dist/_internal/ast-node.js
|
|
367
372
|
var import_utils = require("@typescript-eslint/utils");
|
|
373
|
+
var import_ts_extras = require("ts-extras");
|
|
368
374
|
|
|
369
375
|
// dist/_internal/cycle-safe-linked-search.js
|
|
370
376
|
var FLOYD_FAST_POINTER_ADVANCE_STEPS = 2;
|
|
@@ -395,24 +401,110 @@ var resolveFirstValueInLinkedStructure = ({ getNextNode, resolveValue, startNode
|
|
|
395
401
|
};
|
|
396
402
|
|
|
397
403
|
// dist/_internal/ast-node.js
|
|
398
|
-
var hasOptionalParentProperty = (node) => "parent"
|
|
404
|
+
var hasOptionalParentProperty = (node) => (0, import_ts_extras.keyIn)(node, "parent");
|
|
399
405
|
var getParentNode = (node) => hasOptionalParentProperty(node) ? node.parent : void 0;
|
|
400
406
|
|
|
407
|
+
// dist/_internal/floating-resource.js
|
|
408
|
+
var import_utils2 = require("@typescript-eslint/utils");
|
|
409
|
+
var import_ts_extras2 = require("ts-extras");
|
|
410
|
+
var getTransparentWrappedExpression = (node) => {
|
|
411
|
+
if (node.type === import_utils2.AST_NODE_TYPES.AwaitExpression) {
|
|
412
|
+
return node.argument;
|
|
413
|
+
}
|
|
414
|
+
if (node.type === import_utils2.AST_NODE_TYPES.ChainExpression) {
|
|
415
|
+
return node.expression;
|
|
416
|
+
}
|
|
417
|
+
if (node.type === import_utils2.AST_NODE_TYPES.TSAsExpression) {
|
|
418
|
+
return node.expression;
|
|
419
|
+
}
|
|
420
|
+
if (node.type === import_utils2.AST_NODE_TYPES.TSNonNullExpression) {
|
|
421
|
+
return node.expression;
|
|
422
|
+
}
|
|
423
|
+
if (node.type === import_utils2.AST_NODE_TYPES.TSSatisfiesExpression) {
|
|
424
|
+
return node.expression;
|
|
425
|
+
}
|
|
426
|
+
if (node.type === import_utils2.AST_NODE_TYPES.TSTypeAssertion) {
|
|
427
|
+
return node.expression;
|
|
428
|
+
}
|
|
429
|
+
return void 0;
|
|
430
|
+
};
|
|
431
|
+
var getStaticPropertyName = (node, computed) => {
|
|
432
|
+
if (!computed && node.type === import_utils2.AST_NODE_TYPES.Identifier) {
|
|
433
|
+
return node.name;
|
|
434
|
+
}
|
|
435
|
+
if (computed && node.type === import_utils2.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
436
|
+
return node.value;
|
|
437
|
+
}
|
|
438
|
+
return void 0;
|
|
439
|
+
};
|
|
440
|
+
var collectStaticMemberPath = (node) => {
|
|
441
|
+
if (node.type === import_utils2.AST_NODE_TYPES.Identifier) {
|
|
442
|
+
return [node.name];
|
|
443
|
+
}
|
|
444
|
+
if (node.type !== import_utils2.AST_NODE_TYPES.MemberExpression || node.optional) {
|
|
445
|
+
return void 0;
|
|
446
|
+
}
|
|
447
|
+
const objectPath = collectStaticMemberPath(node.object);
|
|
448
|
+
const propertyName = getStaticPropertyName(node.property, node.computed);
|
|
449
|
+
return !(0, import_ts_extras2.isDefined)(objectPath) || !(0, import_ts_extras2.isDefined)(propertyName) ? void 0 : [...objectPath, propertyName];
|
|
450
|
+
};
|
|
451
|
+
var getFirstOpaqueParent = (node) => {
|
|
452
|
+
let current = node;
|
|
453
|
+
let parent = getParentNode(current);
|
|
454
|
+
while ((0, import_ts_extras2.isDefined)(parent)) {
|
|
455
|
+
const wrappedExpression = getTransparentWrappedExpression(parent);
|
|
456
|
+
if (wrappedExpression !== current) {
|
|
457
|
+
return { current, parent };
|
|
458
|
+
}
|
|
459
|
+
current = parent;
|
|
460
|
+
parent = getParentNode(current);
|
|
461
|
+
}
|
|
462
|
+
return void 0;
|
|
463
|
+
};
|
|
464
|
+
var isDiscardedResourceExpression = (node) => {
|
|
465
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
466
|
+
if (!(0, import_ts_extras2.isDefined)(opaqueParent)) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
const { current, parent } = opaqueParent;
|
|
470
|
+
if (parent.type === import_utils2.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
if (parent.type === import_utils2.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
474
|
+
const unaryParent = getParentNode(parent);
|
|
475
|
+
return unaryParent?.type === import_utils2.AST_NODE_TYPES.ExpressionStatement;
|
|
476
|
+
}
|
|
477
|
+
return false;
|
|
478
|
+
};
|
|
479
|
+
var isImmediateUnownedMemberReceiver = (node, cleanupMemberNames3) => {
|
|
480
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
481
|
+
if (!(0, import_ts_extras2.isDefined)(opaqueParent)) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
const { current, parent } = opaqueParent;
|
|
485
|
+
if (parent.type !== import_utils2.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
const propertyName = getStaticPropertyName(parent.property, parent.computed);
|
|
489
|
+
return !(0, import_ts_extras2.isDefined)(propertyName) || !(0, import_ts_extras2.setHas)(cleanupMemberNames3, propertyName);
|
|
490
|
+
};
|
|
491
|
+
|
|
401
492
|
// dist/_internal/rule-docs-url.js
|
|
402
493
|
var RULE_DOCS_URL_BASE = "https://nick2bad4u.github.io/eslint-plugin-runtime-cleanup/docs/rules/";
|
|
403
494
|
var createRuleDocsUrl = (ruleName) => `${RULE_DOCS_URL_BASE}${ruleName}`;
|
|
404
495
|
|
|
405
496
|
// dist/_internal/scope-variable.js
|
|
497
|
+
var import_ts_extras3 = require("ts-extras");
|
|
406
498
|
var getVariableInScopeChain = (scope, variableName) => {
|
|
407
499
|
const lookupResult = resolveFirstValueInLinkedStructure({
|
|
408
500
|
getNextNode: (currentScope) => currentScope.upper,
|
|
409
501
|
resolveValue: (currentScope) => {
|
|
410
502
|
const variable = currentScope.set.get(variableName);
|
|
411
|
-
return variable
|
|
412
|
-
found: false
|
|
413
|
-
} : {
|
|
503
|
+
return (0, import_ts_extras3.isDefined)(variable) ? {
|
|
414
504
|
found: true,
|
|
415
505
|
value: variable
|
|
506
|
+
} : {
|
|
507
|
+
found: false
|
|
416
508
|
};
|
|
417
509
|
},
|
|
418
510
|
startNode: scope
|
|
@@ -421,9 +513,11 @@ var getVariableInScopeChain = (scope, variableName) => {
|
|
|
421
513
|
};
|
|
422
514
|
|
|
423
515
|
// dist/_internal/typed-rule.js
|
|
424
|
-
var
|
|
516
|
+
var import_utils3 = require("@typescript-eslint/utils");
|
|
517
|
+
var import_ts_extras6 = require("ts-extras");
|
|
425
518
|
|
|
426
519
|
// dist/_internal/plugin-settings.js
|
|
520
|
+
var import_ts_extras4 = require("ts-extras");
|
|
427
521
|
var RUNTIME_CLEANUP_SETTINGS_KEY = "runtime-cleanup";
|
|
428
522
|
var DISABLE_ALL_AUTOFIXES_KEY = "disableAllAutofixes";
|
|
429
523
|
var settingsByProgram = /* @__PURE__ */ new WeakMap();
|
|
@@ -435,7 +529,7 @@ var getRuntimeCleanupSettings = (settings) => {
|
|
|
435
529
|
const pluginSettings = settings[RUNTIME_CLEANUP_SETTINGS_KEY];
|
|
436
530
|
return isObject(pluginSettings) ? pluginSettings : null;
|
|
437
531
|
};
|
|
438
|
-
var readBooleanFlag = (object, key) =>
|
|
532
|
+
var readBooleanFlag = (object, key) => (0, import_ts_extras4.objectHasOwn)(object, key) && object[key] === true;
|
|
439
533
|
var readDisableAllAutofixesFromSettings = (settings) => {
|
|
440
534
|
const pluginSettings = getRuntimeCleanupSettings(settings);
|
|
441
535
|
if (pluginSettings === null) {
|
|
@@ -449,7 +543,7 @@ var registerProgramSettingsForContext = (context) => {
|
|
|
449
543
|
disableAllAutofixes: readDisableAllAutofixesFromSettings(context.settings)
|
|
450
544
|
});
|
|
451
545
|
const existingProgramSettings = settingsByProgram.get(programNode);
|
|
452
|
-
if (
|
|
546
|
+
if ((0, import_ts_extras4.isDefined)(existingProgramSettings)) {
|
|
453
547
|
return existingProgramSettings;
|
|
454
548
|
}
|
|
455
549
|
settingsByProgram.set(programNode, parsedSettings);
|
|
@@ -457,6 +551,7 @@ var registerProgramSettingsForContext = (context) => {
|
|
|
457
551
|
};
|
|
458
552
|
|
|
459
553
|
// dist/_internal/rule-catalog.js
|
|
554
|
+
var import_ts_extras5 = require("ts-extras");
|
|
460
555
|
var orderedRuleNames = [
|
|
461
556
|
"no-floating-timers",
|
|
462
557
|
"no-unmanaged-event-listeners",
|
|
@@ -488,16 +583,16 @@ var runtimeCleanupRuleCatalogEntries = orderedRuleNames.map((ruleName, index) =>
|
|
|
488
583
|
ruleNumber
|
|
489
584
|
};
|
|
490
585
|
});
|
|
491
|
-
var runtimeCleanupRuleCatalogByRuleName =
|
|
586
|
+
var runtimeCleanupRuleCatalogByRuleName = (0, import_ts_extras5.objectFromEntries)(runtimeCleanupRuleCatalogEntries.map((entry) => [entry.ruleName, entry]));
|
|
492
587
|
var getRuleCatalogEntryForRuleNameOrNull = (ruleName) => runtimeCleanupRuleCatalogByRuleName[ruleName] ?? null;
|
|
493
588
|
var runtimeCleanupRuleCatalogByRuleId = new Map(runtimeCleanupRuleCatalogEntries.map((entry) => [entry.ruleId, entry]));
|
|
494
589
|
|
|
495
590
|
// dist/_internal/typed-rule.js
|
|
496
591
|
var createTypedRule = (ruleDefinition) => {
|
|
497
592
|
const catalogEntry = getRuleCatalogEntryForRuleNameOrNull(ruleDefinition.name);
|
|
498
|
-
const createdRule =
|
|
593
|
+
const createdRule = import_utils3.ESLintUtils.RuleCreator.withoutDocs(ruleDefinition);
|
|
499
594
|
const ruleDocs = createdRule.meta.docs;
|
|
500
|
-
if (
|
|
595
|
+
if (!(0, import_ts_extras6.isDefined)(ruleDocs)) {
|
|
501
596
|
throw new TypeError(`Rule '${ruleDefinition.name}' must declare meta.docs.`);
|
|
502
597
|
}
|
|
503
598
|
const canonicalDocsUrl = createRuleDocsUrl(ruleDefinition.name);
|
|
@@ -525,14 +620,14 @@ var createTypedRule = (ruleDefinition) => {
|
|
|
525
620
|
},
|
|
526
621
|
meta: {
|
|
527
622
|
...createdRule.meta,
|
|
528
|
-
...metaDefaultOptions
|
|
623
|
+
...(0, import_ts_extras6.isDefined)(metaDefaultOptions) ? { defaultOptions: metaDefaultOptions } : {},
|
|
529
624
|
docs: docsWithCatalog
|
|
530
625
|
},
|
|
531
626
|
name: ruleDefinition.name
|
|
532
627
|
};
|
|
533
628
|
};
|
|
534
629
|
var getTypedRuleServices = (context) => {
|
|
535
|
-
const parserServices =
|
|
630
|
+
const parserServices = import_utils3.ESLintUtils.getParserServices(context, true);
|
|
536
631
|
const program = parserServices.program;
|
|
537
632
|
if (program === null) {
|
|
538
633
|
throw new Error("Typed rule requires parserServices.program; ensure projectService is enabled for this lint run.");
|
|
@@ -551,30 +646,12 @@ var globalReceiverNames = [
|
|
|
551
646
|
"window"
|
|
552
647
|
];
|
|
553
648
|
var globalReceiverNameSet = new Set(globalReceiverNames);
|
|
554
|
-
var isGlobalReceiverName = (name) =>
|
|
555
|
-
var
|
|
556
|
-
if (node.type ===
|
|
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) {
|
|
649
|
+
var isGlobalReceiverName = (name) => (0, import_ts_extras7.setHas)(globalReceiverNameSet, name);
|
|
650
|
+
var getStaticPropertyName2 = (node, computed) => {
|
|
651
|
+
if (!computed && node.type === import_utils4.AST_NODE_TYPES.Identifier) {
|
|
575
652
|
return node.name;
|
|
576
653
|
}
|
|
577
|
-
if (computed && node.type ===
|
|
654
|
+
if (computed && node.type === import_utils4.AST_NODE_TYPES.Literal && typeof node.value === "string") {
|
|
578
655
|
return node.value;
|
|
579
656
|
}
|
|
580
657
|
return void 0;
|
|
@@ -584,43 +661,31 @@ var isShadowedAbortControllerIdentifier = (context, identifier) => {
|
|
|
584
661
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
585
662
|
return variable !== null && variable.defs.length > 0;
|
|
586
663
|
};
|
|
587
|
-
var isDirectAbortControllerConstructor = (context, callee) => callee.type ===
|
|
588
|
-
var isMemberAbortControllerConstructor = (callee) => callee.type ===
|
|
664
|
+
var isDirectAbortControllerConstructor = (context, callee) => callee.type === import_utils4.AST_NODE_TYPES.Identifier && callee.name === abortControllerConstructorName && !isShadowedAbortControllerIdentifier(context, callee);
|
|
665
|
+
var isMemberAbortControllerConstructor = (callee) => callee.type === import_utils4.AST_NODE_TYPES.MemberExpression && !callee.optional && callee.object.type === import_utils4.AST_NODE_TYPES.Identifier && isGlobalReceiverName(callee.object.name) && getStaticPropertyName2(callee.property, callee.computed) === abortControllerConstructorName;
|
|
589
666
|
var isAbortControllerConstructor = (context, callee) => isDirectAbortControllerConstructor(context, callee) || isMemberAbortControllerConstructor(callee);
|
|
590
667
|
var isDiscardedAbortControllerHandle = (node) => {
|
|
591
|
-
|
|
592
|
-
|
|
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
|
-
}
|
|
668
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
669
|
+
if (!(0, import_ts_extras7.isDefined)(opaqueParent)) {
|
|
607
670
|
return false;
|
|
608
671
|
}
|
|
672
|
+
const { current, parent } = opaqueParent;
|
|
673
|
+
if (parent.type === import_utils4.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
676
|
+
if (parent.type === import_utils4.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
677
|
+
const unaryParent = getParentNode(parent);
|
|
678
|
+
return unaryParent?.type === import_utils4.AST_NODE_TYPES.ExpressionStatement;
|
|
679
|
+
}
|
|
609
680
|
return false;
|
|
610
681
|
};
|
|
611
682
|
var isImmediateAbortSignalAccess = (node) => {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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";
|
|
683
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
684
|
+
if (!(0, import_ts_extras7.isDefined)(opaqueParent)) {
|
|
685
|
+
return false;
|
|
622
686
|
}
|
|
623
|
-
|
|
687
|
+
const { current, parent } = opaqueParent;
|
|
688
|
+
return parent.type === import_utils4.AST_NODE_TYPES.MemberExpression && parent.object === current && !parent.optional && getStaticPropertyName2(parent.property, parent.computed) === "signal";
|
|
624
689
|
};
|
|
625
690
|
var noFloatingAbortControllers = createTypedRule({
|
|
626
691
|
create(context) {
|
|
@@ -662,91 +727,7 @@ var no_floating_abort_controllers_default = noFloatingAbortControllers;
|
|
|
662
727
|
|
|
663
728
|
// dist/rules/no-floating-audio-contexts.js
|
|
664
729
|
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
|
|
730
|
+
var import_ts_extras8 = require("ts-extras");
|
|
750
731
|
var audioContextConstructorNames = [
|
|
751
732
|
"AudioContext",
|
|
752
733
|
"webkitAudioContext"
|
|
@@ -755,7 +736,7 @@ var cleanupMemberNames = /* @__PURE__ */ new Set(["close"]);
|
|
|
755
736
|
var globalReceiverNames2 = ["globalThis", "self", "window"];
|
|
756
737
|
var audioContextConstructorNameSet = new Set(audioContextConstructorNames);
|
|
757
738
|
var globalReceiverNameSet2 = new Set(globalReceiverNames2);
|
|
758
|
-
var isAudioContextConstructorName = (name) =>
|
|
739
|
+
var isAudioContextConstructorName = (name) => (0, import_ts_extras8.setHas)(audioContextConstructorNameSet, name);
|
|
759
740
|
var isShadowedIdentifier = (context, identifier) => {
|
|
760
741
|
const scope = context.sourceCode.getScope(identifier);
|
|
761
742
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
@@ -775,12 +756,12 @@ var getMemberAudioContextConstructorName = (callee) => {
|
|
|
775
756
|
if (path?.length !== 2) {
|
|
776
757
|
return void 0;
|
|
777
758
|
}
|
|
778
|
-
const receiverName = path
|
|
779
|
-
if (receiverName
|
|
759
|
+
const receiverName = (0, import_ts_extras8.arrayFirst)(path);
|
|
760
|
+
if (!(0, import_ts_extras8.isDefined)(receiverName) || !(0, import_ts_extras8.setHas)(globalReceiverNameSet2, receiverName)) {
|
|
780
761
|
return void 0;
|
|
781
762
|
}
|
|
782
763
|
const constructorName = path[1];
|
|
783
|
-
return constructorName
|
|
764
|
+
return (0, import_ts_extras8.isDefined)(constructorName) && isAudioContextConstructorName(constructorName) ? constructorName : void 0;
|
|
784
765
|
};
|
|
785
766
|
var getAudioContextConstructorName = (context, callee) => getDirectAudioContextConstructorName(context, callee) ?? getMemberAudioContextConstructorName(callee);
|
|
786
767
|
var noFloatingAudioContexts = createTypedRule({
|
|
@@ -788,7 +769,7 @@ var noFloatingAudioContexts = createTypedRule({
|
|
|
788
769
|
return {
|
|
789
770
|
NewExpression(node) {
|
|
790
771
|
const constructorName = getAudioContextConstructorName(context, node.callee);
|
|
791
|
-
if (constructorName
|
|
772
|
+
if (!(0, import_ts_extras8.isDefined)(constructorName) || !isDiscardedResourceExpression(node) && !isImmediateUnownedMemberReceiver(node, cleanupMemberNames)) {
|
|
792
773
|
return;
|
|
793
774
|
}
|
|
794
775
|
context.report({
|
|
@@ -825,6 +806,7 @@ var no_floating_audio_contexts_default = noFloatingAudioContexts;
|
|
|
825
806
|
|
|
826
807
|
// dist/rules/no-floating-broadcast-channels.js
|
|
827
808
|
var import_utils6 = require("@typescript-eslint/utils");
|
|
809
|
+
var import_ts_extras9 = require("ts-extras");
|
|
828
810
|
var broadcastChannelConstructorName = "BroadcastChannel";
|
|
829
811
|
var globalReceiverNames3 = [
|
|
830
812
|
"globalThis",
|
|
@@ -832,25 +814,7 @@ var globalReceiverNames3 = [
|
|
|
832
814
|
"window"
|
|
833
815
|
];
|
|
834
816
|
var globalReceiverNameSet3 = new Set(globalReceiverNames3);
|
|
835
|
-
var isGlobalReceiverName2 = (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
|
-
};
|
|
817
|
+
var isGlobalReceiverName2 = (name) => (0, import_ts_extras9.setHas)(globalReceiverNameSet3, name);
|
|
854
818
|
var getStaticPropertyName3 = (node, computed) => {
|
|
855
819
|
if (!computed && node.type === import_utils6.AST_NODE_TYPES.Identifier) {
|
|
856
820
|
return node.name;
|
|
@@ -869,46 +833,34 @@ var isDirectBroadcastChannelConstructor = (context, callee) => callee.type === i
|
|
|
869
833
|
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
834
|
var isBroadcastChannelConstructor = (context, callee) => isDirectBroadcastChannelConstructor(context, callee) || isMemberBroadcastChannelConstructor(callee);
|
|
871
835
|
var isDiscardedBroadcastChannel = (node) => {
|
|
872
|
-
|
|
873
|
-
|
|
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
|
-
}
|
|
836
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
837
|
+
if (!(0, import_ts_extras9.isDefined)(opaqueParent)) {
|
|
888
838
|
return false;
|
|
889
839
|
}
|
|
840
|
+
const { current, parent } = opaqueParent;
|
|
841
|
+
if (parent.type === import_utils6.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
842
|
+
return true;
|
|
843
|
+
}
|
|
844
|
+
if (parent.type === import_utils6.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
845
|
+
const unaryParent = getParentNode(parent);
|
|
846
|
+
return unaryParent?.type === import_utils6.AST_NODE_TYPES.ExpressionStatement;
|
|
847
|
+
}
|
|
890
848
|
return false;
|
|
891
849
|
};
|
|
892
850
|
var isImmediateBroadcastChannelMethodReceiver = (node) => {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
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;
|
|
851
|
+
const opaqueParent = getFirstOpaqueParent(node);
|
|
852
|
+
if (!(0, import_ts_extras9.isDefined)(opaqueParent)) {
|
|
853
|
+
return false;
|
|
910
854
|
}
|
|
911
|
-
|
|
855
|
+
const { current, parent } = opaqueParent;
|
|
856
|
+
if (parent.type !== import_utils6.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
857
|
+
return false;
|
|
858
|
+
}
|
|
859
|
+
if (getStaticPropertyName3(parent.property, parent.computed) === "close") {
|
|
860
|
+
return false;
|
|
861
|
+
}
|
|
862
|
+
const callExpression = getParentNode(parent);
|
|
863
|
+
return callExpression?.type === import_utils6.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
912
864
|
};
|
|
913
865
|
var noFloatingBroadcastChannels = createTypedRule({
|
|
914
866
|
create(context) {
|
|
@@ -950,6 +902,7 @@ var no_floating_broadcast_channels_default = noFloatingBroadcastChannels;
|
|
|
950
902
|
|
|
951
903
|
// dist/rules/no-floating-child-processes.js
|
|
952
904
|
var import_utils7 = require("@typescript-eslint/utils");
|
|
905
|
+
var import_ts_extras10 = require("ts-extras");
|
|
953
906
|
var childProcessFactoryNames = [
|
|
954
907
|
"exec",
|
|
955
908
|
"execFile",
|
|
@@ -967,9 +920,9 @@ var immediateCleanupMethodNames = [
|
|
|
967
920
|
var childProcessFactoryNameSet = new Set(childProcessFactoryNames);
|
|
968
921
|
var childProcessModuleNameSet = new Set(childProcessModuleNames);
|
|
969
922
|
var immediateCleanupMethodNameSet = new Set(immediateCleanupMethodNames);
|
|
970
|
-
var isChildProcessFactoryName = (name) =>
|
|
971
|
-
var isImmediateCleanupMethodName = (name) =>
|
|
972
|
-
var
|
|
923
|
+
var isChildProcessFactoryName = (name) => (0, import_ts_extras10.setHas)(childProcessFactoryNameSet, name);
|
|
924
|
+
var isImmediateCleanupMethodName = (name) => (0, import_ts_extras10.setHas)(immediateCleanupMethodNameSet, name);
|
|
925
|
+
var getTransparentWrappedExpression2 = (node) => {
|
|
973
926
|
if (node.type === import_utils7.AST_NODE_TYPES.ChainExpression) {
|
|
974
927
|
return node.expression;
|
|
975
928
|
}
|
|
@@ -1022,29 +975,28 @@ var getDefinitionModuleSource = (node) => {
|
|
|
1022
975
|
var getImportedSpecifierName = (node) => getStaticPropertyName4(node.imported);
|
|
1023
976
|
var getObjectPatternPropertyNameForIdentifier = (objectPattern, identifierName) => {
|
|
1024
977
|
for (const property of objectPattern.properties) {
|
|
1025
|
-
if (property.type
|
|
1026
|
-
|
|
978
|
+
if (property.type === import_utils7.AST_NODE_TYPES.Property && property.value.type === import_utils7.AST_NODE_TYPES.Identifier && property.value.name === identifierName) {
|
|
979
|
+
return getStaticPropertyName4(property.key);
|
|
1027
980
|
}
|
|
1028
|
-
return getStaticPropertyName4(property.key);
|
|
1029
981
|
}
|
|
1030
982
|
return void 0;
|
|
1031
983
|
};
|
|
1032
|
-
var isChildProcessModuleSource = (source) => source
|
|
984
|
+
var isChildProcessModuleSource = (source) => (0, import_ts_extras10.isDefined)(source) && (0, import_ts_extras10.setHas)(childProcessModuleNameSet, source);
|
|
1033
985
|
var getDefinitionForIdentifier = (context, identifier) => {
|
|
1034
986
|
const scope = context.sourceCode.getScope(identifier);
|
|
1035
987
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1036
|
-
return variable?.defs[
|
|
988
|
+
return (0, import_ts_extras10.arrayFirst)(variable?.defs ?? []);
|
|
1037
989
|
};
|
|
1038
990
|
var isChildProcessModuleBinding = (context, identifier) => {
|
|
1039
991
|
const definition = getDefinitionForIdentifier(context, identifier);
|
|
1040
|
-
if (
|
|
992
|
+
if (!(0, import_ts_extras10.isDefined)(definition)) {
|
|
1041
993
|
return false;
|
|
1042
994
|
}
|
|
1043
995
|
return isChildProcessModuleSource(getDefinitionModuleSource(definition.node));
|
|
1044
996
|
};
|
|
1045
997
|
var getNamedChildProcessFactoryBindingName = (context, identifier) => {
|
|
1046
998
|
const definition = getDefinitionForIdentifier(context, identifier);
|
|
1047
|
-
if (
|
|
999
|
+
if (!(0, import_ts_extras10.isDefined)(definition)) {
|
|
1048
1000
|
return void 0;
|
|
1049
1001
|
}
|
|
1050
1002
|
const source = getDefinitionModuleSource(definition.node);
|
|
@@ -1053,11 +1005,11 @@ var getNamedChildProcessFactoryBindingName = (context, identifier) => {
|
|
|
1053
1005
|
}
|
|
1054
1006
|
if (definition.node.type === import_utils7.AST_NODE_TYPES.ImportSpecifier) {
|
|
1055
1007
|
const importedName = getImportedSpecifierName(definition.node);
|
|
1056
|
-
return importedName
|
|
1008
|
+
return (0, import_ts_extras10.isDefined)(importedName) && isChildProcessFactoryName(importedName) ? importedName : void 0;
|
|
1057
1009
|
}
|
|
1058
1010
|
if (definition.node.type === import_utils7.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils7.AST_NODE_TYPES.ObjectPattern) {
|
|
1059
1011
|
const propertyName = getObjectPatternPropertyNameForIdentifier(definition.node.id, identifier.name);
|
|
1060
|
-
return propertyName
|
|
1012
|
+
return (0, import_ts_extras10.isDefined)(propertyName) && isChildProcessFactoryName(propertyName) ? propertyName : void 0;
|
|
1061
1013
|
}
|
|
1062
1014
|
return void 0;
|
|
1063
1015
|
};
|
|
@@ -1082,39 +1034,37 @@ var getChildProcessFactoryName = (context, callee) => {
|
|
|
1082
1034
|
var isDiscardedChildProcessHandle = (node) => {
|
|
1083
1035
|
let current = node;
|
|
1084
1036
|
let parent = getParentNode(current);
|
|
1085
|
-
while (
|
|
1086
|
-
const wrappedExpression =
|
|
1087
|
-
if (wrappedExpression
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
const unaryParent = getParentNode(parent);
|
|
1097
|
-
return unaryParent?.type === import_utils7.AST_NODE_TYPES.ExpressionStatement;
|
|
1037
|
+
while ((0, import_ts_extras10.isDefined)(parent)) {
|
|
1038
|
+
const wrappedExpression = getTransparentWrappedExpression2(parent);
|
|
1039
|
+
if (wrappedExpression !== current) {
|
|
1040
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1041
|
+
return true;
|
|
1042
|
+
}
|
|
1043
|
+
if (parent.type === import_utils7.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1044
|
+
const unaryParent = getParentNode(parent);
|
|
1045
|
+
return unaryParent?.type === import_utils7.AST_NODE_TYPES.ExpressionStatement;
|
|
1046
|
+
}
|
|
1047
|
+
return false;
|
|
1098
1048
|
}
|
|
1099
|
-
|
|
1049
|
+
current = parent;
|
|
1050
|
+
parent = getParentNode(current);
|
|
1100
1051
|
}
|
|
1101
1052
|
return false;
|
|
1102
1053
|
};
|
|
1103
1054
|
var isImmediateChildProcessMethodReceiver = (node) => {
|
|
1104
1055
|
let current = node;
|
|
1105
1056
|
let parent = getParentNode(current);
|
|
1106
|
-
while (
|
|
1107
|
-
const wrappedExpression =
|
|
1108
|
-
if (wrappedExpression
|
|
1109
|
-
current
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
return false;
|
|
1057
|
+
while ((0, import_ts_extras10.isDefined)(parent)) {
|
|
1058
|
+
const wrappedExpression = getTransparentWrappedExpression2(parent);
|
|
1059
|
+
if (wrappedExpression !== current) {
|
|
1060
|
+
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)) {
|
|
1061
|
+
return false;
|
|
1062
|
+
}
|
|
1063
|
+
const callExpression = getParentNode(parent);
|
|
1064
|
+
return callExpression?.type === import_utils7.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
1115
1065
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1066
|
+
current = parent;
|
|
1067
|
+
parent = getParentNode(current);
|
|
1118
1068
|
}
|
|
1119
1069
|
return false;
|
|
1120
1070
|
};
|
|
@@ -1123,7 +1073,7 @@ var noFloatingChildProcesses = createTypedRule({
|
|
|
1123
1073
|
return {
|
|
1124
1074
|
CallExpression(node) {
|
|
1125
1075
|
const factoryName = getChildProcessFactoryName(context, node.callee);
|
|
1126
|
-
if (factoryName
|
|
1076
|
+
if (!(0, import_ts_extras10.isDefined)(factoryName) || !isDiscardedChildProcessHandle(node) && !isImmediateChildProcessMethodReceiver(node)) {
|
|
1127
1077
|
return;
|
|
1128
1078
|
}
|
|
1129
1079
|
context.report({
|
|
@@ -1160,6 +1110,7 @@ var no_floating_child_processes_default = noFloatingChildProcesses;
|
|
|
1160
1110
|
|
|
1161
1111
|
// dist/rules/no-floating-disposable-stacks.js
|
|
1162
1112
|
var import_utils8 = require("@typescript-eslint/utils");
|
|
1113
|
+
var import_ts_extras11 = require("ts-extras");
|
|
1163
1114
|
var disposableStackConstructorNames = [
|
|
1164
1115
|
"AsyncDisposableStack",
|
|
1165
1116
|
"DisposableStack"
|
|
@@ -1176,10 +1127,10 @@ var globalReceiverNames4 = [
|
|
|
1176
1127
|
var disposableStackConstructorNameSet = new Set(disposableStackConstructorNames);
|
|
1177
1128
|
var cleanupMethodNameSet = new Set(cleanupMethodNames);
|
|
1178
1129
|
var globalReceiverNameSet4 = new Set(globalReceiverNames4);
|
|
1179
|
-
var isDisposableStackConstructorName = (name) =>
|
|
1180
|
-
var isCleanupMethodName = (name) =>
|
|
1181
|
-
var isGlobalReceiverName3 = (name) =>
|
|
1182
|
-
var
|
|
1130
|
+
var isDisposableStackConstructorName = (name) => (0, import_ts_extras11.setHas)(disposableStackConstructorNameSet, name);
|
|
1131
|
+
var isCleanupMethodName = (name) => (0, import_ts_extras11.setHas)(cleanupMethodNameSet, name);
|
|
1132
|
+
var isGlobalReceiverName3 = (name) => (0, import_ts_extras11.setHas)(globalReceiverNameSet4, name);
|
|
1133
|
+
var getTransparentWrappedExpression3 = (node) => {
|
|
1183
1134
|
if (node.type === import_utils8.AST_NODE_TYPES.ChainExpression) {
|
|
1184
1135
|
return node.expression;
|
|
1185
1136
|
}
|
|
@@ -1222,49 +1173,47 @@ var getMemberDisposableStackConstructorName = (callee) => {
|
|
|
1222
1173
|
return void 0;
|
|
1223
1174
|
}
|
|
1224
1175
|
const constructorName = getStaticPropertyName5(callee.property, callee.computed);
|
|
1225
|
-
return constructorName
|
|
1176
|
+
return (0, import_ts_extras11.isDefined)(constructorName) && isDisposableStackConstructorName(constructorName) ? constructorName : void 0;
|
|
1226
1177
|
};
|
|
1227
1178
|
var getDisposableStackConstructorName = (context, callee) => getDirectDisposableStackConstructorName(context, callee) ?? getMemberDisposableStackConstructorName(callee);
|
|
1228
1179
|
var isDiscardedDisposableStack = (node) => {
|
|
1229
1180
|
let current = node;
|
|
1230
1181
|
let parent = getParentNode(current);
|
|
1231
|
-
while (
|
|
1232
|
-
const wrappedExpression =
|
|
1233
|
-
if (wrappedExpression
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
const unaryParent = getParentNode(parent);
|
|
1243
|
-
return unaryParent?.type === import_utils8.AST_NODE_TYPES.ExpressionStatement;
|
|
1182
|
+
while ((0, import_ts_extras11.isDefined)(parent)) {
|
|
1183
|
+
const wrappedExpression = getTransparentWrappedExpression3(parent);
|
|
1184
|
+
if (wrappedExpression !== current) {
|
|
1185
|
+
if (parent.type === import_utils8.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1186
|
+
return true;
|
|
1187
|
+
}
|
|
1188
|
+
if (parent.type === import_utils8.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1189
|
+
const unaryParent = getParentNode(parent);
|
|
1190
|
+
return unaryParent?.type === import_utils8.AST_NODE_TYPES.ExpressionStatement;
|
|
1191
|
+
}
|
|
1192
|
+
return false;
|
|
1244
1193
|
}
|
|
1245
|
-
|
|
1194
|
+
current = parent;
|
|
1195
|
+
parent = getParentNode(current);
|
|
1246
1196
|
}
|
|
1247
1197
|
return false;
|
|
1248
1198
|
};
|
|
1249
1199
|
var isImmediateDisposableStackMethodReceiver = (node) => {
|
|
1250
1200
|
let current = node;
|
|
1251
1201
|
let parent = getParentNode(current);
|
|
1252
|
-
while (
|
|
1253
|
-
const wrappedExpression =
|
|
1254
|
-
if (wrappedExpression
|
|
1255
|
-
current
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
return false;
|
|
1202
|
+
while ((0, import_ts_extras11.isDefined)(parent)) {
|
|
1203
|
+
const wrappedExpression = getTransparentWrappedExpression3(parent);
|
|
1204
|
+
if (wrappedExpression !== current) {
|
|
1205
|
+
if (parent.type !== import_utils8.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
1206
|
+
return false;
|
|
1207
|
+
}
|
|
1208
|
+
const methodName = getStaticPropertyName5(parent.property, parent.computed);
|
|
1209
|
+
if (!(0, import_ts_extras11.isDefined)(methodName) || isCleanupMethodName(methodName)) {
|
|
1210
|
+
return false;
|
|
1211
|
+
}
|
|
1212
|
+
const callExpression = getParentNode(parent);
|
|
1213
|
+
return callExpression?.type === import_utils8.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
1265
1214
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1215
|
+
current = parent;
|
|
1216
|
+
parent = getParentNode(current);
|
|
1268
1217
|
}
|
|
1269
1218
|
return false;
|
|
1270
1219
|
};
|
|
@@ -1273,7 +1222,7 @@ var noFloatingDisposableStacks = createTypedRule({
|
|
|
1273
1222
|
return {
|
|
1274
1223
|
NewExpression(node) {
|
|
1275
1224
|
const constructorName = getDisposableStackConstructorName(context, node.callee);
|
|
1276
|
-
if (constructorName
|
|
1225
|
+
if (!(0, import_ts_extras11.isDefined)(constructorName) || !isDiscardedDisposableStack(node) && !isImmediateDisposableStackMethodReceiver(node)) {
|
|
1277
1226
|
return;
|
|
1278
1227
|
}
|
|
1279
1228
|
context.report({
|
|
@@ -1310,13 +1259,14 @@ var no_floating_disposable_stacks_default = noFloatingDisposableStacks;
|
|
|
1310
1259
|
|
|
1311
1260
|
// dist/rules/no-floating-file-watchers.js
|
|
1312
1261
|
var import_utils9 = require("@typescript-eslint/utils");
|
|
1262
|
+
var import_ts_extras12 = require("ts-extras");
|
|
1313
1263
|
var fileWatcherFactoryName = "watch";
|
|
1314
1264
|
var fsModuleNames = ["fs", "node:fs"];
|
|
1315
1265
|
var immediateCleanupMethodNames2 = ["close"];
|
|
1316
1266
|
var fsModuleNameSet = new Set(fsModuleNames);
|
|
1317
1267
|
var immediateCleanupMethodNameSet2 = new Set(immediateCleanupMethodNames2);
|
|
1318
|
-
var isImmediateCleanupMethodName2 = (name) =>
|
|
1319
|
-
var
|
|
1268
|
+
var isImmediateCleanupMethodName2 = (name) => (0, import_ts_extras12.setHas)(immediateCleanupMethodNameSet2, name);
|
|
1269
|
+
var getTransparentWrappedExpression4 = (node) => {
|
|
1320
1270
|
if (node.type === import_utils9.AST_NODE_TYPES.ChainExpression) {
|
|
1321
1271
|
return node.expression;
|
|
1322
1272
|
}
|
|
@@ -1366,29 +1316,28 @@ var getDefinitionModuleSource2 = (node) => {
|
|
|
1366
1316
|
}
|
|
1367
1317
|
return void 0;
|
|
1368
1318
|
};
|
|
1369
|
-
var isFsModuleSource = (source) => source
|
|
1319
|
+
var isFsModuleSource = (source) => (0, import_ts_extras12.isDefined)(source) && (0, import_ts_extras12.setHas)(fsModuleNameSet, source);
|
|
1370
1320
|
var getDefinitionForIdentifier2 = (context, identifier) => {
|
|
1371
1321
|
const scope = context.sourceCode.getScope(identifier);
|
|
1372
1322
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
1373
|
-
return variable?.defs[
|
|
1323
|
+
return (0, import_ts_extras12.arrayFirst)(variable?.defs ?? []);
|
|
1374
1324
|
};
|
|
1375
1325
|
var isFsModuleBinding = (context, identifier) => {
|
|
1376
1326
|
const definition = getDefinitionForIdentifier2(context, identifier);
|
|
1377
|
-
return definition
|
|
1327
|
+
return (0, import_ts_extras12.isDefined)(definition) && isFsModuleSource(getDefinitionModuleSource2(definition.node));
|
|
1378
1328
|
};
|
|
1379
1329
|
var getImportedSpecifierName2 = (node) => getStaticPropertyName6(node.imported);
|
|
1380
1330
|
var getObjectPatternPropertyNameForIdentifier2 = (objectPattern, identifierName) => {
|
|
1381
1331
|
for (const property of objectPattern.properties) {
|
|
1382
|
-
if (property.type
|
|
1383
|
-
|
|
1332
|
+
if (property.type === import_utils9.AST_NODE_TYPES.Property && property.value.type === import_utils9.AST_NODE_TYPES.Identifier && property.value.name === identifierName) {
|
|
1333
|
+
return getStaticPropertyName6(property.key);
|
|
1384
1334
|
}
|
|
1385
|
-
return getStaticPropertyName6(property.key);
|
|
1386
1335
|
}
|
|
1387
1336
|
return void 0;
|
|
1388
1337
|
};
|
|
1389
1338
|
var getNamedFileWatcherBindingName = (context, identifier) => {
|
|
1390
1339
|
const definition = getDefinitionForIdentifier2(context, identifier);
|
|
1391
|
-
if (
|
|
1340
|
+
if (!(0, import_ts_extras12.isDefined)(definition)) {
|
|
1392
1341
|
return void 0;
|
|
1393
1342
|
}
|
|
1394
1343
|
const source = getDefinitionModuleSource2(definition.node);
|
|
@@ -1424,39 +1373,37 @@ var getFileWatcherFactoryName = (context, callee) => {
|
|
|
1424
1373
|
var isDiscardedFileWatcherHandle = (node) => {
|
|
1425
1374
|
let current = node;
|
|
1426
1375
|
let parent = getParentNode(current);
|
|
1427
|
-
while (
|
|
1428
|
-
const wrappedExpression =
|
|
1429
|
-
if (wrappedExpression
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
const unaryParent = getParentNode(parent);
|
|
1439
|
-
return unaryParent?.type === import_utils9.AST_NODE_TYPES.ExpressionStatement;
|
|
1376
|
+
while ((0, import_ts_extras12.isDefined)(parent)) {
|
|
1377
|
+
const wrappedExpression = getTransparentWrappedExpression4(parent);
|
|
1378
|
+
if (wrappedExpression !== current) {
|
|
1379
|
+
if (parent.type === import_utils9.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1380
|
+
return true;
|
|
1381
|
+
}
|
|
1382
|
+
if (parent.type === import_utils9.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1383
|
+
const unaryParent = getParentNode(parent);
|
|
1384
|
+
return unaryParent?.type === import_utils9.AST_NODE_TYPES.ExpressionStatement;
|
|
1385
|
+
}
|
|
1386
|
+
return false;
|
|
1440
1387
|
}
|
|
1441
|
-
|
|
1388
|
+
current = parent;
|
|
1389
|
+
parent = getParentNode(current);
|
|
1442
1390
|
}
|
|
1443
1391
|
return false;
|
|
1444
1392
|
};
|
|
1445
1393
|
var isImmediateFileWatcherMethodReceiver = (node) => {
|
|
1446
1394
|
let current = node;
|
|
1447
1395
|
let parent = getParentNode(current);
|
|
1448
|
-
while (
|
|
1449
|
-
const wrappedExpression =
|
|
1450
|
-
if (wrappedExpression
|
|
1451
|
-
current
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
return false;
|
|
1396
|
+
while ((0, import_ts_extras12.isDefined)(parent)) {
|
|
1397
|
+
const wrappedExpression = getTransparentWrappedExpression4(parent);
|
|
1398
|
+
if (wrappedExpression !== current) {
|
|
1399
|
+
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)) {
|
|
1400
|
+
return false;
|
|
1401
|
+
}
|
|
1402
|
+
const callExpression = getParentNode(parent);
|
|
1403
|
+
return callExpression?.type === import_utils9.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
1457
1404
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1405
|
+
current = parent;
|
|
1406
|
+
parent = getParentNode(current);
|
|
1460
1407
|
}
|
|
1461
1408
|
return false;
|
|
1462
1409
|
};
|
|
@@ -1465,7 +1412,7 @@ var noFloatingFileWatchers = createTypedRule({
|
|
|
1465
1412
|
return {
|
|
1466
1413
|
CallExpression(node) {
|
|
1467
1414
|
const factoryName = getFileWatcherFactoryName(context, node.callee);
|
|
1468
|
-
if (factoryName
|
|
1415
|
+
if (!(0, import_ts_extras12.isDefined)(factoryName) || !isDiscardedFileWatcherHandle(node) && !isImmediateFileWatcherMethodReceiver(node)) {
|
|
1469
1416
|
return;
|
|
1470
1417
|
}
|
|
1471
1418
|
context.report({
|
|
@@ -1502,10 +1449,11 @@ var no_floating_file_watchers_default = noFloatingFileWatchers;
|
|
|
1502
1449
|
|
|
1503
1450
|
// dist/rules/no-floating-geolocation-watches.js
|
|
1504
1451
|
var import_utils10 = require("@typescript-eslint/utils");
|
|
1452
|
+
var import_ts_extras13 = require("ts-extras");
|
|
1505
1453
|
var geolocationWatchFunctionName = "watchPosition";
|
|
1506
1454
|
var globalNavigatorReceiverNames = ["globalThis", "window"];
|
|
1507
1455
|
var globalNavigatorReceiverNameSet = new Set(globalNavigatorReceiverNames);
|
|
1508
|
-
var
|
|
1456
|
+
var getTransparentWrappedExpression5 = (node) => {
|
|
1509
1457
|
if (node.type === import_utils10.AST_NODE_TYPES.ChainExpression) {
|
|
1510
1458
|
return node.expression;
|
|
1511
1459
|
}
|
|
@@ -1541,7 +1489,7 @@ var collectStaticMemberPath2 = (node) => {
|
|
|
1541
1489
|
}
|
|
1542
1490
|
const objectPath = collectStaticMemberPath2(node.object);
|
|
1543
1491
|
const propertyName = getStaticPropertyName7(node.property, node.computed);
|
|
1544
|
-
return objectPath
|
|
1492
|
+
return !(0, import_ts_extras13.isDefined)(objectPath) || !(0, import_ts_extras13.isDefined)(propertyName) ? void 0 : [...objectPath, propertyName];
|
|
1545
1493
|
};
|
|
1546
1494
|
var isShadowedNavigatorIdentifier = (context, identifier) => {
|
|
1547
1495
|
const scope = context.sourceCode.getScope(identifier);
|
|
@@ -1561,32 +1509,31 @@ var isNavigatorPathShadowed = (context, callee) => {
|
|
|
1561
1509
|
const rootIdentifier = getRootIdentifier(callee.object);
|
|
1562
1510
|
return rootIdentifier?.name === "navigator" && isShadowedNavigatorIdentifier(context, rootIdentifier);
|
|
1563
1511
|
};
|
|
1564
|
-
var isGeolocationWatchPath = (path) => path.length === 3 &&
|
|
1512
|
+
var isGeolocationWatchPath = (path) => path.length === 3 && (0, import_ts_extras13.arrayFirst)(path) === "navigator" && path[1] === "geolocation" && path[2] === geolocationWatchFunctionName || path.length === 4 && (0, import_ts_extras13.setHas)(globalNavigatorReceiverNameSet, (0, import_ts_extras13.arrayFirst)(path) ?? "") && path[1] === "navigator" && path[2] === "geolocation" && path[3] === geolocationWatchFunctionName;
|
|
1565
1513
|
var isGeolocationWatchCall = (context, callee) => {
|
|
1566
1514
|
if (callee.type !== import_utils10.AST_NODE_TYPES.MemberExpression || isNavigatorPathShadowed(context, callee)) {
|
|
1567
1515
|
return false;
|
|
1568
1516
|
}
|
|
1569
1517
|
const path = collectStaticMemberPath2(callee);
|
|
1570
|
-
return path
|
|
1518
|
+
return (0, import_ts_extras13.isDefined)(path) && isGeolocationWatchPath(path);
|
|
1571
1519
|
};
|
|
1572
1520
|
var isDiscardedWatchId = (node) => {
|
|
1573
1521
|
let current = node;
|
|
1574
1522
|
let parent = getParentNode(current);
|
|
1575
|
-
while (
|
|
1576
|
-
const wrappedExpression =
|
|
1577
|
-
if (wrappedExpression
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
const unaryParent = getParentNode(parent);
|
|
1587
|
-
return unaryParent?.type === import_utils10.AST_NODE_TYPES.ExpressionStatement;
|
|
1523
|
+
while ((0, import_ts_extras13.isDefined)(parent)) {
|
|
1524
|
+
const wrappedExpression = getTransparentWrappedExpression5(parent);
|
|
1525
|
+
if (wrappedExpression !== current) {
|
|
1526
|
+
if (parent.type === import_utils10.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1527
|
+
return true;
|
|
1528
|
+
}
|
|
1529
|
+
if (parent.type === import_utils10.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1530
|
+
const unaryParent = getParentNode(parent);
|
|
1531
|
+
return unaryParent?.type === import_utils10.AST_NODE_TYPES.ExpressionStatement;
|
|
1532
|
+
}
|
|
1533
|
+
return false;
|
|
1588
1534
|
}
|
|
1589
|
-
|
|
1535
|
+
current = parent;
|
|
1536
|
+
parent = getParentNode(current);
|
|
1590
1537
|
}
|
|
1591
1538
|
return false;
|
|
1592
1539
|
};
|
|
@@ -1630,20 +1577,23 @@ var no_floating_geolocation_watches_default = noFloatingGeolocationWatches;
|
|
|
1630
1577
|
|
|
1631
1578
|
// dist/rules/no-floating-infinite-animations.js
|
|
1632
1579
|
var import_utils11 = require("@typescript-eslint/utils");
|
|
1580
|
+
var import_ts_extras15 = require("ts-extras");
|
|
1633
1581
|
|
|
1634
1582
|
// dist/_internal/type-checker.js
|
|
1635
|
-
var
|
|
1636
|
-
|
|
1583
|
+
var import_ts_extras14 = require("ts-extras");
|
|
1584
|
+
var hasTypeNameInHierarchy = (checker, candidate, expectedTypeName, seenTypes = /* @__PURE__ */ new Set()) => {
|
|
1585
|
+
const seenCandidate = candidate;
|
|
1586
|
+
if ((0, import_ts_extras14.setHas)(seenTypes, seenCandidate)) {
|
|
1637
1587
|
return false;
|
|
1638
1588
|
}
|
|
1639
1589
|
const nextSeenTypes = new Set(seenTypes);
|
|
1640
|
-
nextSeenTypes.add(
|
|
1641
|
-
if (
|
|
1642
|
-
return
|
|
1590
|
+
nextSeenTypes.add(candidate);
|
|
1591
|
+
if (candidate.isUnionOrIntersection()) {
|
|
1592
|
+
return candidate.types.some((entry) => hasTypeNameInHierarchy(checker, entry, expectedTypeName, nextSeenTypes));
|
|
1643
1593
|
}
|
|
1644
|
-
const apparentType = checker.getApparentType(
|
|
1645
|
-
const
|
|
1646
|
-
if (
|
|
1594
|
+
const apparentType = checker.getApparentType(candidate);
|
|
1595
|
+
const candidateName = apparentType.symbol.getName();
|
|
1596
|
+
if (candidateName === expectedTypeName) {
|
|
1647
1597
|
return true;
|
|
1648
1598
|
}
|
|
1649
1599
|
if (!apparentType.isClassOrInterface()) {
|
|
@@ -1668,7 +1618,7 @@ var isNumberPositiveInfinity = (node) => {
|
|
|
1668
1618
|
if (node.optional) {
|
|
1669
1619
|
return false;
|
|
1670
1620
|
}
|
|
1671
|
-
const propertyName =
|
|
1621
|
+
const propertyName = getStaticPropertyName(node.property, node.computed);
|
|
1672
1622
|
if (propertyName !== "POSITIVE_INFINITY") {
|
|
1673
1623
|
return false;
|
|
1674
1624
|
}
|
|
@@ -1678,7 +1628,7 @@ var isNumberPositiveInfinity = (node) => {
|
|
|
1678
1628
|
if (node.object.type !== import_utils11.AST_NODE_TYPES.MemberExpression) {
|
|
1679
1629
|
return false;
|
|
1680
1630
|
}
|
|
1681
|
-
const objectPropertyName =
|
|
1631
|
+
const objectPropertyName = getStaticPropertyName(node.object.property, node.object.computed);
|
|
1682
1632
|
return objectPropertyName === "Number" && node.object.object.type === import_utils11.AST_NODE_TYPES.Identifier && (node.object.object.name === "globalThis" || node.object.object.name === "window");
|
|
1683
1633
|
};
|
|
1684
1634
|
var isInfinityExpression = (context, node) => {
|
|
@@ -1690,7 +1640,7 @@ var isInfinityExpression = (context, node) => {
|
|
|
1690
1640
|
}
|
|
1691
1641
|
return node.type === import_utils11.AST_NODE_TYPES.MemberExpression && isNumberPositiveInfinity(node);
|
|
1692
1642
|
};
|
|
1693
|
-
var getPropertyKeyName = (property) =>
|
|
1643
|
+
var getPropertyKeyName = (property) => getStaticPropertyName(property.key, property.computed);
|
|
1694
1644
|
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
1645
|
var hasInfiniteIterationsOption = (context, options) => {
|
|
1696
1646
|
if (options.type !== import_utils11.AST_NODE_TYPES.ObjectExpression) {
|
|
@@ -1710,7 +1660,7 @@ var getAnimationReceiver = (callee) => {
|
|
|
1710
1660
|
if (callee.object.type === import_utils11.AST_NODE_TYPES.Super) {
|
|
1711
1661
|
return void 0;
|
|
1712
1662
|
}
|
|
1713
|
-
const propertyName =
|
|
1663
|
+
const propertyName = getStaticPropertyName(callee.property, callee.computed);
|
|
1714
1664
|
return propertyName === "animate" ? callee.object : void 0;
|
|
1715
1665
|
};
|
|
1716
1666
|
var isReceiverElement = (context, receiver) => {
|
|
@@ -1723,8 +1673,8 @@ var noFloatingInfiniteAnimations = createTypedRule({
|
|
|
1723
1673
|
return {
|
|
1724
1674
|
CallExpression(node) {
|
|
1725
1675
|
const receiver = getAnimationReceiver(node.callee);
|
|
1726
|
-
const timingOptions = node.arguments
|
|
1727
|
-
if (receiver
|
|
1676
|
+
const timingOptions = (0, import_ts_extras15.arrayAt)(node.arguments, 1);
|
|
1677
|
+
if (!(0, import_ts_extras15.isDefined)(receiver) || !(0, import_ts_extras15.isDefined)(timingOptions) || !hasInfiniteIterationsOption(context, timingOptions) || !isReceiverElement(context, receiver) || !isDiscardedResourceExpression(node) && !isImmediateUnownedMemberReceiver(node, animationCleanupMemberNames)) {
|
|
1728
1678
|
return;
|
|
1729
1679
|
}
|
|
1730
1680
|
context.report({
|
|
@@ -1759,6 +1709,7 @@ var no_floating_infinite_animations_default = noFloatingInfiniteAnimations;
|
|
|
1759
1709
|
|
|
1760
1710
|
// dist/rules/no-floating-media-streams.js
|
|
1761
1711
|
var import_utils12 = require("@typescript-eslint/utils");
|
|
1712
|
+
var import_ts_extras16 = require("ts-extras");
|
|
1762
1713
|
var mediaCaptureFunctionNames = [
|
|
1763
1714
|
"getDisplayMedia",
|
|
1764
1715
|
"getUserMedia"
|
|
@@ -1766,8 +1717,8 @@ var mediaCaptureFunctionNames = [
|
|
|
1766
1717
|
var globalNavigatorReceiverNames2 = ["globalThis", "window"];
|
|
1767
1718
|
var mediaCaptureFunctionNameSet = new Set(mediaCaptureFunctionNames);
|
|
1768
1719
|
var globalNavigatorReceiverNameSet2 = new Set(globalNavigatorReceiverNames2);
|
|
1769
|
-
var isMediaCaptureFunctionName = (name) =>
|
|
1770
|
-
var
|
|
1720
|
+
var isMediaCaptureFunctionName = (name) => (0, import_ts_extras16.setHas)(mediaCaptureFunctionNameSet, name);
|
|
1721
|
+
var getTransparentWrappedExpression6 = (node) => {
|
|
1771
1722
|
if (node.type === import_utils12.AST_NODE_TYPES.AwaitExpression) {
|
|
1772
1723
|
return node.argument;
|
|
1773
1724
|
}
|
|
@@ -1806,7 +1757,7 @@ var collectStaticMemberPath3 = (node) => {
|
|
|
1806
1757
|
}
|
|
1807
1758
|
const objectPath = collectStaticMemberPath3(node.object);
|
|
1808
1759
|
const propertyName = getStaticPropertyName8(node.property, node.computed);
|
|
1809
|
-
return objectPath
|
|
1760
|
+
return !(0, import_ts_extras16.isDefined)(objectPath) || !(0, import_ts_extras16.isDefined)(propertyName) ? void 0 : [...objectPath, propertyName];
|
|
1810
1761
|
};
|
|
1811
1762
|
var isShadowedNavigatorIdentifier2 = (context, identifier) => {
|
|
1812
1763
|
const scope = context.sourceCode.getScope(identifier);
|
|
@@ -1827,14 +1778,14 @@ var isNavigatorPathShadowed2 = (context, callee) => {
|
|
|
1827
1778
|
return rootIdentifier?.name === "navigator" && isShadowedNavigatorIdentifier2(context, rootIdentifier);
|
|
1828
1779
|
};
|
|
1829
1780
|
var getMediaCaptureNameFromPath = (path) => {
|
|
1830
|
-
const captureName =
|
|
1831
|
-
if (captureName
|
|
1781
|
+
const captureName = (0, import_ts_extras16.arrayAt)(path, -1);
|
|
1782
|
+
if (!(0, import_ts_extras16.isDefined)(captureName) || !isMediaCaptureFunctionName(captureName)) {
|
|
1832
1783
|
return void 0;
|
|
1833
1784
|
}
|
|
1834
|
-
if (path.length === 3 &&
|
|
1785
|
+
if (path.length === 3 && (0, import_ts_extras16.arrayFirst)(path) === "navigator" && path[1] === "mediaDevices") {
|
|
1835
1786
|
return captureName;
|
|
1836
1787
|
}
|
|
1837
|
-
if (path.length === 4 && globalNavigatorReceiverNameSet2.
|
|
1788
|
+
if (path.length === 4 && (0, import_ts_extras16.setHas)(globalNavigatorReceiverNameSet2, (0, import_ts_extras16.arrayFirst)(path) ?? "") && path[1] === "navigator" && path[2] === "mediaDevices") {
|
|
1838
1789
|
return captureName;
|
|
1839
1790
|
}
|
|
1840
1791
|
return void 0;
|
|
@@ -1844,26 +1795,25 @@ var getMediaCaptureFunctionName = (context, callee) => {
|
|
|
1844
1795
|
return void 0;
|
|
1845
1796
|
}
|
|
1846
1797
|
const path = collectStaticMemberPath3(callee);
|
|
1847
|
-
return path
|
|
1798
|
+
return (0, import_ts_extras16.isDefined)(path) ? getMediaCaptureNameFromPath(path) : void 0;
|
|
1848
1799
|
};
|
|
1849
1800
|
var isDiscardedMediaStreamRequest = (node) => {
|
|
1850
1801
|
let current = node;
|
|
1851
1802
|
let parent = getParentNode(current);
|
|
1852
|
-
while (
|
|
1853
|
-
const wrappedExpression =
|
|
1854
|
-
if (wrappedExpression
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
const unaryParent = getParentNode(parent);
|
|
1864
|
-
return unaryParent?.type === import_utils12.AST_NODE_TYPES.ExpressionStatement;
|
|
1803
|
+
while ((0, import_ts_extras16.isDefined)(parent)) {
|
|
1804
|
+
const wrappedExpression = getTransparentWrappedExpression6(parent);
|
|
1805
|
+
if (wrappedExpression !== current) {
|
|
1806
|
+
if (parent.type === import_utils12.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1807
|
+
return true;
|
|
1808
|
+
}
|
|
1809
|
+
if (parent.type === import_utils12.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1810
|
+
const unaryParent = getParentNode(parent);
|
|
1811
|
+
return unaryParent?.type === import_utils12.AST_NODE_TYPES.ExpressionStatement;
|
|
1812
|
+
}
|
|
1813
|
+
return false;
|
|
1865
1814
|
}
|
|
1866
|
-
|
|
1815
|
+
current = parent;
|
|
1816
|
+
parent = getParentNode(current);
|
|
1867
1817
|
}
|
|
1868
1818
|
return false;
|
|
1869
1819
|
};
|
|
@@ -1872,7 +1822,7 @@ var noFloatingMediaStreams = createTypedRule({
|
|
|
1872
1822
|
return {
|
|
1873
1823
|
CallExpression(node) {
|
|
1874
1824
|
const captureName = getMediaCaptureFunctionName(context, node.callee);
|
|
1875
|
-
if (captureName
|
|
1825
|
+
if (!(0, import_ts_extras16.isDefined)(captureName) || !isDiscardedMediaStreamRequest(node)) {
|
|
1876
1826
|
return;
|
|
1877
1827
|
}
|
|
1878
1828
|
context.report({
|
|
@@ -1909,6 +1859,7 @@ var no_floating_media_streams_default = noFloatingMediaStreams;
|
|
|
1909
1859
|
|
|
1910
1860
|
// dist/rules/no-floating-message-channels.js
|
|
1911
1861
|
var import_utils13 = require("@typescript-eslint/utils");
|
|
1862
|
+
var import_ts_extras17 = require("ts-extras");
|
|
1912
1863
|
var messageChannelConstructorName = "MessageChannel";
|
|
1913
1864
|
var messagePortPropertyNames = ["port1", "port2"];
|
|
1914
1865
|
var globalReceiverNames5 = [
|
|
@@ -1918,9 +1869,9 @@ var globalReceiverNames5 = [
|
|
|
1918
1869
|
];
|
|
1919
1870
|
var globalReceiverNameSet5 = new Set(globalReceiverNames5);
|
|
1920
1871
|
var messagePortPropertyNameSet = new Set(messagePortPropertyNames);
|
|
1921
|
-
var isGlobalReceiverName4 = (name) =>
|
|
1922
|
-
var isMessagePortPropertyName = (name) =>
|
|
1923
|
-
var
|
|
1872
|
+
var isGlobalReceiverName4 = (name) => (0, import_ts_extras17.setHas)(globalReceiverNameSet5, name);
|
|
1873
|
+
var isMessagePortPropertyName = (name) => (0, import_ts_extras17.setHas)(messagePortPropertyNameSet, name);
|
|
1874
|
+
var getTransparentWrappedExpression7 = (node) => {
|
|
1924
1875
|
if (node.type === import_utils13.AST_NODE_TYPES.ChainExpression) {
|
|
1925
1876
|
return node.expression;
|
|
1926
1877
|
}
|
|
@@ -1958,39 +1909,37 @@ var isMessageChannelConstructor = (context, callee) => isDirectMessageChannelCon
|
|
|
1958
1909
|
var isDiscardedMessageChannel = (node) => {
|
|
1959
1910
|
let current = node;
|
|
1960
1911
|
let parent = getParentNode(current);
|
|
1961
|
-
while (
|
|
1962
|
-
const wrappedExpression =
|
|
1963
|
-
if (wrappedExpression
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
const unaryParent = getParentNode(parent);
|
|
1973
|
-
return unaryParent?.type === import_utils13.AST_NODE_TYPES.ExpressionStatement;
|
|
1912
|
+
while ((0, import_ts_extras17.isDefined)(parent)) {
|
|
1913
|
+
const wrappedExpression = getTransparentWrappedExpression7(parent);
|
|
1914
|
+
if (wrappedExpression !== current) {
|
|
1915
|
+
if (parent.type === import_utils13.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
1916
|
+
return true;
|
|
1917
|
+
}
|
|
1918
|
+
if (parent.type === import_utils13.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
1919
|
+
const unaryParent = getParentNode(parent);
|
|
1920
|
+
return unaryParent?.type === import_utils13.AST_NODE_TYPES.ExpressionStatement;
|
|
1921
|
+
}
|
|
1922
|
+
return false;
|
|
1974
1923
|
}
|
|
1975
|
-
|
|
1924
|
+
current = parent;
|
|
1925
|
+
parent = getParentNode(current);
|
|
1976
1926
|
}
|
|
1977
1927
|
return false;
|
|
1978
1928
|
};
|
|
1979
1929
|
var isImmediateMessagePortAccess = (node) => {
|
|
1980
1930
|
let current = node;
|
|
1981
1931
|
let parent = getParentNode(current);
|
|
1982
|
-
while (
|
|
1983
|
-
const wrappedExpression =
|
|
1984
|
-
if (wrappedExpression
|
|
1985
|
-
current
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
return false;
|
|
1932
|
+
while ((0, import_ts_extras17.isDefined)(parent)) {
|
|
1933
|
+
const wrappedExpression = getTransparentWrappedExpression7(parent);
|
|
1934
|
+
if (wrappedExpression !== current) {
|
|
1935
|
+
if (parent.type !== import_utils13.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
1936
|
+
return false;
|
|
1937
|
+
}
|
|
1938
|
+
const propertyName = getStaticPropertyName9(parent.property, parent.computed);
|
|
1939
|
+
return (0, import_ts_extras17.isDefined)(propertyName) && isMessagePortPropertyName(propertyName);
|
|
1991
1940
|
}
|
|
1992
|
-
|
|
1993
|
-
|
|
1941
|
+
current = parent;
|
|
1942
|
+
parent = getParentNode(current);
|
|
1994
1943
|
}
|
|
1995
1944
|
return false;
|
|
1996
1945
|
};
|
|
@@ -2034,6 +1983,7 @@ var no_floating_message_channels_default = noFloatingMessageChannels;
|
|
|
2034
1983
|
|
|
2035
1984
|
// dist/rules/no-floating-network-connections.js
|
|
2036
1985
|
var import_utils14 = require("@typescript-eslint/utils");
|
|
1986
|
+
var import_ts_extras18 = require("ts-extras");
|
|
2037
1987
|
var networkConnectionConstructorNames = [
|
|
2038
1988
|
"EventSource",
|
|
2039
1989
|
"WebSocket"
|
|
@@ -2045,9 +1995,9 @@ var globalReceiverNames6 = [
|
|
|
2045
1995
|
];
|
|
2046
1996
|
var networkConnectionConstructorNameSet = new Set(networkConnectionConstructorNames);
|
|
2047
1997
|
var globalReceiverNameSet6 = new Set(globalReceiverNames6);
|
|
2048
|
-
var isNetworkConnectionConstructorName = (name) =>
|
|
2049
|
-
var isGlobalReceiverName5 = (name) =>
|
|
2050
|
-
var
|
|
1998
|
+
var isNetworkConnectionConstructorName = (name) => (0, import_ts_extras18.setHas)(networkConnectionConstructorNameSet, name);
|
|
1999
|
+
var isGlobalReceiverName5 = (name) => (0, import_ts_extras18.setHas)(globalReceiverNameSet6, name);
|
|
2000
|
+
var getTransparentWrappedExpression8 = (node) => {
|
|
2051
2001
|
if (node.type === import_utils14.AST_NODE_TYPES.ChainExpression) {
|
|
2052
2002
|
return node.expression;
|
|
2053
2003
|
}
|
|
@@ -2090,48 +2040,46 @@ var getMemberNetworkConnectionConstructorName = (callee) => {
|
|
|
2090
2040
|
return void 0;
|
|
2091
2041
|
}
|
|
2092
2042
|
const constructorName = getStaticPropertyName10(callee.property, callee.computed);
|
|
2093
|
-
return constructorName
|
|
2043
|
+
return (0, import_ts_extras18.isDefined)(constructorName) && isNetworkConnectionConstructorName(constructorName) ? constructorName : void 0;
|
|
2094
2044
|
};
|
|
2095
2045
|
var getNetworkConnectionConstructorName = (context, callee) => getDirectNetworkConnectionConstructorName(context, callee) ?? getMemberNetworkConnectionConstructorName(callee);
|
|
2096
2046
|
var isDiscardedNetworkConnection = (node) => {
|
|
2097
2047
|
let current = node;
|
|
2098
2048
|
let parent = getParentNode(current);
|
|
2099
|
-
while (
|
|
2100
|
-
const wrappedExpression =
|
|
2101
|
-
if (wrappedExpression
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
const unaryParent = getParentNode(parent);
|
|
2111
|
-
return unaryParent?.type === import_utils14.AST_NODE_TYPES.ExpressionStatement;
|
|
2049
|
+
while ((0, import_ts_extras18.isDefined)(parent)) {
|
|
2050
|
+
const wrappedExpression = getTransparentWrappedExpression8(parent);
|
|
2051
|
+
if (wrappedExpression !== current) {
|
|
2052
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2053
|
+
return true;
|
|
2054
|
+
}
|
|
2055
|
+
if (parent.type === import_utils14.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2056
|
+
const unaryParent = getParentNode(parent);
|
|
2057
|
+
return unaryParent?.type === import_utils14.AST_NODE_TYPES.ExpressionStatement;
|
|
2058
|
+
}
|
|
2059
|
+
return false;
|
|
2112
2060
|
}
|
|
2113
|
-
|
|
2061
|
+
current = parent;
|
|
2062
|
+
parent = getParentNode(current);
|
|
2114
2063
|
}
|
|
2115
2064
|
return false;
|
|
2116
2065
|
};
|
|
2117
2066
|
var isImmediateNetworkConnectionMethodReceiver = (node) => {
|
|
2118
2067
|
let current = node;
|
|
2119
2068
|
let parent = getParentNode(current);
|
|
2120
|
-
while (
|
|
2121
|
-
const wrappedExpression =
|
|
2122
|
-
if (wrappedExpression
|
|
2123
|
-
current
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
return false;
|
|
2069
|
+
while ((0, import_ts_extras18.isDefined)(parent)) {
|
|
2070
|
+
const wrappedExpression = getTransparentWrappedExpression8(parent);
|
|
2071
|
+
if (wrappedExpression !== current) {
|
|
2072
|
+
if (parent.type !== import_utils14.AST_NODE_TYPES.MemberExpression || parent.object !== current || parent.optional) {
|
|
2073
|
+
return false;
|
|
2074
|
+
}
|
|
2075
|
+
if (getStaticPropertyName10(parent.property, parent.computed) === "close") {
|
|
2076
|
+
return false;
|
|
2077
|
+
}
|
|
2078
|
+
const callExpression = getParentNode(parent);
|
|
2079
|
+
return callExpression?.type === import_utils14.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
2132
2080
|
}
|
|
2133
|
-
|
|
2134
|
-
|
|
2081
|
+
current = parent;
|
|
2082
|
+
parent = getParentNode(current);
|
|
2135
2083
|
}
|
|
2136
2084
|
return false;
|
|
2137
2085
|
};
|
|
@@ -2140,7 +2088,7 @@ var noFloatingNetworkConnections = createTypedRule({
|
|
|
2140
2088
|
return {
|
|
2141
2089
|
NewExpression(node) {
|
|
2142
2090
|
const connectionName = getNetworkConnectionConstructorName(context, node.callee);
|
|
2143
|
-
if (connectionName
|
|
2091
|
+
if (!(0, import_ts_extras18.isDefined)(connectionName) || !isDiscardedNetworkConnection(node) && !isImmediateNetworkConnectionMethodReceiver(node)) {
|
|
2144
2092
|
return;
|
|
2145
2093
|
}
|
|
2146
2094
|
context.report({
|
|
@@ -2177,6 +2125,7 @@ var no_floating_network_connections_default = noFloatingNetworkConnections;
|
|
|
2177
2125
|
|
|
2178
2126
|
// dist/rules/no-floating-object-urls.js
|
|
2179
2127
|
var import_utils15 = require("@typescript-eslint/utils");
|
|
2128
|
+
var import_ts_extras19 = require("ts-extras");
|
|
2180
2129
|
var globalUrlReceiverNames = ["globalThis", "self", "window"];
|
|
2181
2130
|
var globalUrlReceiverNameSet = new Set(globalUrlReceiverNames);
|
|
2182
2131
|
var getRootIdentifier3 = (node) => {
|
|
@@ -2190,14 +2139,14 @@ var isShadowedIdentifier3 = (context, identifier) => {
|
|
|
2190
2139
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2191
2140
|
return variable !== null && variable.defs.length > 0;
|
|
2192
2141
|
};
|
|
2193
|
-
var isDirectUrlPath = (path) => path.length === 2 &&
|
|
2194
|
-
var isGlobalUrlPath = (path) => path.length === 3 && globalUrlReceiverNameSet.
|
|
2142
|
+
var isDirectUrlPath = (path) => path.length === 2 && (0, import_ts_extras19.arrayFirst)(path) === "URL" && path[1] === "createObjectURL";
|
|
2143
|
+
var isGlobalUrlPath = (path) => path.length === 3 && (0, import_ts_extras19.setHas)(globalUrlReceiverNameSet, (0, import_ts_extras19.arrayFirst)(path) ?? "") && path[1] === "URL" && path[2] === "createObjectURL";
|
|
2195
2144
|
var isObjectUrlCreateCall = (context, callee) => {
|
|
2196
2145
|
if (callee.type !== import_utils15.AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
2197
2146
|
return false;
|
|
2198
2147
|
}
|
|
2199
2148
|
const path = collectStaticMemberPath(callee);
|
|
2200
|
-
if (path
|
|
2149
|
+
if (!(0, import_ts_extras19.isDefined)(path) || !isDirectUrlPath(path) && !isGlobalUrlPath(path)) {
|
|
2201
2150
|
return false;
|
|
2202
2151
|
}
|
|
2203
2152
|
const rootIdentifier = getRootIdentifier3(callee.object);
|
|
@@ -2243,6 +2192,7 @@ var no_floating_object_urls_default = noFloatingObjectUrls;
|
|
|
2243
2192
|
|
|
2244
2193
|
// dist/rules/no-floating-observers.js
|
|
2245
2194
|
var import_utils16 = require("@typescript-eslint/utils");
|
|
2195
|
+
var import_ts_extras20 = require("ts-extras");
|
|
2246
2196
|
var observerConstructorNames = [
|
|
2247
2197
|
"IntersectionObserver",
|
|
2248
2198
|
"MutationObserver",
|
|
@@ -2257,9 +2207,9 @@ var globalReceiverNames7 = [
|
|
|
2257
2207
|
];
|
|
2258
2208
|
var globalReceiverNameSet7 = new Set(globalReceiverNames7);
|
|
2259
2209
|
var observerConstructorNameSet = new Set(observerConstructorNames);
|
|
2260
|
-
var isGlobalReceiverName6 = (name) =>
|
|
2261
|
-
var isObserverConstructorName = (name) =>
|
|
2262
|
-
var
|
|
2210
|
+
var isGlobalReceiverName6 = (name) => (0, import_ts_extras20.setHas)(globalReceiverNameSet7, name);
|
|
2211
|
+
var isObserverConstructorName = (name) => (0, import_ts_extras20.setHas)(observerConstructorNameSet, name);
|
|
2212
|
+
var getTransparentWrappedExpression9 = (node) => {
|
|
2263
2213
|
if (node.type === import_utils16.AST_NODE_TYPES.ChainExpression) {
|
|
2264
2214
|
return node.expression;
|
|
2265
2215
|
}
|
|
@@ -2298,39 +2248,37 @@ var getObserverConstructorName = (context, callee) => getDirectObserverConstruct
|
|
|
2298
2248
|
var isObserveMethodCallReceiver = (node) => {
|
|
2299
2249
|
let current = node;
|
|
2300
2250
|
let parent = getParentNode(current);
|
|
2301
|
-
while (
|
|
2302
|
-
const wrappedExpression =
|
|
2303
|
-
if (wrappedExpression
|
|
2304
|
-
current
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
return false;
|
|
2251
|
+
while ((0, import_ts_extras20.isDefined)(parent)) {
|
|
2252
|
+
const wrappedExpression = getTransparentWrappedExpression9(parent);
|
|
2253
|
+
if (wrappedExpression !== current) {
|
|
2254
|
+
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") {
|
|
2255
|
+
return false;
|
|
2256
|
+
}
|
|
2257
|
+
const callExpression = getParentNode(parent);
|
|
2258
|
+
return callExpression?.type === import_utils16.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
2310
2259
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2260
|
+
current = parent;
|
|
2261
|
+
parent = getParentNode(current);
|
|
2313
2262
|
}
|
|
2314
2263
|
return false;
|
|
2315
2264
|
};
|
|
2316
2265
|
var isDiscardedObserverInstance = (node) => {
|
|
2317
2266
|
let current = node;
|
|
2318
2267
|
let parent = getParentNode(current);
|
|
2319
|
-
while (
|
|
2320
|
-
const wrappedExpression =
|
|
2321
|
-
if (wrappedExpression
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
const unaryParent = getParentNode(parent);
|
|
2331
|
-
return unaryParent?.type === import_utils16.AST_NODE_TYPES.ExpressionStatement;
|
|
2268
|
+
while ((0, import_ts_extras20.isDefined)(parent)) {
|
|
2269
|
+
const wrappedExpression = getTransparentWrappedExpression9(parent);
|
|
2270
|
+
if (wrappedExpression !== current) {
|
|
2271
|
+
if (parent.type === import_utils16.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2272
|
+
return true;
|
|
2273
|
+
}
|
|
2274
|
+
if (parent.type === import_utils16.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2275
|
+
const unaryParent = getParentNode(parent);
|
|
2276
|
+
return unaryParent?.type === import_utils16.AST_NODE_TYPES.ExpressionStatement;
|
|
2277
|
+
}
|
|
2278
|
+
return false;
|
|
2332
2279
|
}
|
|
2333
|
-
|
|
2280
|
+
current = parent;
|
|
2281
|
+
parent = getParentNode(current);
|
|
2334
2282
|
}
|
|
2335
2283
|
return false;
|
|
2336
2284
|
};
|
|
@@ -2339,7 +2287,7 @@ var noFloatingObservers = createTypedRule({
|
|
|
2339
2287
|
return {
|
|
2340
2288
|
NewExpression(node) {
|
|
2341
2289
|
const observerName = getObserverConstructorName(context, node.callee);
|
|
2342
|
-
if (observerName
|
|
2290
|
+
if (!(0, import_ts_extras20.isDefined)(observerName) || !isDiscardedObserverInstance(node) && !isObserveMethodCallReceiver(node)) {
|
|
2343
2291
|
return;
|
|
2344
2292
|
}
|
|
2345
2293
|
context.report({
|
|
@@ -2376,6 +2324,7 @@ var no_floating_observers_default = noFloatingObservers;
|
|
|
2376
2324
|
|
|
2377
2325
|
// dist/rules/no-floating-servers.js
|
|
2378
2326
|
var import_utils17 = require("@typescript-eslint/utils");
|
|
2327
|
+
var import_ts_extras21 = require("ts-extras");
|
|
2379
2328
|
var serverFactoryNames = [
|
|
2380
2329
|
"createSecureServer",
|
|
2381
2330
|
"createServer"
|
|
@@ -2398,13 +2347,13 @@ var http2OnlyServerFactoryNameSet = new Set(http2OnlyServerFactoryNames);
|
|
|
2398
2347
|
var serverModuleNameSet = new Set(serverModuleNames);
|
|
2399
2348
|
var http2ServerModuleNameSet = new Set(http2ServerModuleNames);
|
|
2400
2349
|
var immediateCleanupMethodNameSet3 = new Set(immediateCleanupMethodNames3);
|
|
2401
|
-
var isServerFactoryName = (name) =>
|
|
2402
|
-
var isHttp2OnlyServerFactoryName = (name) =>
|
|
2403
|
-
var isServerModuleSource = (source) => source
|
|
2404
|
-
var isHttp2ServerModuleSource = (source) => source
|
|
2405
|
-
var isImmediateCleanupMethodName3 = (name) =>
|
|
2350
|
+
var isServerFactoryName = (name) => (0, import_ts_extras21.setHas)(serverFactoryNameSet, name);
|
|
2351
|
+
var isHttp2OnlyServerFactoryName = (name) => (0, import_ts_extras21.setHas)(http2OnlyServerFactoryNameSet, name);
|
|
2352
|
+
var isServerModuleSource = (source) => (0, import_ts_extras21.isDefined)(source) && (0, import_ts_extras21.setHas)(serverModuleNameSet, source);
|
|
2353
|
+
var isHttp2ServerModuleSource = (source) => (0, import_ts_extras21.isDefined)(source) && (0, import_ts_extras21.setHas)(http2ServerModuleNameSet, source);
|
|
2354
|
+
var isImmediateCleanupMethodName3 = (name) => (0, import_ts_extras21.setHas)(immediateCleanupMethodNameSet3, name);
|
|
2406
2355
|
var isValidServerFactoryForSource = (source, factoryName) => isServerModuleSource(source) && isServerFactoryName(factoryName) && (!isHttp2OnlyServerFactoryName(factoryName) || isHttp2ServerModuleSource(source));
|
|
2407
|
-
var
|
|
2356
|
+
var getTransparentWrappedExpression10 = (node) => {
|
|
2408
2357
|
if (node.type === import_utils17.AST_NODE_TYPES.ChainExpression) {
|
|
2409
2358
|
return node.expression;
|
|
2410
2359
|
}
|
|
@@ -2457,35 +2406,34 @@ var getDefinitionModuleSource3 = (node) => {
|
|
|
2457
2406
|
var getDefinitionForIdentifier3 = (context, identifier) => {
|
|
2458
2407
|
const scope = context.sourceCode.getScope(identifier);
|
|
2459
2408
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2460
|
-
return variable?.defs[
|
|
2409
|
+
return (0, import_ts_extras21.arrayFirst)(variable?.defs ?? []);
|
|
2461
2410
|
};
|
|
2462
2411
|
var getImportedSpecifierName3 = (node) => getStaticPropertyName11(node.imported);
|
|
2463
2412
|
var getObjectPatternPropertyNameForIdentifier3 = (objectPattern, identifierName) => {
|
|
2464
2413
|
for (const property of objectPattern.properties) {
|
|
2465
|
-
if (property.type
|
|
2466
|
-
|
|
2414
|
+
if (property.type === import_utils17.AST_NODE_TYPES.Property && property.value.type === import_utils17.AST_NODE_TYPES.Identifier && property.value.name === identifierName) {
|
|
2415
|
+
return getStaticPropertyName11(property.key);
|
|
2467
2416
|
}
|
|
2468
|
-
return getStaticPropertyName11(property.key);
|
|
2469
2417
|
}
|
|
2470
2418
|
return void 0;
|
|
2471
2419
|
};
|
|
2472
2420
|
var getModuleSourceForBinding = (context, identifier) => {
|
|
2473
2421
|
const definition = getDefinitionForIdentifier3(context, identifier);
|
|
2474
|
-
return definition
|
|
2422
|
+
return (0, import_ts_extras21.isDefined)(definition) ? getDefinitionModuleSource3(definition.node) : void 0;
|
|
2475
2423
|
};
|
|
2476
2424
|
var getNamedServerFactoryBindingName = (context, identifier) => {
|
|
2477
2425
|
const definition = getDefinitionForIdentifier3(context, identifier);
|
|
2478
|
-
if (
|
|
2426
|
+
if (!(0, import_ts_extras21.isDefined)(definition)) {
|
|
2479
2427
|
return void 0;
|
|
2480
2428
|
}
|
|
2481
2429
|
const source = getDefinitionModuleSource3(definition.node);
|
|
2482
2430
|
if (definition.node.type === import_utils17.AST_NODE_TYPES.ImportSpecifier) {
|
|
2483
2431
|
const importedName = getImportedSpecifierName3(definition.node);
|
|
2484
|
-
return importedName
|
|
2432
|
+
return (0, import_ts_extras21.isDefined)(importedName) && isValidServerFactoryForSource(source, importedName) ? importedName : void 0;
|
|
2485
2433
|
}
|
|
2486
2434
|
if (definition.node.type === import_utils17.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils17.AST_NODE_TYPES.ObjectPattern) {
|
|
2487
2435
|
const propertyName = getObjectPatternPropertyNameForIdentifier3(definition.node.id, identifier.name);
|
|
2488
|
-
return propertyName
|
|
2436
|
+
return (0, import_ts_extras21.isDefined)(propertyName) && isValidServerFactoryForSource(source, propertyName) ? propertyName : void 0;
|
|
2489
2437
|
}
|
|
2490
2438
|
return void 0;
|
|
2491
2439
|
};
|
|
@@ -2514,45 +2462,43 @@ var getServerFactoryName = (context, callee) => {
|
|
|
2514
2462
|
var isDiscardedExpression = (node) => {
|
|
2515
2463
|
let current = node;
|
|
2516
2464
|
let parent = getParentNode(current);
|
|
2517
|
-
while (
|
|
2518
|
-
const wrappedExpression =
|
|
2519
|
-
if (wrappedExpression
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
const unaryParent = getParentNode(parent);
|
|
2529
|
-
return unaryParent?.type === import_utils17.AST_NODE_TYPES.ExpressionStatement;
|
|
2465
|
+
while ((0, import_ts_extras21.isDefined)(parent)) {
|
|
2466
|
+
const wrappedExpression = getTransparentWrappedExpression10(parent);
|
|
2467
|
+
if (wrappedExpression !== current) {
|
|
2468
|
+
if (parent.type === import_utils17.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2469
|
+
return true;
|
|
2470
|
+
}
|
|
2471
|
+
if (parent.type === import_utils17.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2472
|
+
const unaryParent = getParentNode(parent);
|
|
2473
|
+
return unaryParent?.type === import_utils17.AST_NODE_TYPES.ExpressionStatement;
|
|
2474
|
+
}
|
|
2475
|
+
return false;
|
|
2530
2476
|
}
|
|
2531
|
-
|
|
2477
|
+
current = parent;
|
|
2478
|
+
parent = getParentNode(current);
|
|
2532
2479
|
}
|
|
2533
2480
|
return false;
|
|
2534
2481
|
};
|
|
2535
2482
|
var getImmediateServerMethodCall = (node) => {
|
|
2536
2483
|
let current = node;
|
|
2537
2484
|
let parent = getParentNode(current);
|
|
2538
|
-
while (
|
|
2539
|
-
const wrappedExpression =
|
|
2540
|
-
if (wrappedExpression
|
|
2541
|
-
current
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
return void 0;
|
|
2485
|
+
while ((0, import_ts_extras21.isDefined)(parent)) {
|
|
2486
|
+
const wrappedExpression = getTransparentWrappedExpression10(parent);
|
|
2487
|
+
if (wrappedExpression !== current) {
|
|
2488
|
+
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)) {
|
|
2489
|
+
return void 0;
|
|
2490
|
+
}
|
|
2491
|
+
const callExpression = getParentNode(parent);
|
|
2492
|
+
return callExpression?.type === import_utils17.AST_NODE_TYPES.CallExpression && callExpression.callee === parent ? callExpression : void 0;
|
|
2547
2493
|
}
|
|
2548
|
-
|
|
2549
|
-
|
|
2494
|
+
current = parent;
|
|
2495
|
+
parent = getParentNode(current);
|
|
2550
2496
|
}
|
|
2551
2497
|
return void 0;
|
|
2552
2498
|
};
|
|
2553
2499
|
var isDiscardedImmediateServerMethodChain = (node) => {
|
|
2554
2500
|
let currentCall = getImmediateServerMethodCall(node);
|
|
2555
|
-
while (
|
|
2501
|
+
while ((0, import_ts_extras21.isDefined)(currentCall)) {
|
|
2556
2502
|
if (isDiscardedExpression(currentCall)) {
|
|
2557
2503
|
return true;
|
|
2558
2504
|
}
|
|
@@ -2566,7 +2512,7 @@ var noFloatingServers = createTypedRule({
|
|
|
2566
2512
|
return {
|
|
2567
2513
|
CallExpression(node) {
|
|
2568
2514
|
const factoryName = getServerFactoryName(context, node.callee);
|
|
2569
|
-
if (factoryName
|
|
2515
|
+
if (!(0, import_ts_extras21.isDefined)(factoryName) || !isDiscardedServerHandle(node)) {
|
|
2570
2516
|
return;
|
|
2571
2517
|
}
|
|
2572
2518
|
context.report({
|
|
@@ -2603,6 +2549,7 @@ var no_floating_servers_default = noFloatingServers;
|
|
|
2603
2549
|
|
|
2604
2550
|
// dist/rules/no-floating-streams.js
|
|
2605
2551
|
var import_utils18 = require("@typescript-eslint/utils");
|
|
2552
|
+
var import_ts_extras22 = require("ts-extras");
|
|
2606
2553
|
var fileStreamFactoryNames = [
|
|
2607
2554
|
"createReadStream",
|
|
2608
2555
|
"createWriteStream"
|
|
@@ -2610,8 +2557,8 @@ var fileStreamFactoryNames = [
|
|
|
2610
2557
|
var fsModuleNames2 = ["fs", "node:fs"];
|
|
2611
2558
|
var fileStreamFactoryNameSet = new Set(fileStreamFactoryNames);
|
|
2612
2559
|
var fsModuleNameSet2 = new Set(fsModuleNames2);
|
|
2613
|
-
var isFileStreamFactoryName = (name) =>
|
|
2614
|
-
var
|
|
2560
|
+
var isFileStreamFactoryName = (name) => (0, import_ts_extras22.setHas)(fileStreamFactoryNameSet, name);
|
|
2561
|
+
var getTransparentWrappedExpression11 = (node) => {
|
|
2615
2562
|
if (node.type === import_utils18.AST_NODE_TYPES.ChainExpression) {
|
|
2616
2563
|
return node.expression;
|
|
2617
2564
|
}
|
|
@@ -2664,26 +2611,25 @@ var getDefinitionModuleSource4 = (node) => {
|
|
|
2664
2611
|
var getImportedSpecifierName4 = (node) => getStaticPropertyName12(node.imported);
|
|
2665
2612
|
var getObjectPatternPropertyNameForIdentifier4 = (objectPattern, identifierName) => {
|
|
2666
2613
|
for (const property of objectPattern.properties) {
|
|
2667
|
-
if (property.type
|
|
2668
|
-
|
|
2614
|
+
if (property.type === import_utils18.AST_NODE_TYPES.Property && property.value.type === import_utils18.AST_NODE_TYPES.Identifier && property.value.name === identifierName) {
|
|
2615
|
+
return getStaticPropertyName12(property.key);
|
|
2669
2616
|
}
|
|
2670
|
-
return getStaticPropertyName12(property.key);
|
|
2671
2617
|
}
|
|
2672
2618
|
return void 0;
|
|
2673
2619
|
};
|
|
2674
|
-
var isFsModuleSource2 = (source) => source
|
|
2620
|
+
var isFsModuleSource2 = (source) => (0, import_ts_extras22.isDefined)(source) && (0, import_ts_extras22.setHas)(fsModuleNameSet2, source);
|
|
2675
2621
|
var getDefinitionForIdentifier4 = (context, identifier) => {
|
|
2676
2622
|
const scope = context.sourceCode.getScope(identifier);
|
|
2677
2623
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
2678
|
-
return variable?.defs[
|
|
2624
|
+
return (0, import_ts_extras22.arrayFirst)(variable?.defs ?? []);
|
|
2679
2625
|
};
|
|
2680
2626
|
var isFsModuleBinding2 = (context, identifier) => {
|
|
2681
2627
|
const definition = getDefinitionForIdentifier4(context, identifier);
|
|
2682
|
-
return definition
|
|
2628
|
+
return (0, import_ts_extras22.isDefined)(definition) && isFsModuleSource2(getDefinitionModuleSource4(definition.node));
|
|
2683
2629
|
};
|
|
2684
2630
|
var getNamedFileStreamFactoryBindingName = (context, identifier) => {
|
|
2685
2631
|
const definition = getDefinitionForIdentifier4(context, identifier);
|
|
2686
|
-
if (
|
|
2632
|
+
if (!(0, import_ts_extras22.isDefined)(definition)) {
|
|
2687
2633
|
return void 0;
|
|
2688
2634
|
}
|
|
2689
2635
|
const source = getDefinitionModuleSource4(definition.node);
|
|
@@ -2692,11 +2638,11 @@ var getNamedFileStreamFactoryBindingName = (context, identifier) => {
|
|
|
2692
2638
|
}
|
|
2693
2639
|
if (definition.node.type === import_utils18.AST_NODE_TYPES.ImportSpecifier) {
|
|
2694
2640
|
const importedName = getImportedSpecifierName4(definition.node);
|
|
2695
|
-
return importedName
|
|
2641
|
+
return (0, import_ts_extras22.isDefined)(importedName) && isFileStreamFactoryName(importedName) ? importedName : void 0;
|
|
2696
2642
|
}
|
|
2697
2643
|
if (definition.node.type === import_utils18.AST_NODE_TYPES.VariableDeclarator && definition.node.id.type === import_utils18.AST_NODE_TYPES.ObjectPattern) {
|
|
2698
2644
|
const propertyName = getObjectPatternPropertyNameForIdentifier4(definition.node.id, identifier.name);
|
|
2699
|
-
return propertyName
|
|
2645
|
+
return (0, import_ts_extras22.isDefined)(propertyName) && isFileStreamFactoryName(propertyName) ? propertyName : void 0;
|
|
2700
2646
|
}
|
|
2701
2647
|
return void 0;
|
|
2702
2648
|
};
|
|
@@ -2721,21 +2667,20 @@ var getFileStreamFactoryName = (context, callee) => {
|
|
|
2721
2667
|
var isDiscardedFileStreamHandle = (node) => {
|
|
2722
2668
|
let current = node;
|
|
2723
2669
|
let parent = getParentNode(current);
|
|
2724
|
-
while (
|
|
2725
|
-
const wrappedExpression =
|
|
2726
|
-
if (wrappedExpression
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
const unaryParent = getParentNode(parent);
|
|
2736
|
-
return unaryParent?.type === import_utils18.AST_NODE_TYPES.ExpressionStatement;
|
|
2670
|
+
while ((0, import_ts_extras22.isDefined)(parent)) {
|
|
2671
|
+
const wrappedExpression = getTransparentWrappedExpression11(parent);
|
|
2672
|
+
if (wrappedExpression !== current) {
|
|
2673
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2674
|
+
return true;
|
|
2675
|
+
}
|
|
2676
|
+
if (parent.type === import_utils18.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2677
|
+
const unaryParent = getParentNode(parent);
|
|
2678
|
+
return unaryParent?.type === import_utils18.AST_NODE_TYPES.ExpressionStatement;
|
|
2679
|
+
}
|
|
2680
|
+
return false;
|
|
2737
2681
|
}
|
|
2738
|
-
|
|
2682
|
+
current = parent;
|
|
2683
|
+
parent = getParentNode(current);
|
|
2739
2684
|
}
|
|
2740
2685
|
return false;
|
|
2741
2686
|
};
|
|
@@ -2744,7 +2689,7 @@ var noFloatingStreams = createTypedRule({
|
|
|
2744
2689
|
return {
|
|
2745
2690
|
CallExpression(node) {
|
|
2746
2691
|
const factoryName = getFileStreamFactoryName(context, node.callee);
|
|
2747
|
-
if (factoryName
|
|
2692
|
+
if (!(0, import_ts_extras22.isDefined)(factoryName) || !isDiscardedFileStreamHandle(node)) {
|
|
2748
2693
|
return;
|
|
2749
2694
|
}
|
|
2750
2695
|
context.report({
|
|
@@ -2781,6 +2726,7 @@ var no_floating_streams_default = noFloatingStreams;
|
|
|
2781
2726
|
|
|
2782
2727
|
// dist/rules/no-floating-timers.js
|
|
2783
2728
|
var import_utils19 = require("@typescript-eslint/utils");
|
|
2729
|
+
var import_ts_extras23 = require("ts-extras");
|
|
2784
2730
|
var timerFunctionNames = [
|
|
2785
2731
|
"requestAnimationFrame",
|
|
2786
2732
|
"requestIdleCallback",
|
|
@@ -2796,47 +2742,9 @@ var globalReceiverNames8 = [
|
|
|
2796
2742
|
];
|
|
2797
2743
|
var timerFunctionNameSet = new Set(timerFunctionNames);
|
|
2798
2744
|
var globalReceiverNameSet8 = new Set(globalReceiverNames8);
|
|
2799
|
-
var isTimerFunctionName = (name) =>
|
|
2800
|
-
var isGlobalReceiverName7 = (name) =>
|
|
2801
|
-
var
|
|
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
|
-
};
|
|
2745
|
+
var isTimerFunctionName = (name) => (0, import_ts_extras23.setHas)(timerFunctionNameSet, name);
|
|
2746
|
+
var isGlobalReceiverName7 = (name) => (0, import_ts_extras23.setHas)(globalReceiverNameSet8, name);
|
|
2747
|
+
var isDiscardedTimerHandle = (node) => isDiscardedResourceExpression(node);
|
|
2840
2748
|
var isShadowedIdentifier5 = (context, identifier) => {
|
|
2841
2749
|
const scope = context.sourceCode.getScope(identifier);
|
|
2842
2750
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
@@ -2869,13 +2777,13 @@ var noFloatingTimers = createTypedRule({
|
|
|
2869
2777
|
return {
|
|
2870
2778
|
'CallExpression[callee.type="Identifier"]'(node) {
|
|
2871
2779
|
const timerName = getDirectTimerName(context, node.callee);
|
|
2872
|
-
if (
|
|
2780
|
+
if ((0, import_ts_extras23.isDefined)(timerName)) {
|
|
2873
2781
|
reportFloatingTimer(node, timerName);
|
|
2874
2782
|
}
|
|
2875
2783
|
},
|
|
2876
2784
|
'CallExpression[callee.type="MemberExpression"]'(node) {
|
|
2877
2785
|
const timerName = getMemberTimerName(node.callee);
|
|
2878
|
-
if (
|
|
2786
|
+
if ((0, import_ts_extras23.isDefined)(timerName)) {
|
|
2879
2787
|
reportFloatingTimer(node, timerName);
|
|
2880
2788
|
}
|
|
2881
2789
|
}
|
|
@@ -2907,10 +2815,11 @@ var no_floating_timers_default = noFloatingTimers;
|
|
|
2907
2815
|
|
|
2908
2816
|
// dist/rules/no-floating-wake-locks.js
|
|
2909
2817
|
var import_utils20 = require("@typescript-eslint/utils");
|
|
2818
|
+
var import_ts_extras24 = require("ts-extras");
|
|
2910
2819
|
var wakeLockRequestFunctionName = "request";
|
|
2911
2820
|
var globalNavigatorReceiverNames3 = ["globalThis", "window"];
|
|
2912
2821
|
var globalNavigatorReceiverNameSet3 = new Set(globalNavigatorReceiverNames3);
|
|
2913
|
-
var
|
|
2822
|
+
var getTransparentWrappedExpression12 = (node) => {
|
|
2914
2823
|
if (node.type === import_utils20.AST_NODE_TYPES.AwaitExpression) {
|
|
2915
2824
|
return node.argument;
|
|
2916
2825
|
}
|
|
@@ -2949,7 +2858,7 @@ var collectStaticMemberPath4 = (node) => {
|
|
|
2949
2858
|
}
|
|
2950
2859
|
const objectPath = collectStaticMemberPath4(node.object);
|
|
2951
2860
|
const propertyName = getStaticPropertyName13(node.property, node.computed);
|
|
2952
|
-
return objectPath
|
|
2861
|
+
return !(0, import_ts_extras24.isDefined)(objectPath) || !(0, import_ts_extras24.isDefined)(propertyName) ? void 0 : [...objectPath, propertyName];
|
|
2953
2862
|
};
|
|
2954
2863
|
var isShadowedNavigatorIdentifier3 = (context, identifier) => {
|
|
2955
2864
|
const scope = context.sourceCode.getScope(identifier);
|
|
@@ -2969,32 +2878,31 @@ var isNavigatorPathShadowed3 = (context, callee) => {
|
|
|
2969
2878
|
const rootIdentifier = getRootIdentifier4(callee.object);
|
|
2970
2879
|
return rootIdentifier?.name === "navigator" && isShadowedNavigatorIdentifier3(context, rootIdentifier);
|
|
2971
2880
|
};
|
|
2972
|
-
var isWakeLockRequestPath = (path) => path.length === 3 &&
|
|
2881
|
+
var isWakeLockRequestPath = (path) => path.length === 3 && (0, import_ts_extras24.arrayFirst)(path) === "navigator" && path[1] === "wakeLock" && path[2] === wakeLockRequestFunctionName || path.length === 4 && (0, import_ts_extras24.setHas)(globalNavigatorReceiverNameSet3, (0, import_ts_extras24.arrayFirst)(path) ?? "") && path[1] === "navigator" && path[2] === "wakeLock" && path[3] === wakeLockRequestFunctionName;
|
|
2973
2882
|
var isWakeLockRequestCall = (context, callee) => {
|
|
2974
2883
|
if (callee.type !== import_utils20.AST_NODE_TYPES.MemberExpression || isNavigatorPathShadowed3(context, callee)) {
|
|
2975
2884
|
return false;
|
|
2976
2885
|
}
|
|
2977
2886
|
const path = collectStaticMemberPath4(callee);
|
|
2978
|
-
return path
|
|
2887
|
+
return (0, import_ts_extras24.isDefined)(path) && isWakeLockRequestPath(path);
|
|
2979
2888
|
};
|
|
2980
2889
|
var isDiscardedWakeLockRequest = (node) => {
|
|
2981
2890
|
let current = node;
|
|
2982
2891
|
let parent = getParentNode(current);
|
|
2983
|
-
while (
|
|
2984
|
-
const wrappedExpression =
|
|
2985
|
-
if (wrappedExpression
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
const unaryParent = getParentNode(parent);
|
|
2995
|
-
return unaryParent?.type === import_utils20.AST_NODE_TYPES.ExpressionStatement;
|
|
2892
|
+
while ((0, import_ts_extras24.isDefined)(parent)) {
|
|
2893
|
+
const wrappedExpression = getTransparentWrappedExpression12(parent);
|
|
2894
|
+
if (wrappedExpression !== current) {
|
|
2895
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
2896
|
+
return true;
|
|
2897
|
+
}
|
|
2898
|
+
if (parent.type === import_utils20.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
2899
|
+
const unaryParent = getParentNode(parent);
|
|
2900
|
+
return unaryParent?.type === import_utils20.AST_NODE_TYPES.ExpressionStatement;
|
|
2901
|
+
}
|
|
2902
|
+
return false;
|
|
2996
2903
|
}
|
|
2997
|
-
|
|
2904
|
+
current = parent;
|
|
2905
|
+
parent = getParentNode(current);
|
|
2998
2906
|
}
|
|
2999
2907
|
return false;
|
|
3000
2908
|
};
|
|
@@ -3038,6 +2946,7 @@ var no_floating_wake_locks_default = noFloatingWakeLocks;
|
|
|
3038
2946
|
|
|
3039
2947
|
// dist/rules/no-floating-web-stream-locks.js
|
|
3040
2948
|
var import_utils21 = require("@typescript-eslint/utils");
|
|
2949
|
+
var import_ts_extras25 = require("ts-extras");
|
|
3041
2950
|
var lockFactoryNames = ["getReader", "getWriter"];
|
|
3042
2951
|
var cleanupMemberNames2 = /* @__PURE__ */ new Set(["releaseLock"]);
|
|
3043
2952
|
var lockFactoryMetadataByName = {
|
|
@@ -3051,7 +2960,7 @@ var lockFactoryMetadataByName = {
|
|
|
3051
2960
|
}
|
|
3052
2961
|
};
|
|
3053
2962
|
var lockFactoryNameSet = new Set(lockFactoryNames);
|
|
3054
|
-
var isLockFactoryName = (name) =>
|
|
2963
|
+
var isLockFactoryName = (name) => (0, import_ts_extras25.setHas)(lockFactoryNameSet, name);
|
|
3055
2964
|
var getLockFactoryMetadata = (callee) => {
|
|
3056
2965
|
if (callee.type !== import_utils21.AST_NODE_TYPES.MemberExpression || callee.optional) {
|
|
3057
2966
|
return void 0;
|
|
@@ -3059,8 +2968,8 @@ var getLockFactoryMetadata = (callee) => {
|
|
|
3059
2968
|
if (callee.object.type === import_utils21.AST_NODE_TYPES.Super) {
|
|
3060
2969
|
return void 0;
|
|
3061
2970
|
}
|
|
3062
|
-
const factoryName =
|
|
3063
|
-
if (factoryName
|
|
2971
|
+
const factoryName = getStaticPropertyName(callee.property, callee.computed);
|
|
2972
|
+
if (!(0, import_ts_extras25.isDefined)(factoryName) || !isLockFactoryName(factoryName)) {
|
|
3064
2973
|
return void 0;
|
|
3065
2974
|
}
|
|
3066
2975
|
return {
|
|
@@ -3078,7 +2987,7 @@ var noFloatingWebStreamLocks = createTypedRule({
|
|
|
3078
2987
|
return {
|
|
3079
2988
|
CallExpression(node) {
|
|
3080
2989
|
const metadata = getLockFactoryMetadata(node.callee);
|
|
3081
|
-
if (metadata
|
|
2990
|
+
if (!(0, import_ts_extras25.isDefined)(metadata) || !isReceiverExpectedWebStream(context, metadata.receiver, metadata.streamTypeName) || !isDiscardedResourceExpression(node) && !isImmediateUnownedMemberReceiver(node, cleanupMemberNames2)) {
|
|
3082
2991
|
return;
|
|
3083
2992
|
}
|
|
3084
2993
|
context.report({
|
|
@@ -3114,6 +3023,7 @@ var no_floating_web_stream_locks_default = noFloatingWebStreamLocks;
|
|
|
3114
3023
|
|
|
3115
3024
|
// dist/rules/no-floating-workers.js
|
|
3116
3025
|
var import_utils22 = require("@typescript-eslint/utils");
|
|
3026
|
+
var import_ts_extras26 = require("ts-extras");
|
|
3117
3027
|
var browserWorkerConstructorNames = [
|
|
3118
3028
|
"SharedWorker",
|
|
3119
3029
|
"Worker"
|
|
@@ -3130,9 +3040,9 @@ var workerThreadsModuleNames = [
|
|
|
3130
3040
|
var browserWorkerConstructorNameSet = new Set(browserWorkerConstructorNames);
|
|
3131
3041
|
var globalReceiverNameSet9 = new Set(globalReceiverNames9);
|
|
3132
3042
|
var workerThreadsModuleNameSet = new Set(workerThreadsModuleNames);
|
|
3133
|
-
var isBrowserWorkerConstructorName = (name) =>
|
|
3134
|
-
var isGlobalReceiverName8 = (name) =>
|
|
3135
|
-
var
|
|
3043
|
+
var isBrowserWorkerConstructorName = (name) => (0, import_ts_extras26.setHas)(browserWorkerConstructorNameSet, name);
|
|
3044
|
+
var isGlobalReceiverName8 = (name) => (0, import_ts_extras26.setHas)(globalReceiverNameSet9, name);
|
|
3045
|
+
var getTransparentWrappedExpression13 = (node) => {
|
|
3136
3046
|
if (node.type === import_utils22.AST_NODE_TYPES.ChainExpression) {
|
|
3137
3047
|
return node.expression;
|
|
3138
3048
|
}
|
|
@@ -3160,9 +3070,9 @@ var getImportSourceValue5 = (node) => {
|
|
|
3160
3070
|
var isWorkerThreadsImportBinding = (context, identifier) => {
|
|
3161
3071
|
const scope = context.sourceCode.getScope(identifier);
|
|
3162
3072
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
3163
|
-
const definition = variable?.defs[
|
|
3164
|
-
const importSource = definition
|
|
3165
|
-
return identifier.name === "Worker" && importSource
|
|
3073
|
+
const definition = (0, import_ts_extras26.arrayFirst)(variable?.defs ?? []);
|
|
3074
|
+
const importSource = (0, import_ts_extras26.isDefined)(definition) ? getImportSourceValue5(definition.node) : void 0;
|
|
3075
|
+
return identifier.name === "Worker" && (0, import_ts_extras26.isDefined)(importSource) && (0, import_ts_extras26.setHas)(workerThreadsModuleNameSet, importSource);
|
|
3166
3076
|
};
|
|
3167
3077
|
var isShadowedBrowserWorkerIdentifier = (context, identifier) => {
|
|
3168
3078
|
const scope = context.sourceCode.getScope(identifier);
|
|
@@ -3188,39 +3098,37 @@ var getWorkerConstructorName = (context, callee) => getDirectWorkerConstructorNa
|
|
|
3188
3098
|
var isDiscardedWorkerInstance = (node) => {
|
|
3189
3099
|
let current = node;
|
|
3190
3100
|
let parent = getParentNode(current);
|
|
3191
|
-
while (
|
|
3192
|
-
const wrappedExpression =
|
|
3193
|
-
if (wrappedExpression
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
const unaryParent = getParentNode(parent);
|
|
3203
|
-
return unaryParent?.type === import_utils22.AST_NODE_TYPES.ExpressionStatement;
|
|
3101
|
+
while ((0, import_ts_extras26.isDefined)(parent)) {
|
|
3102
|
+
const wrappedExpression = getTransparentWrappedExpression13(parent);
|
|
3103
|
+
if (wrappedExpression !== current) {
|
|
3104
|
+
if (parent.type === import_utils22.AST_NODE_TYPES.ExpressionStatement && parent.expression === current) {
|
|
3105
|
+
return true;
|
|
3106
|
+
}
|
|
3107
|
+
if (parent.type === import_utils22.AST_NODE_TYPES.UnaryExpression && parent.operator === "void" && parent.argument === current) {
|
|
3108
|
+
const unaryParent = getParentNode(parent);
|
|
3109
|
+
return unaryParent?.type === import_utils22.AST_NODE_TYPES.ExpressionStatement;
|
|
3110
|
+
}
|
|
3111
|
+
return false;
|
|
3204
3112
|
}
|
|
3205
|
-
|
|
3113
|
+
current = parent;
|
|
3114
|
+
parent = getParentNode(current);
|
|
3206
3115
|
}
|
|
3207
3116
|
return false;
|
|
3208
3117
|
};
|
|
3209
3118
|
var isImmediateWorkerMethodReceiver = (node) => {
|
|
3210
3119
|
let current = node;
|
|
3211
3120
|
let parent = getParentNode(current);
|
|
3212
|
-
while (
|
|
3213
|
-
const wrappedExpression =
|
|
3214
|
-
if (wrappedExpression
|
|
3215
|
-
current
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
return false;
|
|
3121
|
+
while ((0, import_ts_extras26.isDefined)(parent)) {
|
|
3122
|
+
const wrappedExpression = getTransparentWrappedExpression13(parent);
|
|
3123
|
+
if (wrappedExpression !== current) {
|
|
3124
|
+
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") {
|
|
3125
|
+
return false;
|
|
3126
|
+
}
|
|
3127
|
+
const callExpression = getParentNode(parent);
|
|
3128
|
+
return callExpression?.type === import_utils22.AST_NODE_TYPES.CallExpression && callExpression.callee === parent;
|
|
3221
3129
|
}
|
|
3222
|
-
|
|
3223
|
-
|
|
3130
|
+
current = parent;
|
|
3131
|
+
parent = getParentNode(current);
|
|
3224
3132
|
}
|
|
3225
3133
|
return false;
|
|
3226
3134
|
};
|
|
@@ -3229,7 +3137,7 @@ var noFloatingWorkers = createTypedRule({
|
|
|
3229
3137
|
return {
|
|
3230
3138
|
NewExpression(node) {
|
|
3231
3139
|
const workerName = getWorkerConstructorName(context, node.callee);
|
|
3232
|
-
if (workerName
|
|
3140
|
+
if (!(0, import_ts_extras26.isDefined)(workerName) || !isDiscardedWorkerInstance(node) && !isImmediateWorkerMethodReceiver(node)) {
|
|
3233
3141
|
return;
|
|
3234
3142
|
}
|
|
3235
3143
|
context.report({
|
|
@@ -3266,11 +3174,12 @@ var no_floating_workers_default = noFloatingWorkers;
|
|
|
3266
3174
|
|
|
3267
3175
|
// dist/rules/no-unmanaged-event-listeners.js
|
|
3268
3176
|
var import_utils23 = require("@typescript-eslint/utils");
|
|
3177
|
+
var import_ts_extras27 = require("ts-extras");
|
|
3269
3178
|
var unknownCaptureKey = "*";
|
|
3270
3179
|
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
3180
|
var getCleanupBoundary = (node) => {
|
|
3272
3181
|
let current = node;
|
|
3273
|
-
while (
|
|
3182
|
+
while ((0, import_ts_extras27.isDefined)(current)) {
|
|
3274
3183
|
if (isCleanupBoundary(current)) {
|
|
3275
3184
|
return current;
|
|
3276
3185
|
}
|
|
@@ -3293,7 +3202,7 @@ var isVariableDeclarator = (node) => isUnknownRecord(node) && node["type"] === i
|
|
|
3293
3202
|
var getVariableInitializer = (context, identifier) => {
|
|
3294
3203
|
const scope = context.sourceCode.getScope(identifier);
|
|
3295
3204
|
const variable = getVariableInScopeChain(scope, identifier.name);
|
|
3296
|
-
const definition = variable?.defs[
|
|
3205
|
+
const definition = (0, import_ts_extras27.arrayFirst)(variable?.defs ?? []);
|
|
3297
3206
|
const definitionNode = definition?.node;
|
|
3298
3207
|
if (!isVariableDeclarator(definitionNode)) {
|
|
3299
3208
|
return void 0;
|
|
@@ -3324,18 +3233,18 @@ var getBooleanPropertyValue = (objectExpression, propertyName) => {
|
|
|
3324
3233
|
return void 0;
|
|
3325
3234
|
};
|
|
3326
3235
|
var hasAbortSignalOption = (context, argument) => {
|
|
3327
|
-
if (
|
|
3236
|
+
if (!(0, import_ts_extras27.isDefined)(argument)) {
|
|
3328
3237
|
return false;
|
|
3329
3238
|
}
|
|
3330
3239
|
const resolvedOptions = resolveOptionsExpression(context, argument);
|
|
3331
3240
|
return resolvedOptions?.type === import_utils23.AST_NODE_TYPES.ObjectExpression && objectExpressionHasProperty(resolvedOptions, "signal");
|
|
3332
3241
|
};
|
|
3333
3242
|
var getCaptureKey = (context, argument) => {
|
|
3334
|
-
if (
|
|
3243
|
+
if (!(0, import_ts_extras27.isDefined)(argument)) {
|
|
3335
3244
|
return "false";
|
|
3336
3245
|
}
|
|
3337
3246
|
const resolvedOptions = resolveOptionsExpression(context, argument);
|
|
3338
|
-
if (
|
|
3247
|
+
if (!(0, import_ts_extras27.isDefined)(resolvedOptions)) {
|
|
3339
3248
|
return unknownCaptureKey;
|
|
3340
3249
|
}
|
|
3341
3250
|
if (resolvedOptions.type === import_utils23.AST_NODE_TYPES.Literal && typeof resolvedOptions.value === "boolean") {
|
|
@@ -3343,7 +3252,7 @@ var getCaptureKey = (context, argument) => {
|
|
|
3343
3252
|
}
|
|
3344
3253
|
if (resolvedOptions.type === import_utils23.AST_NODE_TYPES.ObjectExpression) {
|
|
3345
3254
|
const captureValue = getBooleanPropertyValue(resolvedOptions, "capture");
|
|
3346
|
-
return captureValue
|
|
3255
|
+
return (0, import_ts_extras27.isDefined)(captureValue) ? String(captureValue) : "false";
|
|
3347
3256
|
}
|
|
3348
3257
|
return unknownCaptureKey;
|
|
3349
3258
|
};
|
|
@@ -3352,7 +3261,7 @@ var getCleanupKey = (context, node) => {
|
|
|
3352
3261
|
return void 0;
|
|
3353
3262
|
}
|
|
3354
3263
|
const [eventType, listener, options] = node.arguments;
|
|
3355
|
-
if (eventType
|
|
3264
|
+
if (!(0, import_ts_extras27.isDefined)(eventType) || !(0, import_ts_extras27.isDefined)(listener) || eventType.type === import_utils23.AST_NODE_TYPES.SpreadElement || listener.type === import_utils23.AST_NODE_TYPES.SpreadElement) {
|
|
3356
3265
|
return void 0;
|
|
3357
3266
|
}
|
|
3358
3267
|
const targetText = context.sourceCode.getText(node.callee.object);
|
|
@@ -3362,8 +3271,8 @@ var getCleanupKey = (context, node) => {
|
|
|
3362
3271
|
return `${targetText}\0${eventTypeText}\0${listenerText}\0${captureKey}`;
|
|
3363
3272
|
};
|
|
3364
3273
|
var getWildcardCleanupKey = (cleanupKey) => {
|
|
3365
|
-
const [targetText, eventTypeText, listenerText] =
|
|
3366
|
-
if (targetText
|
|
3274
|
+
const [targetText, eventTypeText, listenerText] = (0, import_ts_extras27.stringSplit)(cleanupKey, "\0");
|
|
3275
|
+
if (!(0, import_ts_extras27.isDefined)(targetText) || !(0, import_ts_extras27.isDefined)(eventTypeText) || !(0, import_ts_extras27.isDefined)(listenerText)) {
|
|
3367
3276
|
throw new TypeError("Expected a complete event listener cleanup key.");
|
|
3368
3277
|
}
|
|
3369
3278
|
return `${targetText}\0${eventTypeText}\0${listenerText}\0${unknownCaptureKey}`;
|
|
@@ -3374,7 +3283,7 @@ var noUnmanagedEventListeners = createTypedRule({
|
|
|
3374
3283
|
const removesByBoundary = /* @__PURE__ */ new Map();
|
|
3375
3284
|
const addRecord = (boundary, record) => {
|
|
3376
3285
|
const records = addsByBoundary.get(boundary);
|
|
3377
|
-
if (
|
|
3286
|
+
if (!(0, import_ts_extras27.isDefined)(records)) {
|
|
3378
3287
|
addsByBoundary.set(boundary, [record]);
|
|
3379
3288
|
return;
|
|
3380
3289
|
}
|
|
@@ -3382,7 +3291,7 @@ var noUnmanagedEventListeners = createTypedRule({
|
|
|
3382
3291
|
};
|
|
3383
3292
|
const addRemoveKey = (boundary, cleanupKey) => {
|
|
3384
3293
|
const cleanupKeys = removesByBoundary.get(boundary);
|
|
3385
|
-
if (
|
|
3294
|
+
if (!(0, import_ts_extras27.isDefined)(cleanupKeys)) {
|
|
3386
3295
|
removesByBoundary.set(boundary, /* @__PURE__ */ new Set([cleanupKey]));
|
|
3387
3296
|
return;
|
|
3388
3297
|
}
|
|
@@ -3392,7 +3301,7 @@ var noUnmanagedEventListeners = createTypedRule({
|
|
|
3392
3301
|
'CallExpression[callee.type="MemberExpression"]'(node) {
|
|
3393
3302
|
if (isMethodCallNamed(node.callee, "addEventListener") && !hasAbortSignalOption(context, node.arguments[2])) {
|
|
3394
3303
|
const cleanupKey = getCleanupKey(context, node);
|
|
3395
|
-
if (
|
|
3304
|
+
if ((0, import_ts_extras27.isDefined)(cleanupKey)) {
|
|
3396
3305
|
addRecord(getCleanupBoundary(node), {
|
|
3397
3306
|
cleanupKey,
|
|
3398
3307
|
node
|
|
@@ -3401,7 +3310,7 @@ var noUnmanagedEventListeners = createTypedRule({
|
|
|
3401
3310
|
}
|
|
3402
3311
|
if (isMethodCallNamed(node.callee, "removeEventListener")) {
|
|
3403
3312
|
const cleanupKey = getCleanupKey(context, node);
|
|
3404
|
-
if (
|
|
3313
|
+
if ((0, import_ts_extras27.isDefined)(cleanupKey)) {
|
|
3405
3314
|
addRemoveKey(getCleanupBoundary(node), cleanupKey);
|
|
3406
3315
|
}
|
|
3407
3316
|
}
|
|
@@ -3410,13 +3319,12 @@ var noUnmanagedEventListeners = createTypedRule({
|
|
|
3410
3319
|
for (const [boundary, addRecords] of addsByBoundary) {
|
|
3411
3320
|
const removeKeys = removesByBoundary.get(boundary) ?? /* @__PURE__ */ new Set();
|
|
3412
3321
|
for (const { cleanupKey, node } of addRecords) {
|
|
3413
|
-
if (
|
|
3414
|
-
|
|
3322
|
+
if (!(0, import_ts_extras27.setHas)(removeKeys, cleanupKey) && !(0, import_ts_extras27.setHas)(removeKeys, getWildcardCleanupKey(cleanupKey))) {
|
|
3323
|
+
context.report({
|
|
3324
|
+
messageId: "unmanagedEventListener",
|
|
3325
|
+
node
|
|
3326
|
+
});
|
|
3415
3327
|
}
|
|
3416
|
-
context.report({
|
|
3417
|
-
messageId: "unmanagedEventListener",
|
|
3418
|
-
node
|
|
3419
|
-
});
|
|
3420
3328
|
}
|
|
3421
3329
|
}
|
|
3422
3330
|
}
|
|
@@ -3472,6 +3380,7 @@ var runtimeCleanupRuleRegistry = {
|
|
|
3472
3380
|
var runtimeCleanupRules = runtimeCleanupRuleRegistry;
|
|
3473
3381
|
|
|
3474
3382
|
// dist/_internal/runtime-cleanup-config-references.js
|
|
3383
|
+
var import_ts_extras28 = require("ts-extras");
|
|
3475
3384
|
var runtimeCleanupConfigNames = [
|
|
3476
3385
|
"all",
|
|
3477
3386
|
"experimental",
|
|
@@ -3482,37 +3391,37 @@ var runtimeCleanupConfigNames = [
|
|
|
3482
3391
|
];
|
|
3483
3392
|
var runtimeCleanupConfigMetadataByName = {
|
|
3484
3393
|
all: {
|
|
3485
|
-
icon: "
|
|
3394
|
+
icon: "\u{1F7E3}",
|
|
3486
3395
|
presetName: "runtime-cleanup:all",
|
|
3487
3396
|
readmeOrder: 5,
|
|
3488
3397
|
requiresTypeChecking: true
|
|
3489
3398
|
},
|
|
3490
3399
|
experimental: {
|
|
3491
|
-
icon: "
|
|
3400
|
+
icon: "\u{1F9EA}",
|
|
3492
3401
|
presetName: "runtime-cleanup:experimental",
|
|
3493
3402
|
readmeOrder: 6,
|
|
3494
3403
|
requiresTypeChecking: false
|
|
3495
3404
|
},
|
|
3496
3405
|
minimal: {
|
|
3497
|
-
icon: "
|
|
3406
|
+
icon: "\u{1F7E2}",
|
|
3498
3407
|
presetName: "runtime-cleanup:minimal",
|
|
3499
3408
|
readmeOrder: 1,
|
|
3500
3409
|
requiresTypeChecking: false
|
|
3501
3410
|
},
|
|
3502
3411
|
recommended: {
|
|
3503
|
-
icon: "
|
|
3412
|
+
icon: "\u{1F7E1}",
|
|
3504
3413
|
presetName: "runtime-cleanup:recommended",
|
|
3505
3414
|
readmeOrder: 2,
|
|
3506
3415
|
requiresTypeChecking: false
|
|
3507
3416
|
},
|
|
3508
3417
|
"recommended-type-checked": {
|
|
3509
|
-
icon: "
|
|
3418
|
+
icon: "\u{1F9EC}",
|
|
3510
3419
|
presetName: "runtime-cleanup:recommended-type-checked",
|
|
3511
3420
|
readmeOrder: 3,
|
|
3512
3421
|
requiresTypeChecking: true
|
|
3513
3422
|
},
|
|
3514
3423
|
strict: {
|
|
3515
|
-
icon: "
|
|
3424
|
+
icon: "\u{1F534}",
|
|
3516
3425
|
presetName: "runtime-cleanup:strict",
|
|
3517
3426
|
readmeOrder: 4,
|
|
3518
3427
|
requiresTypeChecking: true
|
|
@@ -3520,7 +3429,7 @@ var runtimeCleanupConfigMetadataByName = {
|
|
|
3520
3429
|
};
|
|
3521
3430
|
|
|
3522
3431
|
// dist/plugin.js
|
|
3523
|
-
var
|
|
3432
|
+
var TS_FILES = ["**/*.{ts,tsx,mts,cts}"];
|
|
3524
3433
|
function getPackageVersion(pkg) {
|
|
3525
3434
|
if (typeof pkg !== "object" || pkg === null) {
|
|
3526
3435
|
return "0.0.0";
|
|
@@ -3528,7 +3437,7 @@ function getPackageVersion(pkg) {
|
|
|
3528
3437
|
const version = Reflect.get(pkg, "version");
|
|
3529
3438
|
return typeof version === "string" ? version : "0.0.0";
|
|
3530
3439
|
}
|
|
3531
|
-
var
|
|
3440
|
+
var tsParserValue = import_parser.default;
|
|
3532
3441
|
var defaultParserOptions = {
|
|
3533
3442
|
ecmaVersion: "latest",
|
|
3534
3443
|
sourceType: "module"
|
|
@@ -3639,17 +3548,17 @@ function withRuntimeCleanupPlugin(config, plugin, options) {
|
|
|
3639
3548
|
const existingLanguageOptions = config.languageOptions ?? {};
|
|
3640
3549
|
const existingParserOptions = existingLanguageOptions["parserOptions"];
|
|
3641
3550
|
const parserOptions = normalizeParserOptions(existingParserOptions);
|
|
3642
|
-
if (options.requiresTypeChecking && !
|
|
3551
|
+
if (options.requiresTypeChecking && !(0, import_ts_extras29.objectHasOwn)(parserOptions, "projectService")) {
|
|
3643
3552
|
Reflect.set(parserOptions, "projectService", true);
|
|
3644
3553
|
}
|
|
3645
3554
|
const languageOptions = {
|
|
3646
3555
|
...existingLanguageOptions,
|
|
3647
|
-
parser: existingLanguageOptions["parser"] ??
|
|
3556
|
+
parser: existingLanguageOptions["parser"] ?? tsParserValue,
|
|
3648
3557
|
parserOptions
|
|
3649
3558
|
};
|
|
3650
3559
|
return {
|
|
3651
3560
|
...config,
|
|
3652
|
-
files: config.files ?? [...
|
|
3561
|
+
files: config.files ?? [...TS_FILES],
|
|
3653
3562
|
languageOptions,
|
|
3654
3563
|
plugins: {
|
|
3655
3564
|
...config.plugins,
|
|
@@ -3671,7 +3580,7 @@ var createPresetConfig = (configName) => {
|
|
|
3671
3580
|
};
|
|
3672
3581
|
var createRuntimeCleanupConfigsDefinition = () => (
|
|
3673
3582
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Object.fromEntries cannot preserve the finite preset-key union.
|
|
3674
|
-
|
|
3583
|
+
(0, import_ts_extras29.objectFromEntries)(runtimeCleanupConfigNames.map((configName) => [
|
|
3675
3584
|
configName,
|
|
3676
3585
|
createPresetConfig(configName)
|
|
3677
3586
|
]))
|