From 1b556afeb39f7eb6255d6274a50dc4ba592982d1 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Sun, 4 Oct 2020 20:37:42 +0100 Subject: [PATCH] fix: linting --- .eslintrc.js | 1 - lib/util/requestWrapper.js | 51 +++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ee9fc82..e8c5c55 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,6 @@ module.exports = { indent: ['warn', 2], 'linebreak-style': ['error', 'unix'], 'lines-between-class-members': ['warn', 'always'], - quotes: ['error', 'single'], semi: ['error', 'always'], 'new-cap': 'off', 'no-console': 'off', diff --git a/lib/util/requestWrapper.js b/lib/util/requestWrapper.js index 6f1189f..4a3bd96 100644 --- a/lib/util/requestWrapper.js +++ b/lib/util/requestWrapper.js @@ -24,7 +24,7 @@ module.exports = class RequestUtil { this.baseUrl = baseUrls[livenet === true ? 'livenet' : 'testnet']; if (options.baseUrl) { - this.baseUrl = options.baseUrl + this.baseUrl = options.baseUrl; } this.globalRequestOptions = { @@ -35,7 +35,7 @@ module.exports = class RequestUtil { headers: { Referer: 'bybitapinode' }, - } + }; if (key) { assert(secret, 'Secret is required for private enpoints'); @@ -108,27 +108,27 @@ module.exports = class RequestUtil { requestOptions: options }; }) - .catch(e => { - if (!e.response) { + .catch(e => { + if (!e.response) { // Something happened in setting up the request that triggered an Error - if (!e.request) { - throw e.message; + if (!e.request) { + throw e.message; + } + + // request made but no response received + throw e; } - // request made but no response received - throw e; - } - - // The request was made and the server responded with a status code - // that falls out of the range of 2xx - throw { - code: e.response.statusCode, - message: e.response.message, - body: e.response.body, - requestOptions: options, - headers: e.response.headers - }; - }); + // The request was made and the server responded with a status code + // that falls out of the range of 2xx + throw { + code: e.response.statusCode, + message: e.response.message, + body: e.response.body, + requestOptions: options, + headers: e.response.headers + }; + }); } _signRequest(data) { @@ -156,14 +156,9 @@ module.exports = class RequestUtil { return this._syncTimePromise; } - this._syncTimePromise = new Promise(async (resolve, reject) => { - try { - this._timeOffset = await this.getTimeOffset(); - this._syncTimePromise = null; - resolve(); - } catch (err) { - reject(err); - } + this._syncTimePromise = this.getTimeOffset().then(offset => { + this._timeOffset = offset; + this._syncTimePromise = null; }); return this._syncTimePromise;