@jupyter/eslint-plugin 1.0.0 → 1.1.0

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.
Files changed (35) hide show
  1. package/lib/index.d.ts +68 -0
  2. package/lib/index.js +42 -11
  3. package/lib/rules/galata-prefer-filebrowser-helper.d.ts +5 -0
  4. package/lib/rules/galata-prefer-filebrowser-helper.js +105 -0
  5. package/lib/rules/incorrect-translator-usage.d.ts +4 -0
  6. package/lib/rules/incorrect-translator-usage.js +208 -0
  7. package/lib/rules/no-dynamic-translation.d.ts +4 -0
  8. package/lib/rules/no-dynamic-translation.js +92 -0
  9. package/lib/rules/no-pageconfig-base-url.d.ts +4 -0
  10. package/lib/rules/no-pageconfig-base-url.js +37 -0
  11. package/lib/rules/no-translation-concatenation.js +46 -84
  12. package/lib/rules/no-untranslated-string.js +7 -4
  13. package/lib/rules/plugin-activation-args.js +6 -2
  14. package/lib/rules/prefer-signal-this-arg.d.ts +7 -0
  15. package/lib/rules/prefer-signal-this-arg.js +196 -0
  16. package/lib/rules/require-disposable-ownership.d.ts +5 -0
  17. package/lib/rules/require-disposable-ownership.js +120 -0
  18. package/lib/rules/require-disposable-transfer.d.ts +5 -0
  19. package/lib/rules/require-disposable-transfer.js +223 -0
  20. package/lib/rules/require-signal-cleanup.d.ts +8 -0
  21. package/lib/rules/require-signal-cleanup.js +164 -0
  22. package/lib/rules/require-signal-this-arg.d.ts +5 -0
  23. package/lib/rules/require-signal-this-arg.js +74 -0
  24. package/lib/rules/token-format.js +1 -2
  25. package/lib/utils/disposables.d.ts +64 -0
  26. package/lib/utils/disposables.js +1723 -0
  27. package/lib/utils/playwright-selectors.d.ts +66 -0
  28. package/lib/utils/playwright-selectors.js +193 -0
  29. package/lib/utils/signal-lifetime.d.ts +158 -0
  30. package/lib/utils/signal-lifetime.js +755 -0
  31. package/lib/utils/signals.d.ts +143 -0
  32. package/lib/utils/signals.js +601 -0
  33. package/lib/utils/translation.d.ts +45 -0
  34. package/lib/utils/translation.js +122 -0
  35. package/package.json +11 -4
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Jupyter Development Team.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ const utils_1 = require("@typescript-eslint/utils");
7
+ const create_rule_1 = require("../utils/create-rule");
8
+ const disposables_1 = require("../utils/disposables");
9
+ const DEFAULT_IGNORED_RETURN_FUNCTION_NAMES = [
10
+ '_adjacentBar',
11
+ '_currentTabBar',
12
+ '_findWidgetByID',
13
+ '_handleNewSession',
14
+ 'add',
15
+ 'addTab',
16
+ 'addCommand',
17
+ 'addCommandToolbarButtonClass',
18
+ 'addFileType',
19
+ 'addGroup',
20
+ 'addItem',
21
+ 'addKeyBinding',
22
+ 'addToolbarButtonClass',
23
+ 'addWidgetExtension',
24
+ 'contextForWidget',
25
+ 'contextMenuWidget',
26
+ 'defaultWidgetFactory',
27
+ 'delete',
28
+ 'find',
29
+ 'findWidget',
30
+ 'get',
31
+ 'getCurrent',
32
+ 'getLanguageServerManager',
33
+ 'getLogger',
34
+ 'getManager',
35
+ 'getModelFactory',
36
+ 'getWidgetFactory',
37
+ 'initializeState',
38
+ 'insertCell',
39
+ 'insertItem',
40
+ 'insertTab',
41
+ 'open',
42
+ 'openInspector',
43
+ 'openOrReveal',
44
+ 'pop',
45
+ 'popLastModifiedCell',
46
+ 'register',
47
+ 'registerItem',
48
+ 'registerStatusItem',
49
+ 'requestCreateSubshell',
50
+ 'requestDebug',
51
+ 'requestDeleteSubshell',
52
+ 'set',
53
+ 'shift',
54
+ 'widgetAt',
55
+ 'widgetRenderer',
56
+ 'transform'
57
+ ];
58
+ function isDefaultIgnoredFactoryReturnFunctionName(name) {
59
+ return /^add[A-Za-z0-9_$]*Factory$/.test(name);
60
+ }
61
+ function isLikelyDisposableFactoryCall(node) {
62
+ if ((0, disposables_1.isDisposableSetFactoryCall)(node)) {
63
+ return true;
64
+ }
65
+ const name = (0, disposables_1.getCalleeName)(node.callee);
66
+ return name !== null && /^(build|create|make|new)[A-Z0-9_$]/.test(name);
67
+ }
68
+ const requireDisposableTransfer = (0, create_rule_1.createRule)({
69
+ name: 'require-disposable-transfer',
70
+ meta: {
71
+ type: 'problem',
72
+ docs: {
73
+ description: 'Require calls returning IDisposable to be stored, returned, added to a DisposableSet, or disposed',
74
+ url: 'https://eslint-plugin.readthedocs.io/en/latest/rules/require-disposable-transfer/'
75
+ },
76
+ messages: {
77
+ unhandledDisposable: 'IDisposable returned from "{{ name }}" must be stored, returned, added to a DisposableSet, or disposed.',
78
+ unmanagedDisposableVariable: 'IDisposable "{{ name }}" must be returned, added to a DisposableSet, assigned to a field, or disposed.'
79
+ },
80
+ schema: [
81
+ {
82
+ type: 'object',
83
+ properties: {
84
+ ownershipFunctionNames: {
85
+ type: 'array',
86
+ items: { type: 'string' },
87
+ description: 'Function or method names that take ownership of a disposable argument. Added to the built-in defaults unless extendDefaultOwnershipFunctionNames is false.'
88
+ },
89
+ extendDefaultOwnershipFunctionNames: {
90
+ type: 'boolean',
91
+ default: true,
92
+ description: 'Whether ownershipFunctionNames extends the built-in defaults. Set to false to replace them, or to drop them entirely when no list is given.'
93
+ },
94
+ ignoredReturnFunctionNames: {
95
+ type: 'array',
96
+ items: { type: 'string' },
97
+ description: 'Function or method names whose disposable return value is intentionally ignored. Added to the built-in defaults unless extendDefaultIgnoredReturnFunctionNames is false.'
98
+ },
99
+ extendDefaultIgnoredReturnFunctionNames: {
100
+ type: 'boolean',
101
+ default: true,
102
+ description: 'Whether ignoredReturnFunctionNames extends the built-in defaults, including the add*Factory and this._map.set()/delete() exemptions. Set to false to replace them, or to drop them entirely when no list is given.'
103
+ },
104
+ checkAllDisposableReturns: {
105
+ type: 'boolean',
106
+ default: false,
107
+ description: 'Check every call whose return type is disposable, not only factory-named calls (create*, build*, make*, new*).'
108
+ }
109
+ },
110
+ additionalProperties: false
111
+ }
112
+ ]
113
+ },
114
+ defaultOptions: [{}],
115
+ create(context, [options]) {
116
+ const pending = new Map();
117
+ let services = null;
118
+ let checker = null;
119
+ try {
120
+ services = utils_1.ESLintUtils.getParserServices(context, true);
121
+ checker = services.program ? services.program.getTypeChecker() : null;
122
+ }
123
+ catch {
124
+ services = null;
125
+ }
126
+ function returnsDisposable(node) {
127
+ if ((0, disposables_1.isDisposableSetFactoryCall)(node)) {
128
+ return true;
129
+ }
130
+ if (!checker || !services) {
131
+ return false;
132
+ }
133
+ try {
134
+ const tsNode = services.esTreeNodeToTSNodeMap.get(node);
135
+ const type = checker.getTypeAtLocation(tsNode);
136
+ return (0, disposables_1.isDisposableType)(type, checker);
137
+ }
138
+ catch {
139
+ return false;
140
+ }
141
+ }
142
+ // The two pattern-based exemptions below (`add*Factory`, and mutating a
143
+ // map-like field of `this`) are part of the built-in defaults, so the same
144
+ // flag that governs the default name list governs them too.
145
+ const extendDefaultIgnoredReturnFunctionNames = options.extendDefaultIgnoredReturnFunctionNames !==
146
+ false;
147
+ const ignoredReturnFunctionNames = (0, disposables_1.resolveNameListOption)(options.ignoredReturnFunctionNames, DEFAULT_IGNORED_RETURN_FUNCTION_NAMES, extendDefaultIgnoredReturnFunctionNames);
148
+ function isIgnoredReturn(node) {
149
+ if (extendDefaultIgnoredReturnFunctionNames &&
150
+ (0, disposables_1.isClassFieldCollectionMutationCall)(node, ['delete', 'set'])) {
151
+ return true;
152
+ }
153
+ const name = (0, disposables_1.getCalleeName)(node.callee);
154
+ if (!name) {
155
+ return false;
156
+ }
157
+ return (ignoredReturnFunctionNames.has(name) ||
158
+ (extendDefaultIgnoredReturnFunctionNames &&
159
+ isDefaultIgnoredFactoryReturnFunctionName(name)));
160
+ }
161
+ const checkAllDisposableReturns = options.checkAllDisposableReturns === true;
162
+ const ownership = {
163
+ sourceCode: context.sourceCode,
164
+ checker,
165
+ services,
166
+ ownershipFunctionNames: (0, disposables_1.resolveNameListOption)(options.ownershipFunctionNames, disposables_1.DEFAULT_OWNERSHIP_FUNCTION_NAMES, options.extendDefaultOwnershipFunctionNames !== false)
167
+ };
168
+ return {
169
+ CallExpression(node) {
170
+ (0, disposables_1.markManagedDisposableUse)(pending, node, ownership);
171
+ if ((0, disposables_1.isInJupyterPluginActivate)(node, ownership) ||
172
+ isIgnoredReturn(node) ||
173
+ !(0, disposables_1.shouldCheckReturnedDisposable)(node) ||
174
+ (0, disposables_1.isDisposableExpressionManaged)(node, ownership)) {
175
+ return;
176
+ }
177
+ if (!checkAllDisposableReturns &&
178
+ !isLikelyDisposableFactoryCall(node)) {
179
+ return;
180
+ }
181
+ if (!returnsDisposable(node)) {
182
+ return;
183
+ }
184
+ const assignedVariable = (0, disposables_1.getAssignedVariable)(node, context.sourceCode);
185
+ if (assignedVariable) {
186
+ if ((0, disposables_1.isOuterFunctionScopeVariable)(node, assignedVariable, context.sourceCode) ||
187
+ (0, disposables_1.isExportedVariable)(assignedVariable) ||
188
+ (0, disposables_1.isDisposedByNestedFunction)(assignedVariable, ownership)) {
189
+ return;
190
+ }
191
+ (0, disposables_1.addPendingDisposable)(pending, assignedVariable, node);
192
+ return;
193
+ }
194
+ context.report({
195
+ node,
196
+ messageId: 'unhandledDisposable',
197
+ data: { name: (0, disposables_1.getCalleeName)(node.callee) ?? 'call' }
198
+ });
199
+ },
200
+ ReturnStatement(node) {
201
+ (0, disposables_1.markManagedDisposableUse)(pending, node, ownership);
202
+ },
203
+ AssignmentExpression(node) {
204
+ (0, disposables_1.markManagedDisposableUse)(pending, node, ownership);
205
+ },
206
+ NewExpression(node) {
207
+ (0, disposables_1.markManagedDisposableUse)(pending, node, ownership);
208
+ },
209
+ 'Program:exit'() {
210
+ for (const [variable, records] of pending) {
211
+ for (const record of records) {
212
+ context.report({
213
+ node: record.node,
214
+ messageId: 'unmanagedDisposableVariable',
215
+ data: { name: variable.name }
216
+ });
217
+ }
218
+ }
219
+ }
220
+ };
221
+ }
222
+ });
223
+ module.exports = requireDisposableTransfer;
@@ -0,0 +1,8 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ declare const requireSignalCleanup: ESLintUtils.RuleModule<"serviceOutlivesReceiver", [{
3
+ additionalCleanupMethods: string[];
4
+ longLivedTypes: string[] | undefined;
5
+ }], unknown, ESLintUtils.RuleListener> & {
6
+ name: string;
7
+ };
8
+ export = requireSignalCleanup;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Jupyter Development Team.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ const utils_1 = require("@typescript-eslint/utils");
7
+ const create_rule_1 = require("../utils/create-rule");
8
+ const signals_1 = require("../utils/signals");
9
+ const signal_lifetime_1 = require("../utils/signal-lifetime");
10
+ const requireSignalCleanup = (0, create_rule_1.createRule)({
11
+ name: 'require-signal-cleanup',
12
+ meta: {
13
+ type: 'problem',
14
+ docs: {
15
+ description: 'Require a cleanup path for Lumino signal connections whose sender outlives the connecting class',
16
+ url: 'https://eslint-plugin.readthedocs.io/en/latest/rules/require-signal-cleanup/'
17
+ },
18
+ messages: {
19
+ serviceOutlivesReceiver: 'This connection to "{{ sender }}" is never removed, and "{{ typeName }}" is an application-lifetime service, so it will outlive this class and keep every instance alive. Disconnect it during teardown, or call Signal.clearData(this).'
20
+ },
21
+ schema: [
22
+ {
23
+ type: 'object',
24
+ properties: {
25
+ additionalCleanupMethods: {
26
+ type: 'array',
27
+ items: {
28
+ type: 'string'
29
+ },
30
+ default: [],
31
+ description: 'Additional method names (besides "disconnect") that count as cleanup evidence when called anywhere in the class'
32
+ },
33
+ longLivedTypes: {
34
+ type: 'array',
35
+ items: {
36
+ type: 'string'
37
+ },
38
+ description: 'Type names treated as application-lifetime services. Replaces the built-in list when provided.'
39
+ }
40
+ },
41
+ additionalProperties: false
42
+ }
43
+ ]
44
+ },
45
+ defaultOptions: [
46
+ {
47
+ additionalCleanupMethods: [],
48
+ longLivedTypes: undefined
49
+ }
50
+ ],
51
+ create(context, [options]) {
52
+ const additionalCleanupMethods = options.additionalCleanupMethods || [];
53
+ const longLivedTypes = new Set(options.longLivedTypes ?? signal_lifetime_1.DEFAULT_LONG_LIVED_TYPES);
54
+ let services = null;
55
+ let checker = null;
56
+ try {
57
+ services = utils_1.ESLintUtils.getParserServices(context, true);
58
+ checker = services.program ? services.program.getTypeChecker() : null;
59
+ }
60
+ catch {
61
+ services = null;
62
+ }
63
+ const sourceCode = context.sourceCode;
64
+ let program = null;
65
+ let signalLocalNames = new Set(['Signal']);
66
+ const cleanupEvidenceCache = new Map();
67
+ const ownershipCache = new Map();
68
+ return {
69
+ Program(node) {
70
+ program = node;
71
+ signalLocalNames = (0, signals_1.collectSignalNamespaceLocalNames)(node);
72
+ cleanupEvidenceCache.clear();
73
+ ownershipCache.clear();
74
+ },
75
+ CallExpression(node) {
76
+ if (!(0, signals_1.isConnectCall)(node) || !program) {
77
+ return;
78
+ }
79
+ if (node.arguments.length < 2) {
80
+ // No thisArg — see require-signal-this-arg / prefer-signal-this-arg.
81
+ return;
82
+ }
83
+ if (node.arguments[1].type !== 'ThisExpression') {
84
+ // Receiver is some other object; its lifetime is not traceable here.
85
+ return;
86
+ }
87
+ if ((0, signals_1.getThisBinding)(node) !== 'instance') {
88
+ // In a `static` member `this` is the class object, and in a nested
89
+ // regular function it is whatever the caller binds. Neither is an
90
+ // instance whose lifetime this rule reasons about, and neither is
91
+ // removed by a `Signal.clearData(this)` in `dispose()`.
92
+ return;
93
+ }
94
+ const enclosingClass = (0, signals_1.getEnclosingClass)(node);
95
+ if (!enclosingClass) {
96
+ return;
97
+ }
98
+ if (enclosingClass.superClass) {
99
+ // The base class may clean up in an inherited dispose() that is
100
+ // invisible from here — Lumino's Widget.dispose() calls
101
+ // Signal.clearData(this), which removes exactly this connection.
102
+ return;
103
+ }
104
+ if (!(0, signal_lifetime_1.classHasDisposalProtocol)(enclosingClass)) {
105
+ // No dispose(), no isDisposed, no `implements IDisposable`: almost
106
+ // always a plugin-scope singleton whose lifetime matches the
107
+ // services it connects to, and with nowhere to put a disconnect.
108
+ return;
109
+ }
110
+ const chain = (0, signal_lifetime_1.buildSenderChain)(node.callee.object);
111
+ if ((0, signal_lifetime_1.isSelfTerminatingSignal)(chain)) {
112
+ // `x.disposed.connect(cb, this)` fires as its sender is torn down
113
+ // and is cleaned up sender-side. It is the pattern this rule
114
+ // recommends, so it must never be flagged.
115
+ return;
116
+ }
117
+ let hasEvidence = cleanupEvidenceCache.get(enclosingClass);
118
+ if (hasEvidence === undefined) {
119
+ hasEvidence = (0, signals_1.classHasCleanupEvidence)(enclosingClass, signalLocalNames, additionalCleanupMethods);
120
+ cleanupEvidenceCache.set(enclosingClass, hasEvidence);
121
+ }
122
+ if (hasEvidence) {
123
+ return;
124
+ }
125
+ const classification = (0, signals_1.classifySignalReceiver)(node.callee.object, checker, services);
126
+ if (classification === 'not-signal') {
127
+ return;
128
+ }
129
+ let facts = ownershipCache.get(enclosingClass);
130
+ if (!facts) {
131
+ facts = (0, signal_lifetime_1.collectClassOwnershipFacts)(enclosingClass, sourceCode, signalLocalNames);
132
+ ownershipCache.set(enclosingClass, facts);
133
+ }
134
+ const analysis = (0, signal_lifetime_1.analyzeSender)(node.callee.object, {
135
+ classNode: enclosingClass,
136
+ facts,
137
+ sourceCode,
138
+ scope: sourceCode.getScope(node),
139
+ checker,
140
+ services,
141
+ longLivedTypes
142
+ });
143
+ // Only positively proven long-lived senders are reported. `self`,
144
+ // `owned` and `unknown` all stay silent: absence of cleanup is not
145
+ // evidence of a leak when the sender dies with the receiver.
146
+ //
147
+ // `long-lived-model` cannot occur here: it is gated on the receiver
148
+ // extending Lumino's Widget, and every such class is already skipped
149
+ // above by the `superClass` check.
150
+ if (analysis.lifetime === 'long-lived-service') {
151
+ context.report({
152
+ node,
153
+ messageId: 'serviceOutlivesReceiver',
154
+ data: {
155
+ sender: analysis.senderText,
156
+ typeName: analysis.typeName ?? 'service'
157
+ }
158
+ });
159
+ }
160
+ }
161
+ };
162
+ }
163
+ });
164
+ module.exports = requireSignalCleanup;
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ declare const requireSignalThisArg: ESLintUtils.RuleModule<"missingThisArg" | "addThisArg", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ export = requireSignalThisArg;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Jupyter Development Team.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ const utils_1 = require("@typescript-eslint/utils");
7
+ const create_rule_1 = require("../utils/create-rule");
8
+ const signals_1 = require("../utils/signals");
9
+ const requireSignalThisArg = (0, create_rule_1.createRule)({
10
+ name: 'require-signal-this-arg',
11
+ meta: {
12
+ type: 'suggestion',
13
+ hasSuggestions: true,
14
+ docs: {
15
+ description: 'Require a thisArg when connecting a class method that references `this` to a Lumino signal',
16
+ url: 'https://eslint-plugin.readthedocs.io/en/latest/rules/require-signal-this-arg/'
17
+ },
18
+ messages: {
19
+ missingThisArg: 'Callback "{{ name }}" references "this" but is connected without a thisArg, so "this" will not be bound to this instance when the signal fires. Pass "this" as the second argument to connect().',
20
+ addThisArg: 'Add "this" as the second argument'
21
+ },
22
+ schema: []
23
+ },
24
+ defaultOptions: [],
25
+ create(context) {
26
+ let services = null;
27
+ let checker = null;
28
+ try {
29
+ services = utils_1.ESLintUtils.getParserServices(context, true);
30
+ checker = services.program ? services.program.getTypeChecker() : null;
31
+ }
32
+ catch {
33
+ services = null;
34
+ }
35
+ return {
36
+ CallExpression(node) {
37
+ if (!(0, signals_1.isConnectCall)(node) || node.arguments.length !== 1) {
38
+ return;
39
+ }
40
+ const unbound = (0, signals_1.resolveUnboundThisMethodConnect)(node);
41
+ if (!unbound) {
42
+ // Any other callback shape has no runtime `this` bug; the
43
+ // warning-level prefer-signal-this-arg rule covers those.
44
+ return;
45
+ }
46
+ const classification = (0, signals_1.classifySignalReceiver)(node.callee.object, checker, services);
47
+ if (classification === 'not-signal') {
48
+ return;
49
+ }
50
+ if (classification === 'unknown' &&
51
+ !(0, signals_1.looksLikeSignalByName)(node.callee.object)) {
52
+ // Single-argument `.connect(callback)` is a weak signature shared
53
+ // by many non-Lumino APIs — without type information, require a
54
+ // conventional signal name before flagging.
55
+ return;
56
+ }
57
+ context.report({
58
+ node: unbound.arg,
59
+ messageId: 'missingThisArg',
60
+ data: {
61
+ name: unbound.isPrivate ? `#${unbound.name}` : unbound.name
62
+ },
63
+ suggest: [
64
+ {
65
+ messageId: 'addThisArg',
66
+ fix: fixer => fixer.insertTextAfter(unbound.arg, ', this')
67
+ }
68
+ ]
69
+ });
70
+ }
71
+ };
72
+ }
73
+ });
74
+ module.exports = requireSignalThisArg;
@@ -27,8 +27,7 @@ const tokenFormat = (0, create_rule_1.createRule)({
27
27
  create(context) {
28
28
  return {
29
29
  NewExpression(node) {
30
- if (node.callee.type !== 'Identifier' ||
31
- node.callee.name !== 'Token') {
30
+ if (node.callee.type !== 'Identifier' || node.callee.name !== 'Token') {
32
31
  return;
33
32
  }
34
33
  if (node.arguments.length === 0) {
@@ -0,0 +1,64 @@
1
+ import { TSESTree } from '@typescript-eslint/types';
2
+ import { ParserServices, TSESLint } from '@typescript-eslint/utils';
3
+ import * as ts from 'typescript';
4
+ /**
5
+ * Resolves a configurable name list option.
6
+ *
7
+ * A user-supplied list is *added* to the built-in defaults, so a project only
8
+ * has to name its own helpers rather than restate this plugin's list. Passing
9
+ * the matching `extendDefault...` option as `false` drops the defaults, whether
10
+ * or not a replacement list is given, which is also how to ask for the
11
+ * strictest possible checking.
12
+ */
13
+ export declare function resolveNameListOption(provided: readonly string[] | undefined, defaults: readonly string[], extendDefaults: boolean): Set<string>;
14
+ export declare const DEFAULT_OWNERSHIP_FUNCTION_NAMES: string[];
15
+ interface PendingDisposable {
16
+ node: TSESTree.Node;
17
+ }
18
+ export interface DisposableOwnershipContext {
19
+ sourceCode: TSESLint.SourceCode;
20
+ checker: ts.TypeChecker | null;
21
+ services: ParserServices | null;
22
+ ownershipFunctionNames: Set<string>;
23
+ }
24
+ export type PendingDisposableMap = Map<TSESLint.Scope.Variable, PendingDisposable[]>;
25
+ export declare function getCalleeName(node: TSESTree.Node): string | null;
26
+ export declare function isDisposableConstructor(node: TSESTree.NewExpression): boolean;
27
+ export declare function isDisposableSetFactoryCall(node: TSESTree.Node): boolean;
28
+ export declare function addPendingDisposable(pending: PendingDisposableMap, variable: TSESLint.Scope.Variable, node: TSESTree.Node): void;
29
+ export declare function getAssignedVariable(node: TSESTree.Node, sourceCode: TSESLint.SourceCode): TSESLint.Scope.Variable | null;
30
+ export declare function isOuterFunctionScopeVariable(node: TSESTree.Node, variable: TSESLint.Scope.Variable, sourceCode: TSESLint.SourceCode): boolean;
31
+ /**
32
+ * Checks whether a variable is an exported binding, in any of the forms the
33
+ * `export` keyword can take.
34
+ *
35
+ * Ownership of an exported singleton passes to the importers of the module, so
36
+ * this file cannot see - and is not responsible for - its disposal. Such
37
+ * declarations are also created exactly once and live for the lifetime of the
38
+ * program, so there is nothing to leak.
39
+ */
40
+ export declare function isExportedVariable(variable: TSESLint.Scope.Variable): boolean;
41
+ /**
42
+ * Checks whether a variable's lifetime is taken over by a nested function, in
43
+ * any of three ways:
44
+ *
45
+ * - it is captured by a closure the declaring function returns, so the closure
46
+ * owns it (`createToolbarFactory`);
47
+ * - an escaping callback unconditionally disposes it
48
+ * (`requestAnimationFrame(() => splash.dispose())`, promise chains);
49
+ * - an escaping callback unconditionally hands its ownership to something else.
50
+ *
51
+ * The last two generalise the existing `disposed.connect(...)` special case to
52
+ * any callback. Cleanup that is itself conditional inside the callback does not
53
+ * count, so "cleanup only on some paths" stays reportable, and every branch
54
+ * resolves identifiers to this variable rather than comparing names, so a
55
+ * shadowing binding inside the callback cannot silence the outer one.
56
+ */
57
+ export declare function isDisposedByNestedFunction(variable: TSESLint.Scope.Variable, ownership: DisposableOwnershipContext): boolean;
58
+ export declare function isInJupyterPluginActivate(node: TSESTree.Node, ownership: DisposableOwnershipContext): boolean;
59
+ export declare function isClassFieldCollectionMutationCall(node: TSESTree.CallExpression, names: readonly string[]): boolean;
60
+ export declare function isDisposableExpressionManaged(node: TSESTree.Node, ownership: DisposableOwnershipContext): boolean;
61
+ export declare function markManagedDisposableUse(pending: PendingDisposableMap, node: TSESTree.Node, ownership: DisposableOwnershipContext): void;
62
+ export declare function isDisposableType(type: ts.Type, checker: ts.TypeChecker, seen?: Set<ts.Type>): boolean;
63
+ export declare function shouldCheckReturnedDisposable(node: TSESTree.CallExpression): boolean;
64
+ export {};