Skip to content

Commit 8b50169

Browse files
authored
Merge pull request #7599 from dibarbet/async_lint
Enable no floating promises lint rule
2 parents 5ed63dd + bb0b76c commit 8b50169

File tree

74 files changed

+627
-501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+627
-501
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
},
55
extends: [
66
"eslint:recommended",
7-
"plugin:@typescript-eslint/recommended"
7+
"plugin:@typescript-eslint/recommended",
88
],
99
parser: "@typescript-eslint/parser",
1010
parserOptions: {
@@ -33,6 +33,7 @@ module.exports = {
3333
],
3434
"@typescript-eslint/no-namespace": "off",
3535
"@typescript-eslint/promise-function-async": "error",
36+
"@typescript-eslint/no-floating-promises": "error",
3637
"prefer-promise-reject-errors": "error",
3738
"curly": "error",
3839
"prettier/prettier": [ "error", { "endOfLine": "auto" } ],

l10n/bundle.l10n.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"Can't parse envFile {0} because of {1}": "Can't parse envFile {0} because of {1}",
3030
"Open envFile": "Open envFile",
3131
"Yes": "Yes",
32-
"Not Now": "Not Now",
33-
"More Information": "More Information",
34-
"The selected launch configuration is configured to launch a web browser but no trusted development certificate was found. Create a trusted self-signed certificate?": "The selected launch configuration is configured to launch a web browser but no trusted development certificate was found. Create a trusted self-signed certificate?",
3532
"Self-signed certificate sucessfully {0}": "Self-signed certificate sucessfully {0}",
3633
"Couldn't create self-signed certificate. {0}\ncode: {1}\nstdout: {2}": "Couldn't create self-signed certificate. {0}\ncode: {1}\nstdout: {2}",
3734
"Show Output": "Show Output",
3835
"Couldn't create self-signed certificate. See output for more information.": "Couldn't create self-signed certificate. See output for more information.",
36+
"Not Now": "Not Now",
37+
"More Information": "More Information",
38+
"The selected launch configuration is configured to launch a web browser but no trusted development certificate was found. Create a trusted self-signed certificate?": "The selected launch configuration is configured to launch a web browser but no trusted development certificate was found. Create a trusted self-signed certificate?",
3939
"No executable projects": "No executable projects",
4040
"Select the project to launch": "Select the project to launch",
4141
"Invalid project index": "Invalid project index",
@@ -140,8 +140,8 @@
140140
"OmniSharp requires a complete install of Mono (including MSBuild) to provide language services when `omnisharp.useModernNet` is disabled in Settings. Please install the latest Mono and restart.": "OmniSharp requires a complete install of Mono (including MSBuild) to provide language services when `omnisharp.useModernNet` is disabled in Settings. Please install the latest Mono and restart.",
141141
"Download Mono": "Download Mono",
142142
"Open settings": "Open settings",
143-
"dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change": "dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change",
144143
"Reload Window": "Reload Window",
144+
"dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change": "dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change",
145145
"C# configuration has changed. Would you like to relaunch the Language Server with your changes?": "C# configuration has changed. Would you like to relaunch the Language Server with your changes?",
146146
"Restart Language Server": "Restart Language Server",
147147
"project.json is no longer a supported project format for .NET Core applications.": "project.json is no longer a supported project format for .NET Core applications.",

src/coreclrDebug/activate.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { RemoteAttachPicker } from '../shared/processPicker';
2020
import CompositeDisposable from '../compositeDisposable';
2121
import { BaseVsDbgConfigurationProvider } from '../shared/configurationProvider';
2222
import { omnisharpOptions } from '../shared/options';
23+
import { ActionOption, showErrorMessage } from '../shared/observers/utils/showMessage';
2324

2425
export async function activate(
2526
thisExtension: vscode.Extension<any>,
@@ -46,7 +47,7 @@ export async function activate(
4647
showInstallErrorMessage(eventStream);
4748
}
4849
} else if (!CoreClrDebugUtil.existsSync(debugUtil.installCompleteFilePath())) {
49-
completeDebuggerInstall(debugUtil, platformInformation, eventStream);
50+
await completeDebuggerInstall(debugUtil, platformInformation, eventStream);
5051
}
5152

5253
// register process picker for attach for legacy configurations.
@@ -80,7 +81,7 @@ export async function activate(
8081
}
8182
}
8283

83-
vscode.debug.startDebugging(
84+
await vscode.debug.startDebugging(
8485
undefined,
8586
{
8687
name: '.NET Core Attach',
@@ -183,7 +184,8 @@ async function completeDebuggerInstall(
183184
const isValidArchitecture = await checkIsValidArchitecture(platformInformation, eventStream);
184185
if (!isValidArchitecture) {
185186
eventStream.post(new DebuggerNotInstalledFailure());
186-
vscode.window.showErrorMessage(
187+
showErrorMessage(
188+
vscode,
187189
vscode.l10n.t(
188190
'Failed to complete the installation of the C# extension. Please see the error in the output window below.'
189191
)
@@ -192,7 +194,7 @@ async function completeDebuggerInstall(
192194
}
193195

194196
// Write install.complete
195-
CoreClrDebugUtil.writeEmptyFile(debugUtil.installCompleteFilePath());
197+
await CoreClrDebugUtil.writeEmptyFile(debugUtil.installCompleteFilePath());
196198

197199
return true;
198200
} catch (err) {
@@ -208,7 +210,8 @@ async function completeDebuggerInstall(
208210

209211
function showInstallErrorMessage(eventStream: EventStream) {
210212
eventStream.post(new DebuggerNotInstalledFailure());
211-
vscode.window.showErrorMessage(
213+
showErrorMessage(
214+
vscode,
212215
vscode.l10n.t(
213216
'An error occurred during installation of the .NET Debugger. The C# extension may need to be reinstalled.'
214217
)
@@ -218,22 +221,28 @@ function showInstallErrorMessage(eventStream: EventStream) {
218221
function showDotnetToolsWarning(message: string): void {
219222
const config = vscode.workspace.getConfiguration('csharp');
220223
if (!config.get('suppressDotnetInstallWarning', false)) {
221-
const getDotNetMessage = vscode.l10n.t('Get the SDK');
222-
const goToSettingsMessage = vscode.l10n.t('Disable message in settings');
223-
const helpMessage = vscode.l10n.t('Help');
224+
const getDotNetMessage: ActionOption = {
225+
title: vscode.l10n.t('Get the SDK'),
226+
action: async () => {
227+
await vscode.env.openExternal(vscode.Uri.parse('https://dot.net/core-sdk-vscode'));
228+
},
229+
};
230+
const goToSettingsMessage: ActionOption = {
231+
title: vscode.l10n.t('Disable message in settings'),
232+
action: async () => {
233+
await vscode.commands.executeCommand('workbench.action.openGlobalSettings');
234+
},
235+
};
236+
const helpMessage: ActionOption = {
237+
title: vscode.l10n.t('Help'),
238+
action: async () => {
239+
await vscode.env.openExternal(vscode.Uri.parse('https://aka.ms/VSCode-CS-DotnetNotFoundHelp'));
240+
},
241+
};
242+
224243
// Buttons are shown in right-to-left order, with a close button to the right of everything;
225244
// getDotNetMessage will be the first button, then goToSettingsMessage, then the close button.
226-
vscode.window.showErrorMessage(message, goToSettingsMessage, getDotNetMessage, helpMessage).then((value) => {
227-
if (value === getDotNetMessage) {
228-
const dotnetcoreURL = 'https://dot.net/core-sdk-vscode';
229-
vscode.env.openExternal(vscode.Uri.parse(dotnetcoreURL));
230-
} else if (value === goToSettingsMessage) {
231-
vscode.commands.executeCommand('workbench.action.openGlobalSettings');
232-
} else if (value == helpMessage) {
233-
const helpURL = 'https://aka.ms/VSCode-CS-DotnetNotFoundHelp';
234-
vscode.env.openExternal(vscode.Uri.parse(helpURL));
235-
}
236-
});
245+
showErrorMessage(vscode, message, goToSettingsMessage, getDotNetMessage, helpMessage);
237246
}
238247
}
239248

src/createTmpAsset.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export async function CreateTmpDir(unsafeCleanup: boolean): Promise<TmpAsset> {
4343
name: tmpDir.name,
4444
dispose: () => {
4545
if (unsafeCleanup) {
46-
rimraf(tmpDir.name); //to delete directories that have folders inside them
46+
rimraf(tmpDir.name).catch((rejectReason) => {
47+
throw new Error(`Failed to cleanup ${tmpDir.name} at ${tmpDir.fd}: ${rejectReason}`);
48+
}); //to delete directories that have folders inside them
4749
} else {
4850
tmpDir.removeCallback();
4951
}

src/lsptoolshost/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async function openSolution(languageServer: RoslynLanguageServer): Promise<vscod
187187

188188
if (launchTarget) {
189189
const uri = vscode.Uri.file(launchTarget.target);
190-
languageServer.openSolution(uri);
190+
await languageServer.openSolution(uri);
191191
return uri;
192192
}
193193
}

src/lsptoolshost/languageStatusBar.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ class ProjectContextStatus {
7474
projectContextService.onActiveFileContextChanged((e) => {
7575
item.text = e.context._vs_label;
7676
});
77-
projectContextService.refresh();
77+
78+
// Trigger a refresh, but don't block creation on the refresh completing.
79+
projectContextService.refresh().catch((e) => {
80+
throw new Error(`Error refreshing project context status ${e}`);
81+
});
7882
}
7983
}

src/lsptoolshost/onAutoInsert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async function applyAutoInsertEdit(
110110
}
111111

112112
if (response.command !== undefined) {
113-
vscode.commands.executeCommand(response.command.command, response.command.arguments);
113+
await vscode.commands.executeCommand(response.command.command, response.command.arguments);
114114
}
115115
}
116116
}

src/lsptoolshost/optionChanges.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import * as vscode from 'vscode';
77
import { Observable } from 'rxjs';
88
import { CommonOptionsThatTriggerReload, LanguageServerOptionsThatTriggerReload } from '../shared/options';
99
import { HandleOptionChanges, OptionChangeObserver, OptionChanges } from '../shared/observers/optionChangeObserver';
10-
import ShowInformationMessage from '../shared/observers/utils/showInformationMessage';
1110
import Disposable from '../disposable';
11+
import { CommandOption, showInformationMessage } from '../shared/observers/utils/showMessage';
1212

1313
export function registerLanguageServerOptionChanges(optionObservable: Observable<void>): Disposable {
1414
const optionChangeObserver: OptionChangeObserver = {
@@ -34,19 +34,18 @@ function handleLanguageServerOptionChanges(changedOptions: OptionChanges): void
3434
return;
3535
}
3636

37-
const reloadTitle = vscode.l10n.t('Reload Window');
38-
const reloadCommand = 'workbench.action.reloadWindow';
37+
const reloadTitle: CommandOption = {
38+
title: vscode.l10n.t('Reload Window'),
39+
command: 'workbench.action.reloadWindow',
40+
};
3941
if (changedOptions.changedCommonOptions.find((key) => key === 'useOmnisharpServer')) {
4042
// If the user has changed the useOmnisharpServer flag we need to reload the window.
41-
ShowInformationMessage(
43+
showInformationMessage(
4244
vscode,
4345
vscode.l10n.t(
4446
'dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change'
4547
),
46-
{
47-
title: reloadTitle,
48-
command: reloadCommand,
49-
}
48+
reloadTitle
5049
);
5150
return;
5251
}
@@ -56,5 +55,5 @@ function handleLanguageServerOptionChanges(changedOptions: OptionChanges): void
5655
const message = vscode.l10n.t(
5756
'C# configuration has changed. Would you like to reload the window to apply your changes?'
5857
);
59-
ShowInformationMessage(vscode, message, { title: reloadTitle, command: reloadCommand });
58+
showInformationMessage(vscode, message, reloadTitle);
6059
}

src/lsptoolshost/restore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
ProjectNeedsRestoreRequest,
1414
} from './roslynProtocol';
1515
import path = require('path');
16+
import { showErrorMessage } from '../shared/observers/utils/showMessage';
1617

1718
let _restoreInProgress = false;
1819

@@ -79,7 +80,7 @@ export async function restore(
7980
showOutput: boolean
8081
): Promise<void> {
8182
if (_restoreInProgress) {
82-
vscode.window.showErrorMessage(vscode.l10n.t('Restore already in progress'));
83+
showErrorMessage(vscode, vscode.l10n.t('Restore already in progress'));
8384
return;
8485
}
8586
_restoreInProgress = true;

0 commit comments

Comments
 (0)