diff --git a/.eslintrc.sql.ts.json b/.eslintrc.sql.ts.json index 13fe9c4661..fad61cb7ec 100644 --- a/.eslintrc.sql.ts.json +++ b/.eslintrc.sql.ts.json @@ -11,7 +11,7 @@ ], "rules": { "@typescript-eslint/no-floating-promises": [ - "warn", + "error", { "ignoreVoid": true } diff --git a/build/azure-pipelines/sql-product-compile.yml b/build/azure-pipelines/sql-product-compile.yml index 9a2d73f91a..d5b2bb7840 100644 --- a/build/azure-pipelines/sql-product-compile.yml +++ b/build/azure-pipelines/sql-product-compile.yml @@ -87,10 +87,11 @@ steps: - script: | set -e + yarn sqllint yarn gulp hygiene yarn strict-vscode yarn valid-layers-check - displayName: Run hygiene, tslint + displayName: Run hygiene, eslint condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) - script: | diff --git a/src/sql/workbench/api/common/extHostModelView.ts b/src/sql/workbench/api/common/extHostModelView.ts index 31d1bb085c..32c3f7bb04 100644 --- a/src/sql/workbench/api/common/extHostModelView.ts +++ b/src/sql/workbench/api/common/extHostModelView.ts @@ -3,6 +3,8 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +/* eslint-disable @typescript-eslint/no-floating-promises */ + import { IMainContext } from 'vs/workbench/api/common/extHost.protocol'; import { Emitter } from 'vs/base/common/event'; import { deepClone, assign } from 'vs/base/common/objects'; diff --git a/src/sql/workbench/api/common/extHostModelViewTree.ts b/src/sql/workbench/api/common/extHostModelViewTree.ts index 464d9319d7..cd7135ad6b 100644 --- a/src/sql/workbench/api/common/extHostModelViewTree.ts +++ b/src/sql/workbench/api/common/extHostModelViewTree.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { localize } from 'vs/nls'; +import * as errors from 'vs/base/common/errors'; import * as vscode from 'vscode'; import { SqlMainContext, ExtHostModelViewTreeViewsShape, MainThreadModelViewShape } from 'sql/workbench/api/common/sqlExtHost.protocol'; import { ITreeComponentItem } from 'sql/workbench/common/views'; @@ -132,7 +133,7 @@ export class ExtHostTreeView extends vsTreeExt.ExtHostTreeView { } else { const handlesToRefresh = this.getHandlesToRefresh(elements); if (handlesToRefresh.length) { - this.refreshHandles(handlesToRefresh); + this.refreshHandles(handlesToRefresh).catch(errors.onUnexpectedError); } } } diff --git a/src/sql/workbench/api/common/extHostObjectExplorer.ts b/src/sql/workbench/api/common/extHostObjectExplorer.ts index 1816d6eb61..3413a48179 100644 --- a/src/sql/workbench/api/common/extHostObjectExplorer.ts +++ b/src/sql/workbench/api/common/extHostObjectExplorer.ts @@ -83,7 +83,7 @@ export class ExtHostObjectExplorerNode implements azdata.objectexplorer.ObjectEx let parentPathEndIndex: number = this.nodePath.lastIndexOf(nodePathName) - 1; if (parentPathEndIndex < 0) { // At root node - Promise.resolve(undefined); + return Promise.resolve(undefined); } return this._proxy.$getNode(this.connectionId, this.nodePath.slice(0, parentPathEndIndex)).then( nodeInfo => nodeInfo ? new ExtHostObjectExplorerNode(nodeInfo, this.connectionId, this._proxy) : undefined); diff --git a/src/sql/workbench/browser/parts/views/customView.ts b/src/sql/workbench/browser/parts/views/customView.ts index a28851d9e9..2cd09acce8 100644 --- a/src/sql/workbench/browser/parts/views/customView.ts +++ b/src/sql/workbench/browser/parts/views/customView.ts @@ -235,7 +235,7 @@ export class CustomTreeView extends Disposable implements ITreeView { this._register(this.themeService.onThemeChange(() => this.doRefresh([this.root]) /** soft refresh **/)); this._register(this.configurationService.onDidChangeConfiguration(e => { if (e.affectsConfiguration('explorer.decorations')) { - this.doRefresh([this.root]); /** soft refresh **/ + this.doRefresh([this.root]).catch(onUnexpectedError); /** soft refresh **/ } })); this.markdownRenderer = instantiationService.createInstance(MarkdownRenderer); @@ -272,7 +272,7 @@ export class CustomTreeView extends Disposable implements ITreeView { } }; this.updateMessage(); - this.refresh(); + this.refresh().catch(onUnexpectedError); } else { this._dataProvider = null; this.updateMessage(); @@ -361,7 +361,7 @@ export class CustomTreeView extends Disposable implements ITreeView { } if (this.isVisible && this.elementsToRefresh.length) { - this.doRefresh(this.elementsToRefresh); + this.doRefresh(this.elementsToRefresh).catch(onUnexpectedError); this.elementsToRefresh = []; } } diff --git a/src/sql/workbench/contrib/dashboard/browser/dashboard.component.ts b/src/sql/workbench/contrib/dashboard/browser/dashboard.component.ts index 186a48f8c7..84684df61e 100644 --- a/src/sql/workbench/contrib/dashboard/browser/dashboard.component.ts +++ b/src/sql/workbench/contrib/dashboard/browser/dashboard.component.ts @@ -19,6 +19,7 @@ import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/theme import { IDisposable } from 'vs/base/common/lifecycle'; import * as themeColors from 'vs/workbench/common/theme'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; +import { onUnexpectedError } from 'vs/base/common/errors'; export const DASHBOARD_SELECTOR: string = 'dashboard-component'; @@ -59,7 +60,7 @@ export class DashboardComponent extends AngularDisposable implements OnInit { }); if (profile && (!profile.databaseName || Utils.isMaster(profile))) { // Route to the server page as this is the default database - this._router.navigate(['server-dashboard']); + this._router.navigate(['server-dashboard']).catch(onUnexpectedError); } } diff --git a/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts b/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts index 7d61e1d71f..16452e30d8 100644 --- a/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts +++ b/src/sql/workbench/contrib/dashboard/browser/pages/serverDashboardPage.component.ts @@ -20,6 +20,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ILogService } from 'vs/platform/log/common/log'; import { mssqlProviderName } from 'sql/platform/connection/common/constants'; +import { onUnexpectedError } from 'vs/base/common/errors'; export class ServerDashboardPage extends DashboardPage implements OnInit { protected propertiesWidget: WidgetConfig = { @@ -68,6 +69,6 @@ export class ServerDashboardPage extends DashboardPage implements OnInit { this.dashboardService.connectionManagementService.connectionInfo.connectionProfile.databaseName = null; this.init(); this._cd.detectChanges(); - }); + }).catch(onUnexpectedError); } } diff --git a/src/sql/workbench/contrib/dashboard/browser/services/dashboardServiceInterface.service.ts b/src/sql/workbench/contrib/dashboard/browser/services/dashboardServiceInterface.service.ts index ea16c442d9..de2522d30b 100644 --- a/src/sql/workbench/contrib/dashboard/browser/services/dashboardServiceInterface.service.ts +++ b/src/sql/workbench/contrib/dashboard/browser/services/dashboardServiceInterface.service.ts @@ -26,6 +26,7 @@ import * as nls from 'vs/nls'; import { deepClone } from 'vs/base/common/objects'; import { RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { INotificationService } from 'vs/platform/notification/common/notification'; +import { onUnexpectedError } from 'vs/base/common/errors'; const DASHBOARD_SETTINGS = 'dashboard'; @@ -116,7 +117,7 @@ export class DashboardServiceInterface extends CommonServiceInterface { if (this._router.url === '/database-dashboard') { this._updatePage.fire(); } else { - this._router.navigate(['database-dashboard']); + this._router.navigate(['database-dashboard']).catch(onUnexpectedError); } } else { this._notificationService.notify({ @@ -134,7 +135,7 @@ export class DashboardServiceInterface extends CommonServiceInterface { ); break; case AngularEventType.NAV_SERVER: - this._router.navigate(['server-dashboard']); + this._router.navigate(['server-dashboard']).catch(onUnexpectedError); break; case AngularEventType.DELETE_WIDGET: this._onDeleteWidget.fire(event.payload.id); diff --git a/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTree.ts b/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTree.ts index 4236e8dbb6..babc9a48a8 100644 --- a/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTree.ts +++ b/src/sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTree.ts @@ -24,6 +24,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext'; import { ObjectMetadataWrapper } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/objectMetadataWrapper'; +import { onUnexpectedError } from 'vs/base/common/errors'; export declare type TreeResource = IConnectionProfile | ObjectMetadataWrapper; @@ -113,7 +114,7 @@ export class ExplorerController extends TreeDefaults.DefaultController { private handleItemDoubleClick(element: IConnectionProfile): void { this.progressService.showWhile(this._connectionService.changeDatabase(element.databaseName).then(result => { - this._router.navigate(['database-dashboard']); + this._router.navigate(['database-dashboard']).catch(onUnexpectedError); })); } @@ -123,7 +124,7 @@ export class ExplorerController extends TreeDefaults.DefaultController { const focus = tree.getFocus(); if (focus && !(focus instanceof ObjectMetadataWrapper)) { this._connectionService.changeDatabase(focus.databaseName).then(result => { - this._router.navigate(['database-dashboard']); + this._router.navigate(['database-dashboard']).catch(onUnexpectedError); }); } } diff --git a/src/sql/workbench/contrib/editData/browser/editDataEditor.ts b/src/sql/workbench/contrib/editData/browser/editDataEditor.ts index 9031ffc8c4..226905718f 100644 --- a/src/sql/workbench/contrib/editData/browser/editDataEditor.ts +++ b/src/sql/workbench/contrib/editData/browser/editDataEditor.ts @@ -36,6 +36,7 @@ import { EditDataResultsInput } from 'sql/workbench/browser/editData/editDataRes import { CancellationToken } from 'vs/base/common/cancellation'; import { IStorageService } from 'vs/platform/storage/common/storage'; import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; +import { onUnexpectedError } from 'vs/base/common/errors'; /** * Editor that hosts an action bar and a resultSetInput for an edit data session @@ -581,12 +582,12 @@ export class EditDataEditor extends BaseEditor { this._createResultsEditorContainer(); this._createEditor(input.results, this._resultsEditorContainer) - .then(result => { - this._onResultsEditorCreated(result, input.results, this.options); + .then(async result => { + await this._onResultsEditorCreated(result, input.results, this.options); this.resultsEditorVisibility = true; this.hideQueryResultsView = false; this._doLayout(true); - }); + }).catch(onUnexpectedError); } /** diff --git a/src/sql/workbench/contrib/editData/browser/editDataGridPanel.ts b/src/sql/workbench/contrib/editData/browser/editDataGridPanel.ts index 4b9681e4f8..6b9beefb21 100644 --- a/src/sql/workbench/contrib/editData/browser/editDataGridPanel.ts +++ b/src/sql/workbench/contrib/editData/browser/editDataGridPanel.ts @@ -34,6 +34,7 @@ import { deepClone, assign } from 'vs/base/common/objects'; import { Event } from 'vs/base/common/event'; import { equals } from 'vs/base/common/arrays'; import * as DOM from 'vs/base/browser/dom'; +import { onUnexpectedError } from 'vs/base/common/errors'; export class EditDataGridPanel extends GridParentComponent { // The time(in milliseconds) we wait before refreshing the grid. @@ -251,7 +252,7 @@ export class EditDataGridPanel extends GridParentComponent { return (index: number): void => { // If the user is deleting a new row that hasn't been committed yet then use the revert code if (self.newRowVisible && index === self.dataSet.dataRows.getLength() - 2) { - self.revertCurrentRow(); + self.revertCurrentRow().catch(onUnexpectedError); } else if (self.isNullRow(index)) { // Don't try to delete NULL (new) row since it doesn't actually exist and will throw an error @@ -270,7 +271,7 @@ export class EditDataGridPanel extends GridParentComponent { onRevertRow(): () => void { const self = this; return (): void => { - self.revertCurrentRow(); + self.revertCurrentRow().catch(onUnexpectedError); }; } @@ -478,7 +479,7 @@ export class EditDataGridPanel extends GridParentComponent { let handled: boolean = false; if (e.keyCode === KeyCode.Escape) { - this.revertCurrentRow(); + this.revertCurrentRow().catch(onUnexpectedError); handled = true; } return handled; @@ -714,7 +715,7 @@ export class EditDataGridPanel extends GridParentComponent { self.setCellDirtyState(self.currentCell.row, self.currentCell.column, result.cell.isDirty); }, (error: any) => { self.notificationService.error(error); - }); + }).catch(onUnexpectedError); } } } diff --git a/src/sql/workbench/contrib/jobManagement/browser/jobsView.component.ts b/src/sql/workbench/contrib/jobManagement/browser/jobsView.component.ts index 1cb52d2080..43b00b8936 100644 --- a/src/sql/workbench/contrib/jobManagement/browser/jobsView.component.ts +++ b/src/sql/workbench/contrib/jobManagement/browser/jobsView.component.ts @@ -33,6 +33,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import { attachButtonStyler } from 'sql/platform/theme/common/styler'; import { find, fill } from 'vs/base/common/arrays'; +import { onUnexpectedError } from 'vs/base/common/errors'; export const JOBSVIEW_SELECTOR: string = 'jobsview-component'; export const ROW_HEIGHT: number = 45; @@ -389,7 +390,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe // cache the dataview for future use this._jobCacheObject.dataView = this.dataView; this.filterValueMap['start'] = [[], this.dataView.getItems()]; - this.loadJobHistories(); + this.loadJobHistories().catch(onUnexpectedError); } private highlightErrorRows(e) { @@ -541,7 +542,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe // so they can be expanded quicker let failing = separatedJobs[0]; let passing = separatedJobs[1]; - Promise.all([this.curateJobHistory(failing, ownerUri), this.curateJobHistory(passing, ownerUri)]); + await Promise.all([this.curateJobHistory(failing, ownerUri), this.curateJobHistory(passing, ownerUri)]); } } diff --git a/src/sql/workbench/contrib/modelView/browser/webview.component.ts b/src/sql/workbench/contrib/modelView/browser/webview.component.ts index fc5bbdb993..aa58385845 100644 --- a/src/sql/workbench/contrib/modelView/browser/webview.component.ts +++ b/src/sql/workbench/contrib/modelView/browser/webview.component.ts @@ -19,6 +19,7 @@ import { generateUuid } from 'vs/base/common/uuid'; import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase'; import { ComponentEventType, IModelStore, IComponentDescriptor, IComponent } from 'sql/platform/dashboard/browser/interfaces'; +import { onUnexpectedError } from 'vs/base/common/errors'; function reviveWebviewOptions(options: vscode.WebviewOptions): vscode.WebviewOptions { return { @@ -95,7 +96,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen })); this.setHtml(); - }); + }).catch(onUnexpectedError); } ngOnDestroy(): void { @@ -141,7 +142,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen this._ready.then(() => { let element = this._el.nativeElement; element.style.position = this.position; - }); + }).catch(onUnexpectedError); } } @@ -164,7 +165,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen this._extensionLocationUri = URI.revive(this.extensionLocation); } this.sendMessage(); - }); + }).catch(onUnexpectedError); } } diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index a8a3dc7050..bb750a484d 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -69,9 +69,9 @@ export class ServerTreeView extends Disposable implements IServerTreeView { this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler); this._onSelectionOrFocusChange = new Emitter(); this._actionProvider = this._instantiationService.createInstance(ServerTreeActionProvider); - capabilitiesService.onCapabilitiesRegistered(() => { + capabilitiesService.onCapabilitiesRegistered(async () => { if (this._connectionManagementService.hasRegisteredServers()) { - this.refreshTree(); + await this.refreshTree(); this._treeSelectionHandler.onTreeActionStateChange(false); } }); @@ -114,7 +114,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView { CommandsRegistry.registerCommand({ id: 'registeredServers.clearSearchServerResult', handler: (accessor: ServicesAccessor, ...args: any[]) => { - this.refreshTree(); + this.refreshTree().catch(errors.onUnexpectedError); } }); } @@ -151,14 +151,14 @@ export class ServerTreeView extends Disposable implements IServerTreeView { // Refresh Tree when these events are emitted this._register(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => { - this.handleAddConnectionProfile(newProfile); + this.handleAddConnectionProfile(newProfile).catch(errors.onUnexpectedError); })); this._register(this._connectionManagementService.onDeleteConnectionProfile(() => { - this.refreshTree(); + this.refreshTree().catch(errors.onUnexpectedError); })); this._register(this._connectionManagementService.onDisconnect((connectionParams) => { if (this.isObjectExplorerConnectionUri(connectionParams.connectionUri)) { - this.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile); + this.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile).catch(errors.onUnexpectedError); } })); diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts index d91ecc36e2..df11c993a9 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerService.ts @@ -305,7 +305,7 @@ export class ObjectExplorerService implements IObjectExplorerService { this._connectionManagementService.disconnect(connection).then(() => { connection.isDisconnecting = false; }).catch((e) => this.logService.error(e)); - }); + }).catch((e) => this.logService.error(e)); } } } else {