Skip to content

Commit

Permalink
ESLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cesardeazevedo committed Oct 24, 2016
1 parent 81d6a3e commit c4552cb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"parser": "babel-eslint",
"rules": {
"max-len": 0,
"global-require": 0,
"arrow-body-style": 0,
"consistent-return": 0,
"no-nested-ternary": 0,
Expand All @@ -14,10 +15,14 @@
"no-case-declarations": 0,
"newline-per-chained-call": 0,
"no-unused-vars": [2, {"varsIgnorePattern": "Columns|VerificationData" }],
"new-cap": [2, { "newIsCapExceptions": [ "hmac" ] }]
},
"globals": {
"BlinkTradeBase": true,
"BlinkTradeRest": true,
"BlinkTradeEnv": true,
"Stun": true,
"Request": true,
"window": true
}
}
12 changes: 6 additions & 6 deletions src/baseTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
* @flow
*/

import _ from 'lodash';
import Base from './base';
import MsgTypes from './constants/requests';
import * as RequestTypes from './constants/requestTypes';
import _ from 'lodash';
import {
deleteRequest,
generateRequestId,
} from './listener';

type StatusList = '1' | '2' | '4' | '8';
type StatusListType = '1' | '2' | '4' | '8';

class BaseTransport extends Base {

Expand Down Expand Up @@ -144,7 +144,7 @@ class BaseTransport extends Base {
}: {
page?: number;
pageSize?: number;
statusList?: Array<StatusList>;
statusList?: Array<StatusListType>;
} = {}, callback?: Function): Promise<Object> {
const msg = {
MsgType: MsgTypes.REQUEST_WITHDRAW_LIST,
Expand Down Expand Up @@ -235,11 +235,11 @@ class BaseTransport extends Base {
requestDepositList({
page: Page = 0,
pageSize: PageSize = 20,
status: StatusList = ['1', '2', '4', '8']
status: StatusList = ['1', '2', '4', '8'],
}: {
page: number;
pageSize: number;
status: Array<StatusList>;
status: Array<StatusListType>;
} = {}, callback?: Function): Promise<Object> {
const msg = {
MsgType: MsgTypes.REQUEST_DEPOSIT_LIST,
Expand All @@ -257,7 +257,7 @@ class BaseTransport extends Base {
...depositData,
DepositListGrp,
});
});
}).catch(reject);
});
}

Expand Down
2 changes: 0 additions & 2 deletions src/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
* @flow
*/

import MsgTypes from './constants/requests';
import RestTransport from './restTransport';
import { generateRequestId } from './listener';

class BlinkTradeRest extends RestTransport {
ticker(callback?: Function): Promise<Object> {
Expand Down
11 changes: 5 additions & 6 deletions src/restTransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
* @flow
*/

import Base from './base';
import BaseTransport from './baseTransport'
import sjcl from 'sjcl';
import nodeify from 'nodeify';
import url from 'url';
import path from 'path';
import BaseTransport from './baseTransport';

class RestTransport extends BaseTransport {

Expand Down Expand Up @@ -70,15 +69,15 @@ class RestTransport extends BaseTransport {
'Content-Type': 'application/json',
Nonce: timeStamp,
APIKey: this.key,
Signature
Signature,
},
body: JSON.stringify(body),
};
}

fetch(msg: Object, api: string, headers?: Object = {}): Promise<Object> {
return this.fetchRequest(url.resolve(this.endpoint, api), headers)
.then(response => response.json())
.then(response => response.json());
}

fetchPublic(api: string, callback?: Function): Promise<Object> {
Expand All @@ -88,8 +87,8 @@ class RestTransport extends BaseTransport {
fetchTrade(msg: Object, callback?: Function): Promise<Object> {
const headers = this.headers('POST', msg);
return nodeify(this.fetch(msg, 'tapi/v1/message', headers, callback)
.then(response => response.Status === 500 ? Promise.reject(response) : response.Responses)
.then(response => response.length === 1 ? response[0] : response)
.then(response => (response.Status === 500 ? Promise.reject(response) : response.Responses))
.then(response => (response.length === 1 ? response[0] : response))
, callback);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
* @flow
*/

import MsgTypes from './constants/requests';

import WebSocketTransport from './wsTransport';
import _ from 'lodash';
import { EventEmitter2 as EventEmitter } from 'eventemitter2';
import {
Expand All @@ -40,6 +37,9 @@ import {
EXECUTION_REPORT,
} from './constants/actionTypes';

import MsgTypes from './constants/requests';
import WebSocketTransport from './wsTransport';

class BlinkTradeWS extends WebSocketTransport {

/**
Expand Down Expand Up @@ -221,13 +221,13 @@ class BlinkTradeWS extends WebSocketTransport {
switch (order.MDEntryType) {
case '0':
case '1':
const orderbookEvent = ORDER_BOOK + ':' + EVENTS.ORDERBOOK[order.MDUpdateAction];
const orderbookEvent = `${ORDER_BOOK}:${EVENTS.ORDERBOOK[order.MDUpdateAction]}`;
return this.eventEmitter.emit(orderbookEvent, {
...dataOrder,
type: orderbookEvent,
});
case '2':
const tradeEvent = ORDER_BOOK + ':' + EVENTS.TRADES[order.MDUpdateAction];
const tradeEvent = `${ORDER_BOOK}:${EVENTS.TRADES[order.MDUpdateAction]}`;
return this.eventEmitter.emit(tradeEvent, {
...dataOrder,
type: tradeEvent,
Expand Down
2 changes: 1 addition & 1 deletion test/websocket.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('WebSocket', () => {

it('Should connect on websocket and callback', (done) => {
BlinkTrade = new BlinkTradeWS({ prod: false });
BlinkTrade.connect((err, data) => {
BlinkTrade.connect((err) => {
expect(err).to.be.null;
done();
});
Expand Down

0 comments on commit c4552cb

Please sign in to comment.