Fix all await-promise tslint errors (#7530)

* Fix all await-promise tslint errors

* Remove unnecessary await
This commit is contained in:
Charles Gagnon
2019-10-07 17:52:01 -07:00
committed by GitHub
parent 749ddc30c7
commit e4e71af597
7 changed files with 12 additions and 11 deletions

View File

@@ -477,7 +477,7 @@ suite('ConnectionStore', () => {
for (let i = 0; i < 5; i++) {
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
await connectionStore.removeRecentConnection(connectionProfile);
connectionStore.removeRecentConnection(connectionProfile);
const current = connectionStore.getRecentlyUsedConnections();
assert.equal(current.length, 4 - i);
}

View File

@@ -134,7 +134,7 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution,
// we want to connect the given profile to to it.
// If more than one file was passed, only show the connection dialog error on one of them.
if (args._ && args._.length > 0) {
await args._.forEach((f, i) => this.processFile(URI.file(f).toString(), profile, i === 0));
await Promise.all(args._.map((f, i) => this.processFile(URI.file(f).toString(), profile, i === 0)));
}
else {
// Default to showing new query

View File

@@ -329,7 +329,7 @@ export class CellModel implements ICellModel {
if ((Array.isArray(content) && content.length > 0) || (!Array.isArray(content) && content)) {
// requestExecute expects a string for the code parameter
content = Array.isArray(content) ? content.join('') : content;
let future = await kernel.requestExecute({
const future = kernel.requestExecute({
code: content,
stop_on_error: true
}, false);

View File

@@ -49,7 +49,7 @@ export class NotebookContexts {
* @param kernelChangedArgs kernel changed args (both old and new kernel info)
* @param profile current connection profile
*/
public static async getContextsForKernel(connectionService: IConnectionManagementService, connProviderIds: string[], kernelChangedArgs?: nb.IKernelChangedArgs, profile?: IConnectionProfile): Promise<IDefaultConnection> {
public static getContextsForKernel(connectionService: IConnectionManagementService, connProviderIds: string[], kernelChangedArgs?: nb.IKernelChangedArgs, profile?: IConnectionProfile): IDefaultConnection {
let connections: IDefaultConnection = this.DefaultContext;
if (!profile) {
if (!kernelChangedArgs || !kernelChangedArgs.newValue ||
@@ -61,7 +61,7 @@ export class NotebookContexts {
if (kernelChangedArgs && kernelChangedArgs.newValue && kernelChangedArgs.newValue.name && connProviderIds.length < 1) {
return connections;
} else {
connections = await this.getActiveContexts(connectionService, connProviderIds, profile);
connections = this.getActiveContexts(connectionService, connProviderIds, profile);
}
return connections;
}
@@ -71,9 +71,9 @@ export class NotebookContexts {
* @param apiWrapper ApiWrapper
* @param profile current connection profile
*/
public static async getActiveContexts(connectionService: IConnectionManagementService, connProviderIds: string[], profile: IConnectionProfile): Promise<IDefaultConnection> {
public static getActiveContexts(connectionService: IConnectionManagementService, connProviderIds: string[], profile: IConnectionProfile): IDefaultConnection {
let defaultConnection: ConnectionProfile = NotebookContexts.DefaultContext.defaultConnection;
let activeConnections: ConnectionProfile[] = await connectionService.getActiveConnections();
let activeConnections: ConnectionProfile[] = connectionService.getActiveConnections();
if (activeConnections && activeConnections.length > 0) {
activeConnections = activeConnections.filter(conn => conn.id !== '-1');
}

View File

@@ -840,7 +840,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
private async loadActiveContexts(kernelChangedArgs: nb.IKernelChangedArgs): Promise<void> {
if (kernelChangedArgs && kernelChangedArgs.newValue && kernelChangedArgs.newValue.name) {
let kernelDisplayName = this.getDisplayNameFromSpecName(kernelChangedArgs.newValue);
this._activeContexts = await NotebookContexts.getContextsForKernel(this._notebookOptions.connectionService, this.getApplicableConnectionProviderIds(kernelDisplayName), kernelChangedArgs, this.connectionProfile);
this._activeContexts = NotebookContexts.getContextsForKernel(this._notebookOptions.connectionService, this.getApplicableConnectionProviderIds(kernelDisplayName), kernelChangedArgs, this.connectionProfile);
this._contextsChangedEmitter.fire();
if (this.contexts.defaultConnection !== undefined && this.contexts.defaultConnection.serverName !== undefined && this.contexts.defaultConnection.title !== undefined) {
await this.changeContext(this.contexts.defaultConnection.title, this.contexts.defaultConnection);

View File

@@ -455,7 +455,7 @@ export class NotebookService extends Disposable implements INotebookService {
if (!providerDescriptor.instance) {
// Await extension registration before awaiting provider registration
try {
await this._extensionService.whenInstalledExtensionsRegistered;
await this._extensionService.whenInstalledExtensionsRegistered();
} catch (error) {
console.error(error);
}

View File

@@ -17,9 +17,10 @@
"severity": "warn"
},
"await-promise": {
"severity": "warn",
"options": [
"Thenable"
"Thenable",
"Deferred",
"PromiseLike"
]
},
"use-isnan": {