address linter complaints

This commit is contained in:
tiagosiebler
2023-02-17 14:01:07 +00:00
parent 8e54ecbaf5
commit dd6ef2fea5
37 changed files with 154 additions and 106 deletions

View File

@@ -1,3 +1,4 @@
/* eslint-disable max-len */
import { API_ERROR_CODE, ContractClient } from '../../src';
import { successResponseObjectV3 } from '../response.util';

View File

@@ -1,4 +1,4 @@
import { UMCandlesRequest, ContractClient } from '../../src';
import { ContractClient, UMCandlesRequest } from '../../src';
import {
successResponseObject,
successResponseObjectV3,

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Private Contract Websocket Client', () => {

View File

@@ -1,13 +1,15 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Contract Inverse Websocket Client', () => {

View File

@@ -1,13 +1,15 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Contract USDT Websocket Client', () => {

View File

@@ -11,7 +11,8 @@ describe('Private Inverse-Futures REST API GET Endpoints', () => {
testnet: false,
});
// Warning: if some of these start to fail with 10001 params error, it's probably that this future expired and a newer one exists with a different symbol!
// Warning: if some of these start to fail with 10001 params error,
// it's probably that this future expired and a newer one exists with a different symbol!
let symbol = '';
beforeAll(async () => {

View File

@@ -16,7 +16,8 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => {
testnet: false,
});
// Warning: if some of these start to fail with 10001 params error, it's probably that this future expired and a newer one exists with a different symbol!
// Warning: if some of these start to fail with 10001 params error,
// it's probably that this future expired and a newer one exists with a different symbol!
let symbol = '';
beforeAll(async () => {

View File

@@ -1,12 +1,12 @@
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../ws.util';
describe('Private Inverse Perps Websocket Client', () => {

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
LinearClient,
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
promiseSleep,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
promiseSleep,
waitForSocketEvent,
} from '../ws.util';
describe('Public Inverse Perps Websocket Client', () => {

View File

@@ -16,7 +16,8 @@ describe('Private Linear REST API POST Endpoints', () => {
testnet: false,
});
// Warning: if some of these start to fail with 10001 params error, it's probably that this future expired and a newer one exists with a different symbol!
// Warning: if some of these start to fail with 10001 params error,
// it's probably that this future expired and a newer one exists with a different symbol!
const symbol = 'BTCUSDT';
// These tests are primarily check auth is working by expecting balance or order not found style errors

View File

@@ -1,12 +1,12 @@
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../ws.util';
describe('Private Linear Perps Websocket Client', () => {

View File

@@ -1,12 +1,12 @@
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../ws.util';
describe('Public Linear Perps Websocket Client', () => {

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { API_ERROR_CODE } from '../src';
const SUCCESS_MSG_REGEX = /OK|SUCCESS|success|success\.|Request accepted|/gim;
@@ -19,7 +20,7 @@ export function successResponseListV3() {
};
}
export function successResponseObject(successMsg: string | null = 'OK') {
export function successResponseObject() {
return {
result: expect.any(Object),
ret_code: API_ERROR_CODE.SUCCESS,

View File

@@ -16,7 +16,8 @@ describe('Private Spot REST API POST Endpoints', () => {
testnet: false,
});
// Warning: if some of these start to fail with 10001 params error, it's probably that this future expired and a newer one exists with a different symbol!
// Warning: if some of these start to fail with 10001 params error,
// it's probably that this future expired and a newer one exists with a different symbol!
const symbol = 'BTCUSDT';
// These tests are primarily check auth is working by expecting balance or order not found style errors

View File

@@ -21,7 +21,7 @@ describe('Private Spot REST API GET Endpoints', () => {
});
const symbol = 'BTCUSDT';
const interval = '15m';
// const interval = '15m';
const ltCode = 'BTC3S';
it('getOrder()', async () => {

View File

@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { SpotClient } from '../../src';
import {
notAuthenticatedError,
@@ -28,43 +30,39 @@ describe('Public Spot REST API Endpoints', () => {
it('getOrderBook()', async () => {
expect(await api.getOrderBook(symbol)).toMatchObject(
successResponseObject(null)
successResponseObject()
);
});
it('getMergedOrderBook()', async () => {
expect(await api.getMergedOrderBook(symbol)).toMatchObject(
successResponseObject(null)
successResponseObject()
);
});
it('getTrades()', async () => {
expect(await api.getTrades(symbol)).toMatchObject(
successResponseObject(null)
);
expect(await api.getTrades(symbol)).toMatchObject(successResponseObject());
});
it('getCandles()', async () => {
expect(await api.getCandles(symbol, interval)).toMatchObject(
successResponseObject(null)
successResponseObject()
);
});
it('get24hrTicker()', async () => {
expect(await api.get24hrTicker()).toMatchObject(
successResponseObject(null)
);
expect(await api.get24hrTicker()).toMatchObject(successResponseObject());
});
it('getLastTradedPrice()', async () => {
expect(await api.getLastTradedPrice()).toMatchObject(
successResponseObject(null)
successResponseObject()
);
});
it('getBestBidAskPrice()', async () => {
expect(await api.getBestBidAskPrice()).toMatchObject(
successResponseObject(null)
successResponseObject()
);
});

View File

@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { SpotClientV3 } from '../../src';
import {
notAuthenticatedError,

View File

@@ -1,15 +1,17 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
promiseSleep,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
promiseSleep,
waitForSocketEvent,
} from '../ws.util';
describe('Private Spot V1 Websocket Client', () => {

View File

@@ -1,13 +1,15 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_ERROR_ENUM,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../ws.util';
describe('Private Spot V3 Websocket Client', () => {
@@ -19,7 +21,7 @@ describe('Private Spot V3 Websocket Client', () => {
key: API_KEY,
secret: API_SECRET,
};
const wsTopic = `outboundAccountInfo`;
const wsTopic = 'outboundAccountInfo';
describe('with invalid credentials', () => {
it('should reject private subscribe if keys/signature are incorrect', async () => {

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
fullLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Spot V1 Websocket Client', () => {
@@ -64,7 +66,7 @@ describe('Public Spot V1 Websocket Client', () => {
try {
await wsUpdatePromise;
} catch (e) {
console.error(`Wait for spot v1 orderbook event exception: `, e);
console.error('Wait for spot v1 orderbook event exception: ', e);
}
});
});

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
fullLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Spot V3 Websocket Client', () => {

View File

@@ -1,4 +1,4 @@
import { UnifiedMarginClient, UMCandlesRequest } from '../../src';
import { UMCandlesRequest, UnifiedMarginClient } from '../../src';
import {
successResponseObject,
successResponseObjectV3,

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Private Unified Margin Websocket Client', () => {

View File

@@ -1,13 +1,15 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Unified Margin Websocket Client (Options)', () => {

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Unified Margin Websocket Client (Perps - USDC)', () => {

View File

@@ -1,14 +1,16 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../ws.util';
describe('Public Unified Margin Websocket Client (Perps - USDT)', () => {

View File

@@ -1,15 +1,17 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_ERROR_ENUM,
WS_KEY_MAP,
WebsocketClient,
} from '../../../src';
import {
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../../ws.util';
describe('Private USDC Option Websocket Client', () => {
@@ -22,7 +24,7 @@ describe('Private USDC Option Websocket Client', () => {
secret: API_SECRET,
};
const wsTopic = `user.openapi.option.position`;
const wsTopic = 'user.openapi.option.position';
describe('with invalid credentials', () => {
it('should reject private subscribe if keys/signature are incorrect', async () => {

View File

@@ -1,13 +1,15 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../../src';
import {
logAllEvents,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
} from '../../ws.util';
describe('Public USDC Option Websocket Client', () => {

View File

@@ -1,15 +1,17 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_ERROR_ENUM,
WS_KEY_MAP,
WebsocketClient,
} from '../../../src';
import {
WS_OPEN_EVENT_PARTIAL,
fullLogger,
getSilentLogger,
logAllEvents,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../../ws.util';
describe('Private USDC Perp Websocket Client', () => {
@@ -22,7 +24,7 @@ describe('Private USDC Perp Websocket Client', () => {
secret: API_SECRET,
};
const wsTopic = `user.openapi.perp.position`;
const wsTopic = 'user.openapi.perp.position';
describe('with invalid credentials', () => {
it('should reject private subscribe if keys/signature are incorrect', async () => {

View File

@@ -1,13 +1,12 @@
import {
WebsocketClient,
WSClientConfigurableOptions,
WS_KEY_MAP,
WebsocketClient,
} from '../../../src';
import {
logAllEvents,
WS_OPEN_EVENT_PARTIAL,
getSilentLogger,
waitForSocketEvent,
WS_OPEN_EVENT_PARTIAL,
} from '../../ws.util';
describe('Public USDC Perp Websocket Client', () => {

View File

@@ -1,3 +1,5 @@
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */
import { WebsocketClient, WsClientEvent } from '../src';
export function getSilentLogger(logHint?: string) {
@@ -33,6 +35,7 @@ export function waitForSocketEvent(
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject(
// eslint-disable-next-line max-len
`Failed to receive "${event}" event before timeout. Check that these are correct: topic, api keys (if private), signature process (if private)`
);
}, timeoutMs);