diff --git a/.eslintrc.json b/.eslintrc.json index ae0009af5..8476c4f20 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,8 @@ "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 2020, - "sourceType": "module" + "sourceType": "module", + "project": true }, "plugins": ["@typescript-eslint"], "rules": { @@ -13,6 +14,7 @@ // TODO "@typescript-eslint/semi" rule moved to https://eslint.style "semi": "error", "no-console": "warn", + "@typescript-eslint/no-floating-promises": "warn", // Mostly fails tests, ex. expect(...).to.be.true returns a Chai.Assertion "@typescript-eslint/no-unused-expressions": "off", "@typescript-eslint/no-non-null-assertion": "off", diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 000000000..b2cabb90b --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "composite": true, + + "rootDir": ".", + "outDir": "dist", + + "lib": ["ES2021"], + "target": "ES2020", + "module": "commonjs", + + "strict": true, + + "sourceMap": true, + + "types": [] + } +} diff --git a/src/BackgroundCompilation.ts b/src/BackgroundCompilation.ts index f54f48534..edac4dd24 100644 --- a/src/BackgroundCompilation.ts +++ b/src/BackgroundCompilation.ts @@ -58,7 +58,7 @@ export class BackgroundCompilation implements vscode.Disposable { this.workspaceFileWatcher.onDidChange( debounce( () => { - this.runTask(); + void this.runTask(); }, 100 /* 10 times per second */, { trailing: true } diff --git a/src/FolderContext.ts b/src/FolderContext.ts index bf707c5a7..02cd7f171 100644 --- a/src/FolderContext.ts +++ b/src/FolderContext.ts @@ -154,7 +154,7 @@ export class FolderContext implements vscode.Disposable { * @param event event type */ async fireEvent(event: FolderOperation) { - this.workspaceContext.fireEvent(this, event); + await this.workspaceContext.fireEvent(this, event); } /** Return edited Packages folder */ diff --git a/src/PackageWatcher.ts b/src/PackageWatcher.ts index 151a603a0..ab900f1de 100644 --- a/src/PackageWatcher.ts +++ b/src/PackageWatcher.ts @@ -128,7 +128,7 @@ export class PackageWatcher { async handleSwiftVersionFileChange() { const version = await this.readSwiftVersionFile(); if (version && version.toString() !== this.currentVersion?.toString()) { - this.workspaceContext.fireEvent( + await this.workspaceContext.fireEvent( this.folderContext, FolderOperation.swiftVersionUpdated ); @@ -162,7 +162,7 @@ export class PackageWatcher { async handlePackageSwiftChange() { // Load SwiftPM Package.swift description await this.folderContext.reload(); - this.workspaceContext.fireEvent(this.folderContext, FolderOperation.packageUpdated); + await this.workspaceContext.fireEvent(this.folderContext, FolderOperation.packageUpdated); } /** @@ -175,7 +175,10 @@ export class PackageWatcher { await this.folderContext.reloadPackageResolved(); // if file contents has changed then send resolve updated message if (this.folderContext.swiftPackage.resolved?.fileHash !== packageResolvedHash) { - this.workspaceContext.fireEvent(this.folderContext, FolderOperation.resolvedUpdated); + await this.workspaceContext.fireEvent( + this.folderContext, + FolderOperation.resolvedUpdated + ); } } @@ -186,6 +189,9 @@ export class PackageWatcher { */ private async handleWorkspaceStateChange() { await this.folderContext.reloadWorkspaceState(); - this.workspaceContext.fireEvent(this.folderContext, FolderOperation.workspaceStateUpdated); + await this.workspaceContext.fireEvent( + this.folderContext, + FolderOperation.workspaceStateUpdated + ); } } diff --git a/src/TestExplorer/TestExplorer.ts b/src/TestExplorer/TestExplorer.ts index 2ac95fc45..665898218 100644 --- a/src/TestExplorer/TestExplorer.ts +++ b/src/TestExplorer/TestExplorer.ts @@ -87,9 +87,9 @@ export class TestExplorer { this.testFileEdited = false; // only run discover tests if the library has tests - this.folderContext.swiftPackage.getTargets(TargetType.test).then(targets => { + void this.folderContext.swiftPackage.getTargets(TargetType.test).then(targets => { if (targets.length > 0) { - this.discoverTestsInWorkspace(this.tokenSource.token); + void this.discoverTestsInWorkspace(this.tokenSource.token); } }); } @@ -98,7 +98,7 @@ export class TestExplorer { // add file watcher to catch changes to swift test files const fileWatcher = this.folderContext.workspaceContext.onDidChangeSwiftFiles(({ uri }) => { if (this.testFileEdited === false) { - this.folderContext.getTestTarget(uri).then(target => { + void this.folderContext.getTestTarget(uri).then(target => { if (target) { this.testFileEdited = true; } @@ -138,7 +138,7 @@ export class TestExplorer { switch (operation) { case FolderOperation.add: if (folder) { - folder.swiftPackage.getTargets(TargetType.test).then(targets => { + void folder.swiftPackage.getTargets(TargetType.test).then(targets => { if (targets.length === 0) { return; } @@ -149,7 +149,7 @@ export class TestExplorer { if ( !configuration.folder(folder.workspaceFolder).disableAutoResolve ) { - folder.testExplorer?.discoverTestsInWorkspace( + void folder.testExplorer?.discoverTestsInWorkspace( tokenSource.token ); } @@ -158,7 +158,7 @@ export class TestExplorer { break; case FolderOperation.packageUpdated: if (folder) { - folder.swiftPackage.getTargets(TargetType.test).then(targets => { + void folder.swiftPackage.getTargets(TargetType.test).then(targets => { const hasTestTargets = targets.length > 0; if (hasTestTargets && !folder.hasTestExplorer()) { folder.addTestExplorer(); @@ -168,7 +168,7 @@ export class TestExplorer { !configuration.folder(folder.workspaceFolder) .disableAutoResolve ) { - folder.testExplorer?.discoverTestsInWorkspace( + void folder.testExplorer?.discoverTestsInWorkspace( tokenSource.token ); } @@ -219,7 +219,7 @@ export class TestExplorer { const testExplorer = folder?.testExplorer; if (testExplorer && symbols && uri && uri.scheme === "file") { if (isPathInsidePath(uri.fsPath, folder.folder.fsPath)) { - folder.swiftPackage.getTarget(uri.fsPath).then(target => { + void folder.swiftPackage.getTarget(uri.fsPath).then(target => { if (target && target.type === "test") { testExplorer.lspTestDiscovery .getDocumentTests(folder.swiftPackage, uri) diff --git a/src/TestExplorer/TestParsers/SwiftTestingOutputParser.ts b/src/TestExplorer/TestParsers/SwiftTestingOutputParser.ts index ff3281e07..3a9736a0b 100644 --- a/src/TestExplorer/TestParsers/SwiftTestingOutputParser.ts +++ b/src/TestExplorer/TestParsers/SwiftTestingOutputParser.ts @@ -211,7 +211,7 @@ export class SwiftTestingOutputParser { rl.on("line", line => this.parse(JSON.parse(line), runState)); - reader.start(readlinePipe); + void reader.start(readlinePipe); } /** diff --git a/src/TestExplorer/TestRunner.ts b/src/TestExplorer/TestRunner.ts index 8c11592e0..693efe1c1 100644 --- a/src/TestExplorer/TestRunner.ts +++ b/src/TestExplorer/TestRunner.ts @@ -729,7 +729,7 @@ export class TestRunner { // discarded. If the test run has already started this is a no-op so its safe to call it multiple times. this.testRun.testRunStarted(); - this.swiftTestOutputParser.close(); + void this.swiftTestOutputParser.close(); } } finally { outputStream.end(); @@ -807,7 +807,7 @@ export class TestRunner { } }); - this.folderContext.taskQueue.queueOperation( + void this.folderContext.taskQueue.queueOperation( new TaskOperation(task), this.testRun.token ); diff --git a/src/WorkspaceContext.ts b/src/WorkspaceContext.ts index 50e4a23c9..42f843411 100644 --- a/src/WorkspaceContext.ts +++ b/src/WorkspaceContext.ts @@ -133,7 +133,7 @@ export class WorkspaceContext implements vscode.Disposable { break; case FolderOperation.focus: this.updateContextKeys(event.folder); - this.updateContextKeysForFile(); + void this.updateContextKeysForFile(); break; case FolderOperation.unfocus: this.updateContextKeys(event.folder); @@ -232,7 +232,7 @@ export class WorkspaceContext implements vscode.Disposable { return; } - Promise.all([ + void Promise.all([ folderContext.swiftPackage.foundPackage, folderContext.swiftPackage.dependencies, ]).then(([foundPackage, dependencies]) => { @@ -256,7 +256,7 @@ export class WorkspaceContext implements vscode.Disposable { if (this.currentFolder) { const languageClient = this.languageClientManager.get(this.currentFolder); - languageClient.useLanguageClient(async client => { + await languageClient.useLanguageClient(async client => { const experimentalCaps = client.initializeResult?.capabilities.experimental; if (!experimentalCaps) { contextKeys.supportsReindexing = false; @@ -296,7 +296,7 @@ export class WorkspaceContext implements vscode.Disposable { console.log("Trying to run onDidChangeWorkspaceFolders on deleted context"); return; } - this.onDidChangeWorkspaceFolders(event); + void this.onDidChangeWorkspaceFolders(event); }); // add event listener for when the active edited text document changes const onDidChangeActiveWindow = vscode.window.onDidChangeActiveTextEditor(async editor => { @@ -327,7 +327,7 @@ export class WorkspaceContext implements vscode.Disposable { await this.focusFolder(null); } } - this.initialisationComplete(); + await this.initialisationComplete(); } /** @@ -450,7 +450,7 @@ export class WorkspaceContext implements vscode.Disposable { // if current folder is this folder send unfocus event by setting // current folder to undefined if (this.currentFolder === folder) { - this.focusFolder(null); + await this.focusFolder(null); } // run observer functions in reverse order when removing const observersReversed = [...this.observers]; @@ -519,10 +519,10 @@ export class WorkspaceContext implements vscode.Disposable { } } - private initialisationComplete() { + private async initialisationComplete() { this.initialisationFinished = true; if (this.lastFocusUri) { - this.focusUri(this.lastFocusUri); + await this.focusUri(this.lastFocusUri); this.lastFocusUri = undefined; } } diff --git a/src/commands/createNewProject.ts b/src/commands/createNewProject.ts index f0a358f99..16deb6238 100644 --- a/src/commands/createNewProject.ts +++ b/src/commands/createNewProject.ts @@ -30,7 +30,7 @@ export async function createNewProject(toolchain: SwiftToolchain | undefined): P // run before the Swift extension is activated. Show the toolchain error notification in // this case. if (!toolchain) { - showToolchainError(); + void showToolchainError(); return; } diff --git a/src/commands/dependencies/edit.ts b/src/commands/dependencies/edit.ts index 26b463bec..f49272547 100644 --- a/src/commands/dependencies/edit.ts +++ b/src/commands/dependencies/edit.ts @@ -47,7 +47,7 @@ export async function editDependency(identifier: string, ctx: WorkspaceContext) ); if (success) { - ctx.fireEvent(currentFolder, FolderOperation.resolvedUpdated); + await ctx.fireEvent(currentFolder, FolderOperation.resolvedUpdated); // add folder to workspace const index = vscode.workspace.workspaceFolders?.length ?? 0; vscode.workspace.updateWorkspaceFolders(index, 0, { diff --git a/src/commands/dependencies/unedit.ts b/src/commands/dependencies/unedit.ts index 018bfe1b5..816bec70d 100644 --- a/src/commands/dependencies/unedit.ts +++ b/src/commands/dependencies/unedit.ts @@ -60,7 +60,7 @@ async function uneditFolderDependency( ); await folder.taskQueue.queueOperation(uneditOperation); - ctx.fireEvent(folder, FolderOperation.resolvedUpdated); + await ctx.fireEvent(folder, FolderOperation.resolvedUpdated); // find workspace folder, and check folder still exists const folderIndex = vscode.workspace.workspaceFolders?.findIndex( item => item.name === identifier diff --git a/src/commands/dependencies/updateDepViewList.ts b/src/commands/dependencies/updateDepViewList.ts index 04cbb4400..42293619d 100644 --- a/src/commands/dependencies/updateDepViewList.ts +++ b/src/commands/dependencies/updateDepViewList.ts @@ -18,6 +18,6 @@ import { FolderOperation, WorkspaceContext } from "../../WorkspaceContext"; export function updateDependenciesViewList(ctx: WorkspaceContext, flatList: boolean) { if (ctx.currentFolder) { contextKeys.flatDependenciesList = flatList; - ctx.fireEvent(ctx.currentFolder, FolderOperation.packageViewUpdated); + void ctx.fireEvent(ctx.currentFolder, FolderOperation.packageViewUpdated); } } diff --git a/src/commands/dependencies/useLocal.ts b/src/commands/dependencies/useLocal.ts index ba57e2c43..63408f0f9 100644 --- a/src/commands/dependencies/useLocal.ts +++ b/src/commands/dependencies/useLocal.ts @@ -73,7 +73,7 @@ export async function useLocalDependency( true ); if (success) { - ctx.fireEvent(currentFolder, FolderOperation.resolvedUpdated); + await ctx.fireEvent(currentFolder, FolderOperation.resolvedUpdated); } return success; } diff --git a/src/commands/insertFunctionComment.ts b/src/commands/insertFunctionComment.ts index a3fb34b8b..8e2614440 100644 --- a/src/commands/insertFunctionComment.ts +++ b/src/commands/insertFunctionComment.ts @@ -26,5 +26,5 @@ export async function insertFunctionComment(workspaceContext: WorkspaceContext) return; } const line = activeEditor.selection.active.line; - workspaceContext.commentCompletionProvider.insert(activeEditor, line); + await workspaceContext.commentCompletionProvider.insert(activeEditor, line); } diff --git a/src/commands/testMultipleTimes.ts b/src/commands/testMultipleTimes.ts index b70c1fa4c..de78562a9 100644 --- a/src/commands/testMultipleTimes.ts +++ b/src/commands/testMultipleTimes.ts @@ -71,7 +71,7 @@ export async function runTestMultipleTimes( break; } } - runner.testRun.end(); + await runner.testRun.end(); return runStates; } diff --git a/src/commands/utilities.ts b/src/commands/utilities.ts index 430928c37..9e911a40f 100644 --- a/src/commands/utilities.ts +++ b/src/commands/utilities.ts @@ -71,6 +71,6 @@ export function updateAfterError(result: boolean, folderContext: FolderContext) folderContext.hasResolveErrors = !result; if (triggerResolvedUpdatedEvent && !folderContext.hasResolveErrors) { - folderContext.fireEvent(FolderOperation.resolvedUpdated); + void folderContext.fireEvent(FolderOperation.resolvedUpdated); } } diff --git a/src/configuration.ts b/src/configuration.ts index fb7754e14..03af80486 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -532,7 +532,7 @@ export function handleConfigurationChangeEvent( event.affectsConfiguration("swift.path") && configuration.path !== ctx.currentFolder?.toolchain.swiftFolderPath ) { - showReloadExtensionNotification( + void showReloadExtensionNotification( "Changing the Swift path requires Visual Studio Code be reloaded." ); } else if ( @@ -542,7 +542,7 @@ export function handleConfigurationChangeEvent( ) { vscode.commands.executeCommand("swift.restartLSPServer"); } else if (event.affectsConfiguration("swift.swiftEnvironmentVariables")) { - showReloadExtensionNotification( + void showReloadExtensionNotification( "Changing environment variables requires the project be reloaded." ); } diff --git a/src/coverage/LcovResults.ts b/src/coverage/LcovResults.ts index 3262648a5..4cad3fd74 100644 --- a/src/coverage/LcovResults.ts +++ b/src/coverage/LcovResults.ts @@ -88,7 +88,7 @@ export class TestCoverage { this.coverageDetails.set(uri, detailedCoverage); } } - this.lcovTmpFiles.dispose(); + await this.lcovTmpFiles.dispose(); } /** diff --git a/src/documentation/DocumentationPreviewEditor.ts b/src/documentation/DocumentationPreviewEditor.ts index 4ddd8cabc..05c30c596 100644 --- a/src/documentation/DocumentationPreviewEditor.ts +++ b/src/documentation/DocumentationPreviewEditor.ts @@ -152,7 +152,7 @@ export class DocumentationPreviewEditor implements vscode.Disposable { if (!this.activeTextEditor) { break; } - this.convertDocumentation(this.activeTextEditor); + void this.convertDocumentation(this.activeTextEditor); break; case "rendered": this.renderEmitter.fire(); @@ -166,7 +166,7 @@ export class DocumentationPreviewEditor implements vscode.Disposable { } this.activeTextEditor = activeTextEditor; this.activeTextEditorSelection = activeTextEditor.selection; - this.convertDocumentation(activeTextEditor); + void this.convertDocumentation(activeTextEditor); } private handleSelectionChange(event: vscode.TextEditorSelectionChangeEvent) { @@ -177,12 +177,12 @@ export class DocumentationPreviewEditor implements vscode.Disposable { return; } this.activeTextEditorSelection = event.textEditor.selection; - this.convertDocumentation(event.textEditor); + void this.convertDocumentation(event.textEditor); } private handleDocumentChange(event: vscode.TextDocumentChangeEvent) { if (this.activeTextEditor?.document === event.document) { - this.convertDocumentation(this.activeTextEditor); + void this.convertDocumentation(this.activeTextEditor); } } diff --git a/src/documentation/webview/webview.ts b/src/documentation/webview/webview.ts index adae07757..7ee31c63a 100644 --- a/src/documentation/webview/webview.ts +++ b/src/documentation/webview/webview.ts @@ -11,6 +11,7 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// +/* eslint-disable @typescript-eslint/no-floating-promises */ import { RenderNode, WebviewContent, WebviewMessage } from "./WebviewMessage"; import { createCommunicationBridge } from "./CommunicationBridge"; diff --git a/src/extension.ts b/src/extension.ts index f1df772ee..c4e61422e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -65,7 +65,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { // This can happen if the user has not installed Swift or if the toolchain is not // properly configured. if (!toolchain) { - showToolchainError(); + void showToolchainError(); return { workspaceContext: undefined, outputChannel, @@ -137,7 +137,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { context.subscriptions.push(TestExplorer.observeFolders(workspaceContext)); // setup workspace context with initial workspace folders - workspaceContext.addWorkspaceFolders(); + void workspaceContext.addWorkspaceFolders(); // Mark the extension as activated. contextKeys.isActivated = true; @@ -183,12 +183,12 @@ function handleFolderEvent( } if (folder.toolchain.swiftVersion.isGreaterThanOrEqual(new Version(5, 6, 0))) { - workspace.statusItem.showStatusWhileRunning( + void workspace.statusItem.showStatusWhileRunning( `Loading Swift Plugins (${FolderContext.uriName(folder.workspaceFolder.uri)})`, async () => { await folder.loadSwiftPlugins(outputChannel); workspace.updatePluginContextKey(); - folder.fireEvent(FolderOperation.pluginsUpdated); + await folder.fireEvent(FolderOperation.pluginsUpdated); } ); } @@ -203,16 +203,16 @@ function handleFolderEvent( switch (operation) { case FolderOperation.add: // Create launch.json files based on package description. - debug.makeDebugConfigurations(folder); + await debug.makeDebugConfigurations(folder); if (await folder.swiftPackage.foundPackage) { // do not await for this, let packages resolve in parallel - folderAdded(folder, workspace); + void folderAdded(folder, workspace); } break; case FolderOperation.packageUpdated: // Create launch.json files based on package description. - debug.makeDebugConfigurations(folder); + await debug.makeDebugConfigurations(folder); if ( (await folder.swiftPackage.foundPackage) && !configuration.folder(folder.workspaceFolder).disableAutoResolve diff --git a/src/sourcekit-lsp/LanguageClientConfiguration.ts b/src/sourcekit-lsp/LanguageClientConfiguration.ts index 23cf81cf1..9c4804938 100644 --- a/src/sourcekit-lsp/LanguageClientConfiguration.ts +++ b/src/sourcekit-lsp/LanguageClientConfiguration.ts @@ -252,7 +252,7 @@ export function lspClientOptions( ) { // Only prompt once an hour in case sourcekit is in a crash loop lastPrompted = now; - promptForDiagnostics(workspaceContext); + void promptForDiagnostics(workspaceContext); } return result; }; diff --git a/src/sourcekit-lsp/LanguageClientManager.ts b/src/sourcekit-lsp/LanguageClientManager.ts index d64d816b4..3159e115f 100644 --- a/src/sourcekit-lsp/LanguageClientManager.ts +++ b/src/sourcekit-lsp/LanguageClientManager.ts @@ -145,7 +145,7 @@ export class LanguageClientManager implements vscode.Disposable { } vscode.window.showInformationMessage(message, restartLSPButton).then(selected => { if (selected === restartLSPButton) { - this.restart(); + void this.restart(); } }); }); @@ -160,11 +160,11 @@ export class LanguageClientManager implements vscode.Disposable { ); // restart LSP server on creation of a new file const onDidCreateFileDisposable = vscode.workspace.onDidCreateFiles(() => { - this.restart(); + void this.restart(); }); // restart LSP server on deletion of a file const onDidDeleteFileDisposable = vscode.workspace.onDidDeleteFiles(() => { - this.restart(); + void this.restart(); }); this.subscriptions.push(onDidCreateFileDisposable, onDidDeleteFileDisposable); } @@ -236,7 +236,7 @@ export class LanguageClientManager implements vscode.Disposable { uri: client.code2ProtocolConverter.asUri(uri), name: FolderContext.uriName(uri), }; - client.sendNotification(DidChangeWorkspaceFoldersNotification.type, { + await client.sendNotification(DidChangeWorkspaceFoldersNotification.type, { event: { added: [workspaceFolder], removed: [] }, }); }); @@ -253,7 +253,7 @@ export class LanguageClientManager implements vscode.Disposable { uri: client.code2ProtocolConverter.asUri(uri), name: FolderContext.uriName(uri), }; - client.sendNotification(DidChangeWorkspaceFoldersNotification.type, { + await client.sendNotification(DidChangeWorkspaceFoldersNotification.type, { event: { added: [], removed: [workspaceFolder] }, }); }); @@ -266,7 +266,7 @@ export class LanguageClientManager implements vscode.Disposable { uri: client.code2ProtocolConverter.asUri(uri), name: FolderContext.uriName(uri), }; - client.sendNotification(DidChangeWorkspaceFoldersNotification.type, { + await client.sendNotification(DidChangeWorkspaceFoldersNotification.type, { event: { added: [workspaceFolder], removed: [] }, }); } @@ -445,7 +445,7 @@ export class LanguageClientManager implements vscode.Disposable { // we won't have any sub folder workspaces, but if the server crashed // or we forced a restart then we need to do this if (e.oldState === State.Starting && e.newState === State.Running) { - this.addSubFolderWorkspaces(client); + void this.addSubFolderWorkspaces(client); } }); if (client.clientOptions.workspaceFolder) { @@ -495,7 +495,7 @@ export class LanguageClientManager implements vscode.Disposable { }) .catch(reason => { this.folderContext.workspaceContext.outputChannel.log(`${reason}`); - this.languageClient?.stop(); + void this.languageClient?.stop(); this.languageClient = undefined; throw reason; }); diff --git a/src/sourcekit-lsp/LanguageClientToolchainCoordinator.ts b/src/sourcekit-lsp/LanguageClientToolchainCoordinator.ts index 86adb5f13..1097cb6f8 100644 --- a/src/sourcekit-lsp/LanguageClientToolchainCoordinator.ts +++ b/src/sourcekit-lsp/LanguageClientToolchainCoordinator.ts @@ -45,7 +45,7 @@ export class LanguageClientToolchainCoordinator implements vscode.Disposable { // This is mainly for testing purposes, as this class should be created immediately // when the extension is activated and the workspace context is first created. for (const folder of workspaceContext.folders) { - this.handleEvent(folder, FolderOperation.add, languageClientFactory); + void this.handleEvent(folder, FolderOperation.add, languageClientFactory); } } diff --git a/src/sourcekit-lsp/didChangeActiveDocument.ts b/src/sourcekit-lsp/didChangeActiveDocument.ts index dc26625b3..6fab63455 100644 --- a/src/sourcekit-lsp/didChangeActiveDocument.ts +++ b/src/sourcekit-lsp/didChangeActiveDocument.ts @@ -32,7 +32,7 @@ export class LSPActiveDocumentManager { next: (data: vscode.TextDocument) => Promise ) { this.openDocuments.add(document.uri); - next(document); + await next(document); } public async didClose( @@ -40,7 +40,7 @@ export class LSPActiveDocumentManager { next: (data: vscode.TextDocument) => Promise ) { this.openDocuments.add(document.uri); - next(document); + await next(document); } public activateDidChangeActiveDocument(client: langclient.LanguageClient): vscode.Disposable { @@ -65,7 +65,7 @@ export class LSPActiveDocumentManager { // Avoid sending multiple identical notifications in a row. if (textDocument !== this.lastActiveDocument) { - client.sendNotification(DidChangeActiveDocumentNotification.method, { + void client.sendNotification(DidChangeActiveDocumentNotification.method, { textDocument: textDocument, }); } diff --git a/src/sourcekit-lsp/peekDocuments.ts b/src/sourcekit-lsp/peekDocuments.ts index 51bc5a99b..bfbfb44fa 100644 --- a/src/sourcekit-lsp/peekDocuments.ts +++ b/src/sourcekit-lsp/peekDocuments.ts @@ -96,7 +96,7 @@ export function activatePeekDocuments(client: langclient.LanguageClient): vscode ) ); - openPeekedEditorIn(peekURI, peekPosition, peekLocations); + await openPeekedEditorIn(peekURI, peekPosition, peekLocations); return { success: true }; } diff --git a/src/tasks/TaskManager.ts b/src/tasks/TaskManager.ts index dfa1e3434..c91e65740 100644 --- a/src/tasks/TaskManager.ts +++ b/src/tasks/TaskManager.ts @@ -81,9 +81,9 @@ export class TaskManager implements vscode.Disposable { // one will run. The startingTaskPromise is setup when a executeTask is // called and resolved at the point it actually starts if (this.startingTaskPromise) { - this.startingTaskPromise.then(() => { - this.executeTaskAndResolve(task, resolve, reject, token); - }); + void this.startingTaskPromise.then(() => + this.executeTaskAndResolve(task, resolve, reject, token) + ); } else { this.executeTaskAndResolve(task, resolve, reject, token); } diff --git a/src/tasks/TaskQueue.ts b/src/tasks/TaskQueue.ts index 598fa53a3..6b5abca0e 100644 --- a/src/tasks/TaskQueue.ts +++ b/src/tasks/TaskQueue.ts @@ -218,7 +218,7 @@ export class TaskQueue { token ); this.queue.push(queuedOperation); - this.processQueue(); + void this.processQueue(); }); // if the last item does not have a promise then it is the queue // entry we just added above and we should set its promise @@ -292,7 +292,7 @@ export class TaskQueue { this.workspaceContext.statusItem.end(operation.operation.statusItemId); } this.activeOperation = undefined; - this.processQueue(); + void this.processQueue(); } /** Return if we already have an operation in the queue */ diff --git a/src/toolchain/SelectedXcodeWatcher.ts b/src/toolchain/SelectedXcodeWatcher.ts index d7954e810..05d6dcc43 100644 --- a/src/toolchain/SelectedXcodeWatcher.ts +++ b/src/toolchain/SelectedXcodeWatcher.ts @@ -52,7 +52,7 @@ export class SelectedXcodeWatcher implements vscode.Disposable { } // Deliberately not awaiting this, as we don't want to block the extension activation. - this.setup(); + void this.setup(); } dispose() { diff --git a/src/ui/ProjectPanelProvider.ts b/src/ui/ProjectPanelProvider.ts index ff33e1649..813ed01e0 100644 --- a/src/ui/ProjectPanelProvider.ts +++ b/src/ui/ProjectPanelProvider.ts @@ -635,7 +635,7 @@ class TaskPoller implements vscode.Disposable { private static POLL_INTERVAL = 5000; constructor(private onTasksChanged: () => void) { - this.pollTasks(); + void this.pollTasks(); } private async pollTasks() { diff --git a/src/ui/SwiftBuildStatus.ts b/src/ui/SwiftBuildStatus.ts index d597fc5aa..f0ae661a6 100644 --- a/src/ui/SwiftBuildStatus.ts +++ b/src/ui/SwiftBuildStatus.ts @@ -100,7 +100,7 @@ export class SwiftBuildStatus implements vscode.Disposable { progress => handleTaskOutput(message => progress.report({ message })) ); } else { - this.statusItem.showStatusWhileRunning(task, () => + void this.statusItem.showStatusWhileRunning(task, () => handleTaskOutput(message => this.statusItem.update(task, message)) ); } diff --git a/src/ui/win32.ts b/src/ui/win32.ts index faa9ce0ed..2f2760ff4 100644 --- a/src/ui/win32.ts +++ b/src/ui/win32.ts @@ -26,7 +26,7 @@ import * as vscode from "vscode"; */ export function checkAndWarnAboutWindowsSymlinks(outputChannel: SwiftOutputChannel) { if (process.platform === "win32" && configuration.warnAboutSymlinkCreation) { - isSymlinkAllowed(outputChannel).then(async canCreateSymlink => { + void isSymlinkAllowed(outputChannel).then(async canCreateSymlink => { if (canCreateSymlink) { return; } diff --git a/test/integration-tests/DiagnosticsManager.test.ts b/test/integration-tests/DiagnosticsManager.test.ts index e42e95d1a..c4fcbaeed 100644 --- a/test/integration-tests/DiagnosticsManager.test.ts +++ b/test/integration-tests/DiagnosticsManager.test.ts @@ -241,7 +241,7 @@ suite("DiagnosticsManager Test Suite", function () { // Clean up any lingering diagnostics workspaceContext.diagnostics.clear(); - workspaceContext.focusFolder(null); + await workspaceContext.focusFolder(null); resetSettings = await updateSettings({ "swift.diagnosticsStyle": style }); }); diff --git a/test/integration-tests/ExtensionActivation.test.ts b/test/integration-tests/ExtensionActivation.test.ts index 59d88f981..3bb3bc8a8 100644 --- a/test/integration-tests/ExtensionActivation.test.ts +++ b/test/integration-tests/ExtensionActivation.test.ts @@ -44,6 +44,7 @@ suite("Extension Activation/Deactivation Tests", () => { test("Duplicate Activation", async function () { await activate(this.test as Mocha.Test); + // eslint-disable-next-line @typescript-eslint/no-floating-promises assert.rejects(activateExtension(this.test as Mocha.Test), err => { const msg = (err as unknown as any).message; return ( diff --git a/test/integration-tests/testexplorer/TestExplorerIntegration.test.ts b/test/integration-tests/testexplorer/TestExplorerIntegration.test.ts index 7823c46e7..e50e2d760 100644 --- a/test/integration-tests/testexplorer/TestExplorerIntegration.test.ts +++ b/test/integration-tests/testexplorer/TestExplorerIntegration.test.ts @@ -50,6 +50,7 @@ import { Commands } from "../../../src/commands"; import { executeTaskAndWaitForResult } from "../../utilities/tasks"; import { createBuildAllTask } from "../../../src/tasks/SwiftTaskProvider"; import { FolderContext } from "../../../src/FolderContext"; +import { lineBreakRegex } from "../../../src/utilities/tasks"; suite("Test Explorer Suite", function () { const MAX_TEST_RUN_TIME_MINUTES = 5; @@ -261,9 +262,12 @@ suite("Test Explorer Suite", function () { // in the middle of the print, so the last line is actually end end of our // huge string. If they fix this in future this `find` ensures the test wont break. const needle = "100000"; - const lastTenLines = testRun.runState.output.slice(-10).join("\n"); + const output = testRun.runState.output.flatMap(o => + o.split(lineBreakRegex).filter(o => !!o) + ); + const lastTenLines = output.slice(-10).join("\n"); assertContainsTrimmed( - testRun.runState.output, + output, needle, `Expected all test output to be captured, but it was truncated. Last 10 lines of output were: ${lastTenLines}` ); diff --git a/test/integration-tests/testexplorer/XCTestOutputParser.test.ts b/test/integration-tests/testexplorer/XCTestOutputParser.test.ts index 80f45b09d..03e472ba7 100644 --- a/test/integration-tests/testexplorer/XCTestOutputParser.test.ts +++ b/test/integration-tests/testexplorer/XCTestOutputParser.test.ts @@ -86,7 +86,7 @@ ${tests.map( if (parserTestKind === ParserTestKind.Parallel) { const xmlResults = expectedStateToXML(expected); const xmlParser = new TestXUnitParser(hasMultiLineParallelTestOutput); - xmlParser.parse(xmlResults, testRunState, new SwiftOutputChannel("test")); + void xmlParser.parse(xmlResults, testRunState, new SwiftOutputChannel("test")); } assert.deepEqual(testRunState.tests, expected); diff --git a/test/integration-tests/utilities/testutilities.ts b/test/integration-tests/utilities/testutilities.ts index ee892bc1c..8f86e97ef 100644 --- a/test/integration-tests/utilities/testutilities.ts +++ b/test/integration-tests/utilities/testutilities.ts @@ -238,7 +238,7 @@ const extensionBootstrapper = (() => { lastTestName = undefined; }, - activateExtensionForSuite: async function (config?: { + activateExtensionForSuite: function (config?: { setup?: ( this: Mocha.Context, ctx: WorkspaceContext @@ -259,7 +259,7 @@ const extensionBootstrapper = (() => { ); }, - activateExtensionForTest: async function (config?: { + activateExtensionForTest: function (config?: { setup?: ( this: Mocha.Context, ctx: WorkspaceContext diff --git a/test/unit-tests/MockUtils.test.ts b/test/unit-tests/MockUtils.test.ts index 9e1eb102c..f922a5bdc 100644 --- a/test/unit-tests/MockUtils.test.ts +++ b/test/unit-tests/MockUtils.test.ts @@ -46,9 +46,9 @@ suite("MockUtils Test Suite", () => { }); values.push(num); }); - stubbedFn(1); - stubbedFn(2); - stubbedFn(3); + void stubbedFn(1); + void stubbedFn(2); + void stubbedFn(3); expect(values).to.deep.equal([]); await waitForReturnedPromises(stubbedFn); diff --git a/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts b/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts index 541fe8253..07038347f 100644 --- a/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts +++ b/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts @@ -594,7 +594,7 @@ suite("LanguageClientManager Suite", () => { const activeDocumentManager = new LSPActiveDocumentManager(); activeDocumentManager.activateDidChangeActiveDocument(instance(languageClientMock)); - activeDocumentManager.didOpen(document, async () => {}); + await activeDocumentManager.didOpen(document, async () => {}); if (_listener) { _listener(instance(mockObject({ document }))); @@ -625,7 +625,7 @@ suite("LanguageClientManager Suite", () => { await waitForReturnedPromises(languageClientMock.start); const activeDocumentManager = new LSPActiveDocumentManager(); - activeDocumentManager.didOpen(document, async () => {}); + await activeDocumentManager.didOpen(document, async () => {}); activeDocumentManager.activateDidChangeActiveDocument(instance(languageClientMock));