Stricter tslint rules (#9352)

This commit is contained in:
Amir Omidi
2020-03-06 13:06:44 -08:00
committed by GitHub
parent f3a255a7f7
commit 20f7670b32
16 changed files with 44 additions and 32 deletions

View File

@@ -11,7 +11,7 @@
], ],
"rules": { "rules": {
"@typescript-eslint/no-floating-promises": [ "@typescript-eslint/no-floating-promises": [
"warn", "error",
{ {
"ignoreVoid": true "ignoreVoid": true
} }

View File

@@ -87,10 +87,11 @@ steps:
- script: | - script: |
set -e set -e
yarn sqllint
yarn gulp hygiene yarn gulp hygiene
yarn strict-vscode yarn strict-vscode
yarn valid-layers-check 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')) condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- script: | - script: |

View File

@@ -3,6 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * 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 { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
import { Emitter } from 'vs/base/common/event'; import { Emitter } from 'vs/base/common/event';
import { deepClone, assign } from 'vs/base/common/objects'; import { deepClone, assign } from 'vs/base/common/objects';

View File

@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import * as errors from 'vs/base/common/errors';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { SqlMainContext, ExtHostModelViewTreeViewsShape, MainThreadModelViewShape } from 'sql/workbench/api/common/sqlExtHost.protocol'; import { SqlMainContext, ExtHostModelViewTreeViewsShape, MainThreadModelViewShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { ITreeComponentItem } from 'sql/workbench/common/views'; import { ITreeComponentItem } from 'sql/workbench/common/views';
@@ -132,7 +133,7 @@ export class ExtHostTreeView<T> extends vsTreeExt.ExtHostTreeView<T> {
} else { } else {
const handlesToRefresh = this.getHandlesToRefresh(elements); const handlesToRefresh = this.getHandlesToRefresh(elements);
if (handlesToRefresh.length) { if (handlesToRefresh.length) {
this.refreshHandles(handlesToRefresh); this.refreshHandles(handlesToRefresh).catch(errors.onUnexpectedError);
} }
} }
} }

View File

@@ -83,7 +83,7 @@ export class ExtHostObjectExplorerNode implements azdata.objectexplorer.ObjectEx
let parentPathEndIndex: number = this.nodePath.lastIndexOf(nodePathName) - 1; let parentPathEndIndex: number = this.nodePath.lastIndexOf(nodePathName) - 1;
if (parentPathEndIndex < 0) { if (parentPathEndIndex < 0) {
// At root node // At root node
Promise.resolve(undefined); return Promise.resolve(undefined);
} }
return this._proxy.$getNode(this.connectionId, this.nodePath.slice(0, parentPathEndIndex)).then( return this._proxy.$getNode(this.connectionId, this.nodePath.slice(0, parentPathEndIndex)).then(
nodeInfo => nodeInfo ? new ExtHostObjectExplorerNode(nodeInfo, this.connectionId, this._proxy) : undefined); nodeInfo => nodeInfo ? new ExtHostObjectExplorerNode(nodeInfo, this.connectionId, this._proxy) : undefined);

View File

@@ -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.themeService.onThemeChange(() => this.doRefresh([this.root]) /** soft refresh **/));
this._register(this.configurationService.onDidChangeConfiguration(e => { this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('explorer.decorations')) { if (e.affectsConfiguration('explorer.decorations')) {
this.doRefresh([this.root]); /** soft refresh **/ this.doRefresh([this.root]).catch(onUnexpectedError); /** soft refresh **/
} }
})); }));
this.markdownRenderer = instantiationService.createInstance(MarkdownRenderer); this.markdownRenderer = instantiationService.createInstance(MarkdownRenderer);
@@ -272,7 +272,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
} }
}; };
this.updateMessage(); this.updateMessage();
this.refresh(); this.refresh().catch(onUnexpectedError);
} else { } else {
this._dataProvider = null; this._dataProvider = null;
this.updateMessage(); this.updateMessage();
@@ -361,7 +361,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
} }
if (this.isVisible && this.elementsToRefresh.length) { if (this.isVisible && this.elementsToRefresh.length) {
this.doRefresh(this.elementsToRefresh); this.doRefresh(this.elementsToRefresh).catch(onUnexpectedError);
this.elementsToRefresh = []; this.elementsToRefresh = [];
} }
} }

View File

@@ -19,6 +19,7 @@ import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/theme
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import * as themeColors from 'vs/workbench/common/theme'; import * as themeColors from 'vs/workbench/common/theme';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { onUnexpectedError } from 'vs/base/common/errors';
export const DASHBOARD_SELECTOR: string = 'dashboard-component'; 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))) { if (profile && (!profile.databaseName || Utils.isMaster(profile))) {
// Route to the server page as this is the default database // Route to the server page as this is the default database
this._router.navigate(['server-dashboard']); this._router.navigate(['server-dashboard']).catch(onUnexpectedError);
} }
} }

View File

@@ -20,6 +20,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { mssqlProviderName } from 'sql/platform/connection/common/constants'; import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { onUnexpectedError } from 'vs/base/common/errors';
export class ServerDashboardPage extends DashboardPage implements OnInit { export class ServerDashboardPage extends DashboardPage implements OnInit {
protected propertiesWidget: WidgetConfig = { protected propertiesWidget: WidgetConfig = {
@@ -68,6 +69,6 @@ export class ServerDashboardPage extends DashboardPage implements OnInit {
this.dashboardService.connectionManagementService.connectionInfo.connectionProfile.databaseName = null; this.dashboardService.connectionManagementService.connectionInfo.connectionProfile.databaseName = null;
this.init(); this.init();
this._cd.detectChanges(); this._cd.detectChanges();
}); }).catch(onUnexpectedError);
} }
} }

View File

@@ -26,6 +26,7 @@ import * as nls from 'vs/nls';
import { deepClone } from 'vs/base/common/objects'; import { deepClone } from 'vs/base/common/objects';
import { RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { onUnexpectedError } from 'vs/base/common/errors';
const DASHBOARD_SETTINGS = 'dashboard'; const DASHBOARD_SETTINGS = 'dashboard';
@@ -116,7 +117,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
if (this._router.url === '/database-dashboard') { if (this._router.url === '/database-dashboard') {
this._updatePage.fire(); this._updatePage.fire();
} else { } else {
this._router.navigate(['database-dashboard']); this._router.navigate(['database-dashboard']).catch(onUnexpectedError);
} }
} else { } else {
this._notificationService.notify({ this._notificationService.notify({
@@ -134,7 +135,7 @@ export class DashboardServiceInterface extends CommonServiceInterface {
); );
break; break;
case AngularEventType.NAV_SERVER: case AngularEventType.NAV_SERVER:
this._router.navigate(['server-dashboard']); this._router.navigate(['server-dashboard']).catch(onUnexpectedError);
break; break;
case AngularEventType.DELETE_WIDGET: case AngularEventType.DELETE_WIDGET:
this._onDeleteWidget.fire(event.payload.id); this._onDeleteWidget.fire(event.payload.id);

View File

@@ -24,6 +24,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext'; import { ItemContextKey } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/explorerTreeContext';
import { ObjectMetadataWrapper } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/objectMetadataWrapper'; import { ObjectMetadataWrapper } from 'sql/workbench/contrib/dashboard/browser/widgets/explorer/objectMetadataWrapper';
import { onUnexpectedError } from 'vs/base/common/errors';
export declare type TreeResource = IConnectionProfile | ObjectMetadataWrapper; export declare type TreeResource = IConnectionProfile | ObjectMetadataWrapper;
@@ -113,7 +114,7 @@ export class ExplorerController extends TreeDefaults.DefaultController {
private handleItemDoubleClick(element: IConnectionProfile): void { private handleItemDoubleClick(element: IConnectionProfile): void {
this.progressService.showWhile(this._connectionService.changeDatabase(element.databaseName).then(result => { 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(); const focus = tree.getFocus();
if (focus && !(focus instanceof ObjectMetadataWrapper)) { if (focus && !(focus instanceof ObjectMetadataWrapper)) {
this._connectionService.changeDatabase(focus.databaseName).then(result => { this._connectionService.changeDatabase(focus.databaseName).then(result => {
this._router.navigate(['database-dashboard']); this._router.navigate(['database-dashboard']).catch(onUnexpectedError);
}); });
} }
} }

View File

@@ -36,6 +36,7 @@ import { EditDataResultsInput } from 'sql/workbench/browser/editData/editDataRes
import { CancellationToken } from 'vs/base/common/cancellation'; import { CancellationToken } from 'vs/base/common/cancellation';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService } from 'vs/platform/storage/common/storage';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; 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 * 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._createResultsEditorContainer();
this._createEditor(<EditDataResultsInput>input.results, this._resultsEditorContainer) this._createEditor(<EditDataResultsInput>input.results, this._resultsEditorContainer)
.then(result => { .then(async result => {
this._onResultsEditorCreated(<EditDataResultsEditor>result, input.results, this.options); await this._onResultsEditorCreated(<EditDataResultsEditor>result, input.results, this.options);
this.resultsEditorVisibility = true; this.resultsEditorVisibility = true;
this.hideQueryResultsView = false; this.hideQueryResultsView = false;
this._doLayout(true); this._doLayout(true);
}); }).catch(onUnexpectedError);
} }
/** /**

View File

@@ -34,6 +34,7 @@ import { deepClone, assign } from 'vs/base/common/objects';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
import { equals } from 'vs/base/common/arrays'; import { equals } from 'vs/base/common/arrays';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { onUnexpectedError } from 'vs/base/common/errors';
export class EditDataGridPanel extends GridParentComponent { export class EditDataGridPanel extends GridParentComponent {
// The time(in milliseconds) we wait before refreshing the grid. // The time(in milliseconds) we wait before refreshing the grid.
@@ -251,7 +252,7 @@ export class EditDataGridPanel extends GridParentComponent {
return (index: number): void => { return (index: number): void => {
// If the user is deleting a new row that hasn't been committed yet then use the revert code // 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) { if (self.newRowVisible && index === self.dataSet.dataRows.getLength() - 2) {
self.revertCurrentRow(); self.revertCurrentRow().catch(onUnexpectedError);
} }
else if (self.isNullRow(index)) { else if (self.isNullRow(index)) {
// Don't try to delete NULL (new) row since it doesn't actually exist and will throw an error // 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 { onRevertRow(): () => void {
const self = this; const self = this;
return (): void => { return (): void => {
self.revertCurrentRow(); self.revertCurrentRow().catch(onUnexpectedError);
}; };
} }
@@ -478,7 +479,7 @@ export class EditDataGridPanel extends GridParentComponent {
let handled: boolean = false; let handled: boolean = false;
if (e.keyCode === KeyCode.Escape) { if (e.keyCode === KeyCode.Escape) {
this.revertCurrentRow(); this.revertCurrentRow().catch(onUnexpectedError);
handled = true; handled = true;
} }
return handled; return handled;
@@ -714,7 +715,7 @@ export class EditDataGridPanel extends GridParentComponent {
self.setCellDirtyState(self.currentCell.row, self.currentCell.column, result.cell.isDirty); self.setCellDirtyState(self.currentCell.row, self.currentCell.column, result.cell.isDirty);
}, (error: any) => { }, (error: any) => {
self.notificationService.error(error); self.notificationService.error(error);
}); }).catch(onUnexpectedError);
} }
} }
} }

View File

@@ -33,6 +33,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { attachButtonStyler } from 'sql/platform/theme/common/styler'; import { attachButtonStyler } from 'sql/platform/theme/common/styler';
import { find, fill } from 'vs/base/common/arrays'; import { find, fill } from 'vs/base/common/arrays';
import { onUnexpectedError } from 'vs/base/common/errors';
export const JOBSVIEW_SELECTOR: string = 'jobsview-component'; export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
export const ROW_HEIGHT: number = 45; export const ROW_HEIGHT: number = 45;
@@ -389,7 +390,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
// cache the dataview for future use // cache the dataview for future use
this._jobCacheObject.dataView = this.dataView; this._jobCacheObject.dataView = this.dataView;
this.filterValueMap['start'] = [[], this.dataView.getItems()]; this.filterValueMap['start'] = [[], this.dataView.getItems()];
this.loadJobHistories(); this.loadJobHistories().catch(onUnexpectedError);
} }
private highlightErrorRows(e) { private highlightErrorRows(e) {
@@ -541,7 +542,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
// so they can be expanded quicker // so they can be expanded quicker
let failing = separatedJobs[0]; let failing = separatedJobs[0];
let passing = separatedJobs[1]; 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)]);
} }
} }

View File

@@ -19,6 +19,7 @@ import { generateUuid } from 'vs/base/common/uuid';
import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase'; import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase';
import { ComponentEventType, IModelStore, IComponentDescriptor, IComponent } from 'sql/platform/dashboard/browser/interfaces'; 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 { function reviveWebviewOptions(options: vscode.WebviewOptions): vscode.WebviewOptions {
return { return {
@@ -95,7 +96,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
})); }));
this.setHtml(); this.setHtml();
}); }).catch(onUnexpectedError);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@@ -141,7 +142,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
this._ready.then(() => { this._ready.then(() => {
let element = <HTMLElement>this._el.nativeElement; let element = <HTMLElement>this._el.nativeElement;
element.style.position = this.position; 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._extensionLocationUri = URI.revive(this.extensionLocation);
} }
this.sendMessage(); this.sendMessage();
}); }).catch(onUnexpectedError);
} }
} }

View File

@@ -69,9 +69,9 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler); this._treeSelectionHandler = this._instantiationService.createInstance(TreeSelectionHandler);
this._onSelectionOrFocusChange = new Emitter(); this._onSelectionOrFocusChange = new Emitter();
this._actionProvider = this._instantiationService.createInstance(ServerTreeActionProvider); this._actionProvider = this._instantiationService.createInstance(ServerTreeActionProvider);
capabilitiesService.onCapabilitiesRegistered(() => { capabilitiesService.onCapabilitiesRegistered(async () => {
if (this._connectionManagementService.hasRegisteredServers()) { if (this._connectionManagementService.hasRegisteredServers()) {
this.refreshTree(); await this.refreshTree();
this._treeSelectionHandler.onTreeActionStateChange(false); this._treeSelectionHandler.onTreeActionStateChange(false);
} }
}); });
@@ -114,7 +114,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
CommandsRegistry.registerCommand({ CommandsRegistry.registerCommand({
id: 'registeredServers.clearSearchServerResult', id: 'registeredServers.clearSearchServerResult',
handler: (accessor: ServicesAccessor, ...args: any[]) => { 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 // Refresh Tree when these events are emitted
this._register(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => { this._register(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => {
this.handleAddConnectionProfile(newProfile); this.handleAddConnectionProfile(newProfile).catch(errors.onUnexpectedError);
})); }));
this._register(this._connectionManagementService.onDeleteConnectionProfile(() => { this._register(this._connectionManagementService.onDeleteConnectionProfile(() => {
this.refreshTree(); this.refreshTree().catch(errors.onUnexpectedError);
})); }));
this._register(this._connectionManagementService.onDisconnect((connectionParams) => { this._register(this._connectionManagementService.onDisconnect((connectionParams) => {
if (this.isObjectExplorerConnectionUri(connectionParams.connectionUri)) { if (this.isObjectExplorerConnectionUri(connectionParams.connectionUri)) {
this.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile); this.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile).catch(errors.onUnexpectedError);
} }
})); }));

View File

@@ -305,7 +305,7 @@ export class ObjectExplorerService implements IObjectExplorerService {
this._connectionManagementService.disconnect(connection).then(() => { this._connectionManagementService.disconnect(connection).then(() => {
connection.isDisconnecting = false; connection.isDisconnecting = false;
}).catch((e) => this.logService.error(e)); }).catch((e) => this.logService.error(e));
}); }).catch((e) => this.logService.error(e));
} }
} }
} else { } else {