Fix some unhandled promise lint errors (#16924)

This commit is contained in:
Charles Gagnon
2021-08-30 09:08:28 -07:00
committed by GitHub
parent fde114bb14
commit 7804c87c87
14 changed files with 48 additions and 48 deletions

View File

@@ -126,7 +126,7 @@ export class BookModel {
} }
if (await fs.pathExists(this._tableOfContentsPath)) { if (await fs.pathExists(this._tableOfContentsPath)) {
vscode.commands.executeCommand('setContext', 'bookOpened', true); void vscode.commands.executeCommand('setContext', 'bookOpened', true);
this.watchTOC(); this.watchTOC();
} else { } else {
this._errorMessage = loc.missingTocError; this._errorMessage = loc.missingTocError;
@@ -322,7 +322,7 @@ export class BookModel {
treeItems.push(markdown); treeItems.push(markdown);
} else { } else {
this._errorMessage = loc.missingFileError(sections[i].title, book.title); this._errorMessage = loc.missingFileError(sections[i].title, book.title);
vscode.window.showErrorMessage(this._errorMessage); void vscode.window.showErrorMessage(this._errorMessage);
} }
} }
} }

View File

@@ -26,9 +26,9 @@ export class BookPinManager implements IBookPinManager {
setPinnedSectionContext(): void { setPinnedSectionContext(): void {
if (getPinnedNotebooks().length > 0) { if (getPinnedNotebooks().length > 0) {
vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, constants.showPinnedBooksContextKey, true); void vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, constants.showPinnedBooksContextKey, true);
} else { } else {
vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, constants.showPinnedBooksContextKey, false); void vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, constants.showPinnedBooksContextKey, false);
} }
} }

View File

@@ -112,7 +112,7 @@ export class BookTocManager implements IBookTocManager {
} }
} }
catch (error) { catch (error) {
vscode.window.showWarningMessage(loc.msgCreateBookWarningMsg(content)); void vscode.window.showWarningMessage(loc.msgCreateBookWarningMsg(content));
} }
} }
return toc; return toc;
@@ -132,7 +132,7 @@ export class BookTocManager implements IBookTocManager {
} }
this.movedFiles.set(src, path.join(newFileName.concat(' - ', counter.toString())).concat(path.parse(dest).ext)); this.movedFiles.set(src, path.join(newFileName.concat(' - ', counter.toString())).concat(path.parse(dest).ext));
await fs.move(src, path.join(newFileName.concat(' - ', counter.toString())).concat(path.parse(dest).ext), { overwrite: true }); await fs.move(src, path.join(newFileName.concat(' - ', counter.toString())).concat(path.parse(dest).ext), { overwrite: true });
vscode.window.showInformationMessage(loc.duplicateFileError(path.parse(dest).base, src, newFileName.concat(' - ', counter.toString()))); void vscode.window.showInformationMessage(loc.duplicateFileError(path.parse(dest).base, src, newFileName.concat(' - ', counter.toString())));
return newFileName.concat(' - ', counter.toString()); return newFileName.concat(' - ', counter.toString());
} }
@@ -424,7 +424,7 @@ export class BookTocManager implements IBookTocManager {
} }
} catch (e) { } catch (e) {
await this.recovery(); await this.recovery();
vscode.window.showErrorMessage(loc.editBookError(element.book.contentPath, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.editBookError(element.book.contentPath, e instanceof Error ? e.message : e));
} finally { } finally {
try { try {
await this._targetBook.reinitializeContents(); await this._targetBook.reinitializeContents();

View File

@@ -106,7 +106,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
} }
set _visitedNotebooks(value: string[]) { set _visitedNotebooks(value: string[]) {
this._extensionContext.globalState.update(constants.visitedNotebooksMementoKey, value); void this._extensionContext.globalState.update(constants.visitedNotebooksMementoKey, value);
} }
trustBook(bookTreeItem?: BookTreeItem): void { trustBook(bookTreeItem?: BookTreeItem): void {
@@ -125,9 +125,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
}); });
} }
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.TrustNotebook); TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.TrustNotebook);
vscode.window.showInformationMessage(loc.msgBookTrusted); void vscode.window.showInformationMessage(loc.msgBookTrusted);
} else { } else {
vscode.window.showInformationMessage(loc.msgBookAlreadyTrusted); void vscode.window.showInformationMessage(loc.msgBookAlreadyTrusted);
} }
} }
} }
@@ -248,7 +248,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
if (index !== -1) { if (index !== -1) {
this.books.splice(index, 1); this.books.splice(index, 1);
} }
vscode.window.showErrorMessage(loc.openFileError(bookPath, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.openFileError(bookPath, e instanceof Error ? e.message : e));
} }
} }
@@ -303,7 +303,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
} }
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.CloseBook); TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.CloseBook);
} catch (e) { } catch (e) {
vscode.window.showErrorMessage(loc.closeBookError(book.root, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.closeBookError(book.root, e instanceof Error ? e.message : e));
} finally { } finally {
// remove watch on toc file. // remove watch on toc file.
if (deletedBook && !deletedBook.isNotebook) { if (deletedBook && !deletedBook.isNotebook) {
@@ -388,7 +388,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
} }
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.OpenNotebookFromBook); TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.OpenNotebookFromBook);
} catch (e) { } catch (e) {
vscode.window.showErrorMessage(loc.openNotebookError(resource, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.openNotebookError(resource, e instanceof Error ? e.message : e));
} }
} }
@@ -490,9 +490,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
openMarkdown(resource: string): void { openMarkdown(resource: string): void {
try { try {
vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.file(resource)); void vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.file(resource));
} catch (e) { } catch (e) {
vscode.window.showErrorMessage(loc.openMarkdownError(resource, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.openMarkdownError(resource, e instanceof Error ? e.message : e));
} }
} }
@@ -507,7 +507,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
initialDirtyState: false initialDirtyState: false
}); });
} catch (e) { } catch (e) {
vscode.window.showErrorMessage(loc.openUntitledNotebookError(resource, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.openUntitledNotebookError(resource, e instanceof Error ? e.message : e));
} }
} }
@@ -547,7 +547,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
this.books.splice(untitledBookIndex, 1); this.books.splice(untitledBookIndex, 1);
this.currentBook = undefined; this.currentBook = undefined;
this._onDidChangeTreeData.fire(undefined); this._onDidChangeTreeData.fire(undefined);
vscode.commands.executeCommand('bookTreeView.openBook', destinationUri.fsPath, false, undefined); void vscode.commands.executeCommand('bookTreeView.openBook', destinationUri.fsPath, false, undefined);
} }
} }
} }
@@ -561,12 +561,12 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
} else if (this.currentBook && !this.currentBook.isNotebook) { } else if (this.currentBook && !this.currentBook.isNotebook) {
folderToSearch = path.join(this.currentBook.contentFolderPath); folderToSearch = path.join(this.currentBook.contentFolderPath);
} else { } else {
vscode.window.showErrorMessage(loc.noBooksSelectedError); void vscode.window.showErrorMessage(loc.noBooksSelectedError);
} }
if (folderToSearch) { if (folderToSearch) {
let filesToIncludeFiltered = path.join(folderToSearch, '**', '*.md') + ',' + path.join(folderToSearch, '**', '*.ipynb'); let filesToIncludeFiltered = path.join(folderToSearch, '**', '*.md') + ',' + path.join(folderToSearch, '**', '*.ipynb');
vscode.commands.executeCommand('workbench.action.findInFiles', { filesToInclude: filesToIncludeFiltered, query: '' }); void vscode.commands.executeCommand('workbench.action.findInFiles', { filesToInclude: filesToIncludeFiltered, query: '' });
} }
} }
@@ -659,7 +659,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
try { try {
await vscode.env.openExternal(vscode.Uri.parse(resource)); await vscode.env.openExternal(vscode.Uri.parse(resource));
} catch (e) { } catch (e) {
vscode.window.showErrorMessage(loc.openExternalLinkError(resource, e instanceof Error ? e.message : e)); void vscode.window.showErrorMessage(loc.openExternalLinkError(resource, e instanceof Error ? e.message : e));
} }
} }

View File

@@ -83,7 +83,7 @@ export class GitHubRemoteBook extends RemoteBook {
} }
await fs.promises.unlink(remoteBookFullPath.fsPath); await fs.promises.unlink(remoteBookFullPath.fsPath);
this.outputChannel.appendLine(loc.msgRemoteBookDownloadComplete); this.outputChannel.appendLine(loc.msgRemoteBookDownloadComplete);
vscode.commands.executeCommand('notebook.command.openNotebookFolder', this.localPath.fsPath, undefined, true); void vscode.commands.executeCommand('notebook.command.openNotebookFolder', this.localPath.fsPath, undefined, true);
} }
catch (err) { catch (err) {
this.outputChannel.appendLine(loc.msgRemoteBookUnpackingError); this.outputChannel.appendLine(loc.msgRemoteBookUnpackingError);

View File

@@ -49,7 +49,7 @@ export class NotebookUtils {
await azdata.nb.showNotebookDocument(file[0]); await azdata.nb.showNotebookDocument(file[0]);
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err)); void vscode.window.showErrorMessage(getErrorMessage(err));
} }
} }
@@ -62,7 +62,7 @@ export class NotebookUtils {
throw new Error(noNotebookVisible); throw new Error(noNotebookVisible);
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err)); void vscode.window.showErrorMessage(getErrorMessage(err));
} }
} }
@@ -75,7 +75,7 @@ export class NotebookUtils {
throw new Error(noNotebookVisible); throw new Error(noNotebookVisible);
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err)); void vscode.window.showErrorMessage(getErrorMessage(err));
} }
} }
@@ -88,7 +88,7 @@ export class NotebookUtils {
throw new Error(noNotebookVisible); throw new Error(noNotebookVisible);
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err)); void vscode.window.showErrorMessage(getErrorMessage(err));
} }
} }
@@ -107,7 +107,7 @@ export class NotebookUtils {
throw new Error(noNotebookVisible); throw new Error(noNotebookVisible);
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err)); void vscode.window.showErrorMessage(getErrorMessage(err));
} }
} }

View File

@@ -146,9 +146,9 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
azdata.nb.onDidChangeActiveNotebookEditor(e => { azdata.nb.onDidChangeActiveNotebookEditor(e => {
if (e.document.uri.scheme === 'untitled') { if (e.document.uri.scheme === 'untitled') {
providedBookTreeViewProvider.revealDocumentInTreeView(e.document.uri, false, false); void providedBookTreeViewProvider.revealDocumentInTreeView(e.document.uri, false, false);
} else { } else {
bookTreeViewProvider.revealDocumentInTreeView(e.document.uri, false, false); void bookTreeViewProvider.revealDocumentInTreeView(e.document.uri, false, false);
} }
}); });

View File

@@ -123,7 +123,7 @@ export class JupyterController {
// Verify this is a .ipynb file since this isn't actually filtered on Mac/Linux // Verify this is a .ipynb file since this isn't actually filtered on Mac/Linux
if (path.extname(fileUri.fsPath) !== '.ipynb') { if (path.extname(fileUri.fsPath) !== '.ipynb') {
// in the future might want additional supported types // in the future might want additional supported types
vscode.window.showErrorMessage(localize('unsupportedFileType', "Only .ipynb Notebooks are supported")); void vscode.window.showErrorMessage(localize('unsupportedFileType', "Only .ipynb Notebooks are supported"));
} else { } else {
await azdata.nb.showNotebookDocument(fileUri, { await azdata.nb.showNotebookDocument(fileUri, {
connectionProfile: profile, connectionProfile: profile,
@@ -174,7 +174,7 @@ export class JupyterController {
await this._jupyterInstallation.startInstallProcess(true); await this._jupyterInstallation.startInstallProcess(true);
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(utils.getErrorMessage(err)); void vscode.window.showErrorMessage(utils.getErrorMessage(err));
} }
} }
@@ -202,7 +202,7 @@ export class JupyterController {
packagesDialog.showDialog(); packagesDialog.showDialog();
} catch (error) { } catch (error) {
let message = utils.getErrorMessage(error); let message = utils.getErrorMessage(error);
vscode.window.showErrorMessage(message); void vscode.window.showErrorMessage(message);
} }
} }
@@ -236,10 +236,10 @@ export class JupyterController {
public doConfigurePython(jupyterInstaller: JupyterServerInstallation): void { public doConfigurePython(jupyterInstaller: JupyterServerInstallation): void {
let pythonWizard = new ConfigurePythonWizard(jupyterInstaller); let pythonWizard = new ConfigurePythonWizard(jupyterInstaller);
pythonWizard.start().catch((err: any) => { pythonWizard.start().catch((err: any) => {
vscode.window.showErrorMessage(utils.getErrorMessage(err)); void vscode.window.showErrorMessage(utils.getErrorMessage(err));
}); });
pythonWizard.setupComplete.catch((err: any) => { pythonWizard.setupComplete.catch((err: any) => {
vscode.window.showErrorMessage(utils.getErrorMessage(err)); void vscode.window.showErrorMessage(utils.getErrorMessage(err));
}); });
} }

View File

@@ -44,7 +44,7 @@ export class JupyterNotebookManager implements nb.NotebookManager, vscode.Dispos
dispose() { dispose() {
if (this._sessionManager) { if (this._sessionManager) {
this._sessionManager.shutdownAll().then(() => this._sessionManager.dispose()); void this._sessionManager.shutdownAll().then(() => this._sessionManager.dispose());
} }
if (this._serverManager) { if (this._serverManager) {
this._serverManager.stopServer().then(success => undefined, error => vscode.window.showErrorMessage(error)); this._serverManager.stopServer().then(success => undefined, error => vscode.window.showErrorMessage(error));

View File

@@ -139,7 +139,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
this.outputChannel = outputChannel; this.outputChannel = outputChannel;
this._runningOnSAW = vscode.env.appName.toLowerCase().indexOf('saw') > 0; this._runningOnSAW = vscode.env.appName.toLowerCase().indexOf('saw') > 0;
vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, 'notebook:runningOnSAW', this._runningOnSAW); void vscode.commands.executeCommand(constants.BuiltInCommands.SetContext, 'notebook:runningOnSAW', this._runningOnSAW);
if (this._runningOnSAW) { if (this._runningOnSAW) {
this._pythonInstallationPath = `${vscode.env.appRoot}\\ads-python`; this._pythonInstallationPath = `${vscode.env.appRoot}\\ads-python`;
@@ -170,7 +170,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
} }
private async installDependencies(backgroundOperation: azdata.BackgroundOperation, forceInstall: boolean, packages: PythonPkgDetails[]): Promise<void> { private async installDependencies(backgroundOperation: azdata.BackgroundOperation, forceInstall: boolean, packages: PythonPkgDetails[]): Promise<void> {
vscode.window.showInformationMessage(msgInstallPkgStart); void vscode.window.showInformationMessage(msgInstallPkgStart);
this.outputChannel.show(true); this.outputChannel.show(true);
this.outputChannel.appendLine(msgInstallPkgProgress); this.outputChannel.appendLine(msgInstallPkgProgress);
@@ -224,7 +224,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
this.outputChannel.appendLine(msgInstallPkgFinish); this.outputChannel.appendLine(msgInstallPkgFinish);
backgroundOperation.updateStatus(azdata.TaskStatus.Succeeded, msgInstallPkgFinish); backgroundOperation.updateStatus(azdata.TaskStatus.Succeeded, msgInstallPkgFinish);
vscode.window.showInformationMessage(msgInstallPkgFinish); void vscode.window.showInformationMessage(msgInstallPkgFinish);
} }
private installPythonPackage(backgroundOperation: azdata.BackgroundOperation, usingExistingPython: boolean, pythonInstallationPath: string, outputChannel: vscode.OutputChannel): Promise<void> { private installPythonPackage(backgroundOperation: azdata.BackgroundOperation, usingExistingPython: boolean, pythonInstallationPath: string, outputChannel: vscode.OutputChannel): Promise<void> {
@@ -438,7 +438,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
} }
if (this._installInProgress) { if (this._installInProgress) {
vscode.window.showInformationMessage(msgWaitingForInstall); void vscode.window.showInformationMessage(msgWaitingForInstall);
return this._installCompletion.promise; return this._installCompletion.promise;
} }
@@ -500,7 +500,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
return Promise.resolve(); return Promise.resolve();
} }
if (this._installInProgress) { if (this._installInProgress) {
vscode.window.showInformationMessage(msgWaitingForInstall); void vscode.window.showInformationMessage(msgWaitingForInstall);
return this._installCompletion.promise; return this._installCompletion.promise;
} }
@@ -532,7 +532,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
if (response === yes) { if (response === yes) {
this._oldPythonInstallationPath = path.join(this._pythonInstallationPath, '0.0.1'); this._oldPythonInstallationPath = path.join(this._pythonInstallationPath, '0.0.1');
this._oldPythonExecutable = this._pythonExecutable; this._oldPythonExecutable = this._pythonExecutable;
vscode.commands.executeCommand(constants.jupyterConfigurePython); void vscode.commands.executeCommand(constants.jupyterConfigurePython);
} else if (response === dontAskAgain) { } else if (response === dontAskAgain) {
await notebookConfig.update(constants.dontPromptPythonUpdate, true, vscode.ConfigurationTarget.Global); await notebookConfig.update(constants.dontPromptPythonUpdate, true, vscode.ConfigurationTarget.Global);
} }

View File

@@ -70,7 +70,7 @@ export class LocalJupyterServerManager implements nb.ServerManager, vscode.Dispo
public dispose(): void { public dispose(): void {
this.stopServer().catch(err => { this.stopServer().catch(err => {
let msg = utils.getErrorMessage(err); let msg = utils.getErrorMessage(err);
vscode.window.showErrorMessage(localize('shutdownError', "Shutdown of Notebook server failed: {0}", msg)); void vscode.window.showErrorMessage(localize('shutdownError', "Shutdown of Notebook server failed: {0}", msg));
}); });
} }
@@ -105,7 +105,7 @@ export class LocalJupyterServerManager implements nb.ServerManager, vscode.Dispo
private async doStartServer(kernelSpec: nb.IKernelSpec): Promise<IServerInstance> { // We can't find or create servers until the installation is complete private async doStartServer(kernelSpec: nb.IKernelSpec): Promise<IServerInstance> { // We can't find or create servers until the installation is complete
let installation = this.options.jupyterInstallation; let installation = this.options.jupyterInstallation;
await installation.promptForPythonInstall(kernelSpec.display_name); await installation.promptForPythonInstall(kernelSpec.display_name);
vscode.commands.executeCommand(BuiltInCommands.SetContext, CommandContext.NotebookPythonInstalled, true); void vscode.commands.executeCommand(BuiltInCommands.SetContext, CommandContext.NotebookPythonInstalled, true);
// Calculate the path to use as the notebook-dir for Jupyter based on the path of the uri of the // Calculate the path to use as the notebook-dir for Jupyter based on the path of the uri of the
// notebook to open. This will be the workspace folder if the notebook uri is inside a workspace // notebook to open. This will be the workspace folder if the notebook uri is inside a workspace

View File

@@ -54,7 +54,7 @@ export default class CodeAdapter implements IPrompter {
return undefined; return undefined;
} }
vscode.window.showErrorMessage(err.message); void vscode.window.showErrorMessage(err.message);
}); });
} }
} }

View File

@@ -30,7 +30,7 @@ export class NotebookUriHandler implements vscode.UriHandler {
case '/open': case '/open':
return this.open(uri); return this.open(uri);
default: default:
vscode.window.showErrorMessage(localize('notebook.unsupportedAction', "Action {0} is not supported for this handler", uri.path)); void vscode.window.showErrorMessage(localize('notebook.unsupportedAction', "Action {0} is not supported for this handler", uri.path));
} }
} }
/** /**
@@ -84,7 +84,7 @@ export class NotebookUriHandler implements vscode.UriHandler {
case 'https': case 'https':
break; break;
default: default:
vscode.window.showErrorMessage(localize('unsupportedScheme', "Cannot open link {0} as only HTTP, HTTPS, and File links are supported", url)); void vscode.window.showErrorMessage(localize('unsupportedScheme', "Cannot open link {0} as only HTTP, HTTPS, and File links are supported", url));
return; return;
} }
let contents: string; let contents: string;
@@ -116,7 +116,7 @@ export class NotebookUriHandler implements vscode.UriHandler {
}); });
} }
} catch (err) { } catch (err) {
vscode.window.showErrorMessage(getErrorMessage(err)); void vscode.window.showErrorMessage(getErrorMessage(err));
} }
} }

View File

@@ -441,7 +441,7 @@ class TestComponentBuilder<T extends azdata.Component, TPropertyBag> implements
return this._component; return this._component;
} }
withProperties<U>(properties: U): azdata.ComponentBuilder<T, TPropertyBag> { withProperties<U>(properties: U): azdata.ComponentBuilder<T, TPropertyBag> {
this._component.updateProperties(properties); void this._component.updateProperties(properties);
return this; return this;
} }
withValidation(validation: (component: T) => boolean): azdata.ComponentBuilder<T, TPropertyBag> { withValidation(validation: (component: T) => boolean): azdata.ComponentBuilder<T, TPropertyBag> {
@@ -449,7 +449,7 @@ class TestComponentBuilder<T extends azdata.Component, TPropertyBag> implements
} }
withProps(properties: TPropertyBag): azdata.ComponentBuilder<T, TPropertyBag> { withProps(properties: TPropertyBag): azdata.ComponentBuilder<T, TPropertyBag> {
this._component.updateProperties(properties); void this._component.updateProperties(properties);
return this; return this;
} }
} }