Skip to content

Commit

Permalink
Fixed linting #150
Browse files Browse the repository at this point in the history
  • Loading branch information
githubsaturn committed Dec 23, 2024
1 parent 92363fe commit ec4e705
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/api/ApiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class ApiManager {
baseUrl,
appToken,
ApiManager.authToken,
function () {
function() {
return self.getAuthToken(ApiManager.lastKnownPassword)
}
)
Expand Down Expand Up @@ -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
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/CliApiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions src/api/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,37 @@ export default class HttpClient {
variables: any
) {
const self = this
return function (): Promise<any> {
return function(): Promise<any> {
return Promise.resolve() //
.then(function () {
.then(function() {
if (!process.env.REACT_APP_IS_DEBUG) {
return Promise.resolve()
}
return new Promise<void>(function (res) {
return new Promise<void>(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
})
})
} else {
return data
}
})
.then(function (data) {
.then(function(data) {
if (
data.status !== ErrorFactory.OKAY &&
data.status !== ErrorFactory.OKAY_BUILD_STARTED
Expand All @@ -94,25 +94,25 @@ 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)
}
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)
}
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class HttpClient {
headers: self.createHeaders(),
qs: variables,
json: true
}).then(function (data) {
}).then(function(data) {
return data
})
}
Expand All @@ -162,7 +162,7 @@ export default class HttpClient {
headers: self.createHeaders(),
formData: variables,
json: true
}).then(function (data) {
}).then(function(data) {
return data
})
}
Expand All @@ -171,7 +171,7 @@ export default class HttpClient {
headers: self.createHeaders(),
body: variables,
json: true
}).then(function (data) {
}).then(function(data) {
return data
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/DeployHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class DeployHelper {
}

private gitArchiveFile(zipFileFullPath: string, branchToPush: string) {
return new Promise<string>(function (resolve, reject) {
return new Promise<string>(function(resolve, reject) {
if (fs.pathExistsSync(zipFileFullPath)) {
fs.removeSync(zipFileFullPath)
} // Removes the temporary file created
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ErrorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ErrorFactory {
}

eatUpPromiseRejection() {
return function (error: any) {
return function(error: any) {
// nom nom
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ec4e705

Please sign in to comment.