From ec4e705d45e67186d81e4d9dc73a5397c5f64450 Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Sun, 22 Dec 2024 21:55:46 -0800 Subject: [PATCH] Fixed linting https://github.com/caprover/caprover-cli/pull/150 --- src/api/ApiManager.ts | 6 +++--- src/api/CliApiManager.ts | 2 +- src/api/HttpClient.ts | 30 +++++++++++++++--------------- src/utils/DeployHelper.ts | 2 +- src/utils/ErrorFactory.ts | 2 +- src/utils/Utils.ts | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/api/ApiManager.ts b/src/api/ApiManager.ts index 103b2c9..5bc655b 100644 --- a/src/api/ApiManager.ts +++ b/src/api/ApiManager.ts @@ -30,7 +30,7 @@ export default class ApiManager { baseUrl, appToken, ApiManager.authToken, - function () { + function() { return self.getAuthToken(ApiManager.lastKnownPassword) } ) @@ -72,13 +72,13 @@ export default class ApiManager { otpToken: process.env.CAPROVER_OTP_TOKEN }) ) - .then(function (data) { + .then(function(data) { authTokenFetched = data.token self.setAuthToken(authTokenFetched) return authTokenFetched }) .then(self.authTokenSaver) - .then(function () { + .then(function() { return authTokenFetched }) } diff --git a/src/api/CliApiManager.ts b/src/api/CliApiManager.ts index 952e2d4..2042ad6 100644 --- a/src/api/CliApiManager.ts +++ b/src/api/CliApiManager.ts @@ -28,7 +28,7 @@ export default class CliApiManager { CliApiManager.instances[hashKey] = new ApiManager( capMachine.baseUrl + Constants.BASE_API_PATH, capMachine.appToken, - function (token) { + function(token) { capMachine.authToken = token if (capMachine.name) { StorageHelper.get().saveMachine(capMachine) diff --git a/src/api/HttpClient.ts b/src/api/HttpClient.ts index e4e960b..3923a16 100644 --- a/src/api/HttpClient.ts +++ b/src/api/HttpClient.ts @@ -52,29 +52,29 @@ export default class HttpClient { variables: any ) { const self = this - return function (): Promise { + return function(): Promise { return Promise.resolve() // - .then(function () { + .then(function() { if (!process.env.REACT_APP_IS_DEBUG) { return Promise.resolve() } - return new Promise(function (res) { + return new Promise(function(res) { setTimeout(res, 500) }) }) - .then(function () { + .then(function() { return self.fetchInternal(method, endpoint, variables) // }) - .then(function (data) { + .then(function(data) { if ( data.status === ErrorFactory.STATUS_AUTH_TOKEN_INVALID ) { return self .onAuthFailure() // - .then(function () { + .then(function() { return self .fetchInternal(method, endpoint, variables) - .then(function (newRequestResponse) { + .then(function(newRequestResponse) { return newRequestResponse }) }) @@ -82,7 +82,7 @@ export default class HttpClient { return data } }) - .then(function (data) { + .then(function(data) { if ( data.status !== ErrorFactory.OKAY && data.status !== ErrorFactory.OKAY_BUILD_STARTED @@ -94,14 +94,14 @@ export default class HttpClient { } return data }) - .then(function (data) { + .then(function(data) { // tslint:disable-next-line: max-line-length // These two blocks are clearly memory leaks! But I don't have time to fix them now... I need to CANCEL the promise, but since I don't // have CANCEL method on the native Promise, I return a promise that will never RETURN if the HttpClient is destroyed. // tslint:disable-next-line: max-line-length // Will fix them later... but it shouldn't be a big deal anyways as it's only a problem when user navigates away from a page before the // network request returns back. - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { // data.data here is the "data" field inside the API response! {status: 100, description: "Login succeeded", data: {…}} if (!self.isDestroyed) { return resolve(data.data) @@ -109,10 +109,10 @@ export default class HttpClient { Logger.dev('Destroyed then not called') }) }) - .catch(function (error) { + .catch(function(error) { // Logger.log(''); // Logger.error(error.message || error); - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { if (!self.isDestroyed) { return reject(error) } @@ -145,7 +145,7 @@ export default class HttpClient { headers: self.createHeaders(), qs: variables, json: true - }).then(function (data) { + }).then(function(data) { return data }) } @@ -162,7 +162,7 @@ export default class HttpClient { headers: self.createHeaders(), formData: variables, json: true - }).then(function (data) { + }).then(function(data) { return data }) } @@ -171,7 +171,7 @@ export default class HttpClient { headers: self.createHeaders(), body: variables, json: true - }).then(function (data) { + }).then(function(data) { return data }) } diff --git a/src/utils/DeployHelper.ts b/src/utils/DeployHelper.ts index 5ca985f..edd9102 100644 --- a/src/utils/DeployHelper.ts +++ b/src/utils/DeployHelper.ts @@ -103,7 +103,7 @@ export default class DeployHelper { } private gitArchiveFile(zipFileFullPath: string, branchToPush: string) { - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { if (fs.pathExistsSync(zipFileFullPath)) { fs.removeSync(zipFileFullPath) } // Removes the temporary file created diff --git a/src/utils/ErrorFactory.ts b/src/utils/ErrorFactory.ts index 38aa3ac..6ddd3c3 100644 --- a/src/utils/ErrorFactory.ts +++ b/src/utils/ErrorFactory.ts @@ -30,7 +30,7 @@ class ErrorFactory { } eatUpPromiseRejection() { - return function (error: any) { + return function(error: any) { // nom nom } } diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 546e6e8..4ba08d1 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -17,7 +17,7 @@ const util = { generateUuidV4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace( /[xy]/g, - function (c) { + function(c) { const r = (Math.random() * 16) | 0 const v = c === 'x' ? r : (r & 0x3) | 0x8 return v.toString(16)