diff --git a/eslint.config.js b/eslint.config.js index fde5c2c1162..7c87b5b0b1e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -374,7 +374,6 @@ export default tseslint.config( 'src/vs/base/node/processes.ts', 'src/vs/base/common/arrays.ts', 'src/vs/base/common/async.ts', - 'src/vs/base/common/cancellation.ts', 'src/vs/base/common/collections.ts', 'src/vs/base/common/console.ts', 'src/vs/base/common/controlFlow.ts', @@ -389,7 +388,6 @@ export default tseslint.config( 'src/vs/base/common/json.ts', 'src/vs/base/common/jsonSchema.ts', 'src/vs/base/common/lifecycle.ts', - 'src/vs/base/common/linkedList.ts', 'src/vs/base/common/map.ts', 'src/vs/base/common/marshalling.ts', 'src/vs/base/common/network.ts', @@ -399,9 +397,7 @@ export default tseslint.config( 'src/vs/base/common/platform.ts', 'src/vs/base/common/processes.ts', 'src/vs/base/common/resourceTree.ts', - 'src/vs/base/common/skipList.ts', 'src/vs/base/common/strings.ts', - 'src/vs/base/common/ternarySearchTree.ts', 'src/vs/base/common/types.ts', 'src/vs/base/common/uriIpc.ts', 'src/vs/base/common/verifier.ts', @@ -471,7 +467,6 @@ export default tseslint.config( 'src/vs/platform/contextkey/browser/contextKeyService.ts', 'src/vs/platform/contextkey/common/contextkey.ts', 'src/vs/platform/contextview/browser/contextView.ts', - 'src/vs/platform/contextview/browser/contextViewService.ts', 'src/vs/platform/debug/common/extensionHostDebugIpc.ts', 'src/vs/platform/debug/electron-main/extensionHostDebugIpc.ts', 'src/vs/platform/diagnostics/common/diagnostics.ts', @@ -573,8 +568,6 @@ export default tseslint.config( 'src/vs/editor/contrib/codeAction/browser/codeAction.ts', 'src/vs/editor/contrib/codeAction/browser/codeActionCommands.ts', 'src/vs/editor/contrib/codeAction/common/types.ts', - 'src/vs/editor/contrib/codelens/browser/codelens.ts', - 'src/vs/editor/contrib/codelens/browser/codelensController.ts', 'src/vs/editor/contrib/colorPicker/browser/colorDetector.ts', 'src/vs/editor/contrib/diffEditorBreadcrumbs/browser/contribution.ts', 'src/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorContribution.ts', @@ -617,8 +610,6 @@ export default tseslint.config( 'src/vs/workbench/api/common/extHostConsoleForwarder.ts', 'src/vs/workbench/api/common/extHostDataChannels.ts', 'src/vs/workbench/api/common/extHostDebugService.ts', - 'src/vs/workbench/api/common/extHostDiagnostics.ts', - 'src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts', 'src/vs/workbench/api/common/extHostExtensionActivator.ts', 'src/vs/workbench/api/common/extHostExtensionService.ts', 'src/vs/workbench/api/common/extHostFileSystemConsumer.ts', @@ -941,7 +932,7 @@ export default tseslint.config( '@typescript-eslint/no-explicit-any': [ 'warn', { - 'fixToUnknown': true + 'fixToUnknown': false } ] } diff --git a/src/vs/base/common/cancellation.ts b/src/vs/base/common/cancellation.ts index 3be4a90a103..e04c9277b85 100644 --- a/src/vs/base/common/cancellation.ts +++ b/src/vs/base/common/cancellation.ts @@ -21,10 +21,10 @@ export interface CancellationToken { * * @event */ - readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable; + readonly onCancellationRequested: (listener: (e: void) => unknown, thisArgs?: unknown, disposables?: IDisposable[]) => IDisposable; } -const shortcutEvent: Event = Object.freeze(function (callback, context?): IDisposable { +const shortcutEvent: Event = Object.freeze(function (callback, context?): IDisposable { const handle = setTimeout(callback.bind(context), 0); return { dispose() { clearTimeout(handle); } }; }); @@ -60,7 +60,7 @@ export namespace CancellationToken { class MutableToken implements CancellationToken { private _isCancelled: boolean = false; - private _emitter: Emitter | null = null; + private _emitter: Emitter | null = null; public cancel() { if (!this._isCancelled) { @@ -76,12 +76,12 @@ class MutableToken implements CancellationToken { return this._isCancelled; } - get onCancellationRequested(): Event { + get onCancellationRequested(): Event { if (this._isCancelled) { return shortcutEvent; } if (!this._emitter) { - this._emitter = new Emitter(); + this._emitter = new Emitter(); } return this._emitter.event; } diff --git a/src/vs/base/common/linkedList.ts b/src/vs/base/common/linkedList.ts index 9e6d3333e32..b436c611717 100644 --- a/src/vs/base/common/linkedList.ts +++ b/src/vs/base/common/linkedList.ts @@ -5,11 +5,11 @@ class Node { - static readonly Undefined = new Node(undefined); + static readonly Undefined = new Node(undefined); element: E; - next: Node; - prev: Node; + next: Node | typeof Node.Undefined; + prev: Node | typeof Node.Undefined; constructor(element: E) { this.element = element; @@ -20,8 +20,8 @@ class Node { export class LinkedList { - private _first: Node = Node.Undefined; - private _last: Node = Node.Undefined; + private _first: Node | typeof Node.Undefined = Node.Undefined; + private _last: Node | typeof Node.Undefined = Node.Undefined; private _size: number = 0; get size(): number { @@ -91,7 +91,7 @@ export class LinkedList { } else { const res = this._first.element; this._remove(this._first); - return res; + return res as E; } } @@ -101,7 +101,7 @@ export class LinkedList { } else { const res = this._last.element; this._remove(this._last); - return res; + return res as E; } } @@ -110,11 +110,11 @@ export class LinkedList { return undefined; } else { const res = this._last.element; - return res; + return res as E; } } - private _remove(node: Node): void { + private _remove(node: Node | typeof Node.Undefined): void { if (node.prev !== Node.Undefined && node.next !== Node.Undefined) { // middle const anchor = node.prev; @@ -144,7 +144,7 @@ export class LinkedList { *[Symbol.iterator](): Iterator { let node = this._first; while (node !== Node.Undefined) { - yield node.element; + yield node.element as E; node = node.next; } } diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index 377e37e6ea1..0eb115b0df0 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -116,7 +116,7 @@ export class ResourceMap implements Map { return this.map.delete(this.toKey(resource)); } - forEach(clb: (value: T, key: URI, map: Map) => void, thisArg?: any): void { + forEach(clb: (value: T, key: URI, map: Map) => void, thisArg?: object): void { if (typeof thisArg !== 'undefined') { clb = clb.bind(thisArg); } @@ -185,7 +185,7 @@ export class ResourceSet implements Set { return this._map.delete(value); } - forEach(callbackfn: (value: URI, value2: URI, set: Set) => void, thisArg?: any): void { + forEach(callbackfn: (value: URI, value2: URI, set: Set) => void, thisArg?: unknown): void { this._map.forEach((_value, key) => callbackfn.call(thisArg, key, key, this)); } @@ -340,7 +340,7 @@ export class LinkedMap implements Map { return item.value; } - forEach(callbackfn: (value: V, key: K, map: LinkedMap) => void, thisArg?: any): void { + forEach(callbackfn: (value: V, key: K, map: LinkedMap) => void, thisArg?: unknown): void { const state = this._state; let current = this._head; while (current) { @@ -789,7 +789,7 @@ export class BidirectionalMap { return true; } - forEach(callbackfn: (value: V, key: K, map: BidirectionalMap) => void, thisArg?: any): void { + forEach(callbackfn: (value: V, key: K, map: BidirectionalMap) => void, thisArg?: unknown): void { this._m1.forEach((value, key) => { callbackfn.call(thisArg, value, key, this); }); diff --git a/src/vs/base/common/skipList.ts b/src/vs/base/common/skipList.ts index 295adb603fe..b88184f9935 100644 --- a/src/vs/base/common/skipList.ts +++ b/src/vs/base/common/skipList.ts @@ -35,8 +35,8 @@ export class SkipList implements Map { capacity: number = 2 ** 16 ) { this._maxLevel = Math.max(1, Math.log2(capacity) | 0); - // eslint-disable-next-line local/code-no-any-casts - this._header = new Node(this._maxLevel, NIL, NIL); + + this._header = new Node(this._maxLevel, NIL, NIL); } get size(): number { @@ -44,8 +44,8 @@ export class SkipList implements Map { } clear(): void { - // eslint-disable-next-line local/code-no-any-casts - this._header = new Node(this._maxLevel, NIL, NIL); + + this._header = new Node(this._maxLevel, NIL, NIL); this._size = 0; } @@ -74,7 +74,7 @@ export class SkipList implements Map { // --- iteration - forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void { + forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: unknown): void { let node = this._header.forward[0]; while (node) { callbackfn.call(thisArg, node.value, node.key, this); @@ -169,7 +169,7 @@ export class SkipList implements Map { } } - private static _randomLevel(list: SkipList, p: number = 0.5): number { + private static _randomLevel(list: SkipList, p: number = 0.5): number { let lvl = 1; while (Math.random() < p && lvl < list._maxLevel) { lvl += 1; diff --git a/src/vs/base/common/ternarySearchTree.ts b/src/vs/base/common/ternarySearchTree.ts index 0364b263f69..d184ed1765e 100644 --- a/src/vs/base/common/ternarySearchTree.ts +++ b/src/vs/base/common/ternarySearchTree.ts @@ -781,7 +781,7 @@ export class TernarySearchTree { // for debug/testing _isBalanced(): boolean { - const nodeIsBalanced = (node: TernarySearchTreeNode | undefined): boolean => { + const nodeIsBalanced = (node: TernarySearchTreeNode | undefined): boolean => { if (!node) { return true; } diff --git a/src/vs/editor/contrib/codelens/browser/codelens.ts b/src/vs/editor/contrib/codelens/browser/codelens.ts index c91c3092043..fdbcf259f18 100644 --- a/src/vs/editor/contrib/codelens/browser/codelens.ts +++ b/src/vs/editor/contrib/codelens/browser/codelens.ts @@ -112,7 +112,7 @@ CommandsRegistry.registerCommand('_executeCodeLensProvider', function (accessor, return getCodeLensModel(codeLensProvider, model, CancellationToken.None).then(value => { disposables.add(value); - const resolve: Promise[] = []; + const resolve: Promise[] = []; for (const item of value.lenses) { if (itemResolveCount === undefined || itemResolveCount === null || Boolean(item.symbol.command)) { diff --git a/src/vs/editor/contrib/codelens/browser/codelensController.ts b/src/vs/editor/contrib/codelens/browser/codelensController.ts index f34e88a4d24..3a3877a2664 100644 --- a/src/vs/editor/contrib/codelens/browser/codelensController.ts +++ b/src/vs/editor/contrib/codelens/browser/codelensController.ts @@ -42,7 +42,7 @@ export class CodeLensContribution implements IEditorContribution { private _getCodeLensModelPromise: CancelablePromise | undefined; private readonly _oldCodeLensModels = new DisposableStore(); private _currentCodeLensModel: CodeLensModel | undefined; - private _resolveCodeLensesPromise: CancelablePromise | undefined; + private _resolveCodeLensesPromise: CancelablePromise | undefined; constructor( private readonly _editor: ICodeEditor, diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 3060d527d84..0c65323c6b5 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -103,7 +103,7 @@ declare namespace monaco { * * @event */ - readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable; + readonly onCancellationRequested: (listener: (e: void) => unknown, thisArgs?: unknown, disposables?: IDisposable[]) => IDisposable; } /** * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986. diff --git a/src/vs/platform/contextview/browser/contextViewService.ts b/src/vs/platform/contextview/browser/contextViewService.ts index 734a1f32603..1ca549dc76c 100644 --- a/src/vs/platform/contextview/browser/contextViewService.ts +++ b/src/vs/platform/contextview/browser/contextViewService.ts @@ -61,7 +61,7 @@ export class ContextViewHandler extends Disposable implements IContextViewProvid this.contextView.layout(); } - hideContextView(data?: any): void { + hideContextView(data?: unknown): void { this.contextView.hide(data); this.openContextView = undefined; } diff --git a/src/vs/workbench/api/common/extHostDiagnostics.ts b/src/vs/workbench/api/common/extHostDiagnostics.ts index fe0367ccad6..d3e84c8d05f 100644 --- a/src/vs/workbench/api/common/extHostDiagnostics.ts +++ b/src/vs/workbench/api/common/extHostDiagnostics.ts @@ -186,7 +186,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection { this.#proxy?.$clear(this._owner); } - forEach(callback: (uri: URI, diagnostics: ReadonlyArray, collection: DiagnosticCollection) => any, thisArg?: any): void { + forEach(callback: (uri: URI, diagnostics: ReadonlyArray, collection: DiagnosticCollection) => unknown, thisArg?: unknown): void { this._checkDisposed(); for (const [uri, values] of this) { callback.call(thisArg, uri, values, this); diff --git a/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts b/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts index f46aa4b4686..ef4941c549e 100644 --- a/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts +++ b/src/vs/workbench/api/common/extHostDocumentSaveParticipant.ts @@ -17,7 +17,7 @@ import { ILogService } from '../../../platform/log/common/log.js'; import { IExtensionDescription } from '../../../platform/extensions/common/extensions.js'; import { SerializableObjectWithBuffers } from '../../services/extensions/common/proxyIdentifier.js'; -type Listener = [Function, any, IExtensionDescription]; +type Listener = [Function, unknown, IExtensionDescription]; export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSaveParticipantShape { @@ -62,8 +62,8 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic break; } const document = this._documents.getDocument(resource); - // eslint-disable-next-line local/code-no-any-casts - const success = await this._deliverEventAsyncAndBlameBadListeners(listener, { document, reason: TextDocumentSaveReason.to(reason) }); + + const success = await this._deliverEventAsyncAndBlameBadListeners(listener, { document, reason: TextDocumentSaveReason.to(reason) }); results.push(success); } } finally { @@ -72,7 +72,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic return results; } - private _deliverEventAsyncAndBlameBadListeners([listener, thisArg, extension]: Listener, stubEvent: vscode.TextDocumentWillSaveEvent): Promise { + private _deliverEventAsyncAndBlameBadListeners([listener, thisArg, extension]: Listener, stubEvent: Pick): Promise { const errors = this._badListeners.get(listener); if (typeof errors === 'number' && errors > this._thresholds.errors) { // bad listener - ignore @@ -100,7 +100,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic }); } - private _deliverEventAsync(extension: IExtensionDescription, listener: Function, thisArg: any, stubEvent: vscode.TextDocumentWillSaveEvent): Promise { + private _deliverEventAsync(extension: IExtensionDescription, listener: Function, thisArg: unknown, stubEvent: Pick): Promise { const promises: Promise[] = []; @@ -111,6 +111,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic const event = Object.freeze({ document, reason, + // eslint-disable-next-line @typescript-eslint/no-explicit-any waitUntil(p: Promise) { if (Object.isFrozen(promises)) { throw illegalState('waitUntil can not be called async');