import { TSESTree } from '@typescript-eslint/types'; import { ParserServices, TSESLint } from '@typescript-eslint/utils'; import * as ts from 'typescript'; /** * Resolves a configurable name list option. * * A user-supplied list is *added* to the built-in defaults, so a project only * has to name its own helpers rather than restate this plugin's list. Passing * the matching `extendDefault...` option as `false` drops the defaults, whether * or not a replacement list is given, which is also how to ask for the * strictest possible checking. */ export declare function resolveNameListOption(provided: readonly string[] | undefined, defaults: readonly string[], extendDefaults: boolean): Set; export declare const DEFAULT_OWNERSHIP_FUNCTION_NAMES: string[]; interface PendingDisposable { node: TSESTree.Node; } export interface DisposableOwnershipContext { sourceCode: TSESLint.SourceCode; checker: ts.TypeChecker | null; services: ParserServices | null; ownershipFunctionNames: Set; } export type PendingDisposableMap = Map; export declare function getCalleeName(node: TSESTree.Node): string | null; export declare function isDisposableConstructor(node: TSESTree.NewExpression): boolean; export declare function isDisposableSetFactoryCall(node: TSESTree.Node): boolean; export declare function addPendingDisposable(pending: PendingDisposableMap, variable: TSESLint.Scope.Variable, node: TSESTree.Node): void; export declare function getAssignedVariable(node: TSESTree.Node, sourceCode: TSESLint.SourceCode): TSESLint.Scope.Variable | null; export declare function isOuterFunctionScopeVariable(node: TSESTree.Node, variable: TSESLint.Scope.Variable, sourceCode: TSESLint.SourceCode): boolean; /** * Checks whether a variable is an exported binding, in any of the forms the * `export` keyword can take. * * Ownership of an exported singleton passes to the importers of the module, so * this file cannot see - and is not responsible for - its disposal. Such * declarations are also created exactly once and live for the lifetime of the * program, so there is nothing to leak. */ export declare function isExportedVariable(variable: TSESLint.Scope.Variable): boolean; /** * Checks whether a variable's lifetime is taken over by a nested function, in * any of three ways: * * - it is captured by a closure the declaring function returns, so the closure * owns it (`createToolbarFactory`); * - an escaping callback unconditionally disposes it * (`requestAnimationFrame(() => splash.dispose())`, promise chains); * - an escaping callback unconditionally hands its ownership to something else. * * The last two generalise the existing `disposed.connect(...)` special case to * any callback. Cleanup that is itself conditional inside the callback does not * count, so "cleanup only on some paths" stays reportable, and every branch * resolves identifiers to this variable rather than comparing names, so a * shadowing binding inside the callback cannot silence the outer one. */ export declare function isDisposedByNestedFunction(variable: TSESLint.Scope.Variable, ownership: DisposableOwnershipContext): boolean; export declare function isInJupyterPluginActivate(node: TSESTree.Node, ownership: DisposableOwnershipContext): boolean; export declare function isClassFieldCollectionMutationCall(node: TSESTree.CallExpression, names: readonly string[]): boolean; export declare function isDisposableExpressionManaged(node: TSESTree.Node, ownership: DisposableOwnershipContext): boolean; export declare function markManagedDisposableUse(pending: PendingDisposableMap, node: TSESTree.Node, ownership: DisposableOwnershipContext): void; export declare function isDisposableType(type: ts.Type, checker: ts.TypeChecker, seen?: Set): boolean; export declare function shouldCheckReturnedDisposable(node: TSESTree.CallExpression): boolean; export {};