From edca51be10c4c370dd7562ba72caf34d5b345228 Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Tue, 19 Nov 2019 12:06:54 +0100 Subject: [PATCH] refactor: adjust code to new TSLint rules --- src/api.ts | 190 +++++++++++++++++++++++++-------------------------- src/cli.ts | 23 ++++--- src/types.ts | 8 ++- 3 files changed, 113 insertions(+), 108 deletions(-) diff --git a/src/api.ts b/src/api.ts index 67f21ca4..a8f31357 100644 --- a/src/api.ts +++ b/src/api.ts @@ -34,17 +34,12 @@ import { TreeFile, } from './types'; -/** - * Instance of logger - */ -export const logger = new Logger(); - /** * Sleep for a number of milliseconds * * @param ms Number of milliseconds to wait */ -export function sleep(ms: number) { +export async function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } @@ -55,7 +50,7 @@ export interface ApiRequestOptions { /** * Data to be sent with the request */ - data?: any; + data?: object | null; /** * HTTP verb to use for the request @@ -124,10 +119,10 @@ export class Api { * @param userId ID of the user * @param accessLevel Access level for the new member in the scope */ - public addMember(scope: MembershipScope, - id: number, - userId: number, - accessLevel: AccessLevel): Promise { + public async addMember(scope: MembershipScope, + id: number, + userId: number, + accessLevel: AccessLevel): Promise { return this.makeGitLabAPIRequest( `${scope}/${id}/members`, { @@ -137,7 +132,7 @@ export class Api { }, method: 'POST', }, - ); + ) as Promise; } /** @@ -147,7 +142,7 @@ export class Api { * @param title Title of the issue * @param description Description of the issue (can contain slash commands) */ - public createIssue(projectId: number, title: string, description: string): Promise { + public async createIssue(projectId: number, title: string, description: string): Promise { return this.makeGitLabAPIRequest( `projects/${projectId}/issues`, { @@ -157,7 +152,7 @@ export class Api { }, method: 'POST', }, - ); + ) as Promise; } /** @@ -168,22 +163,23 @@ export class Api { * @param description Description of the label to create * @param color Color of the label to create */ - public createLabel(projectId: number, name: string, description?: string, color?: string): Promise