Skip to content

Commit

Permalink
Merge pull request #393 from tiagosiebler/testfixes2
Browse files Browse the repository at this point in the history
fix(): failing tests, failing eslint configuration, chore(): run linter
  • Loading branch information
tiagosiebler authored Nov 8, 2024
2 parents 725f252 + cbf9623 commit 304d5c2
Show file tree
Hide file tree
Showing 21 changed files with 206 additions and 159 deletions.
84 changes: 84 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.linting.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: [
'@typescript-eslint/eslint-plugin',
// 'simple-import-sort',
// 'require-extensions',
],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
// 'plugin:require-extensions/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-unused-vars': 'warn',

'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',

'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',

'no-dupe-class-members': 'off',
'no-param-reassign': ['error'],
'array-bracket-spacing': ['error', 'never'],
indent: ['off'],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['warn', 'always'],
semi: 'off',
'@typescript-eslint/semi': ['error'],
'new-cap': 'off',
'no-console': 'off',
'no-debugger': 'off',
'no-mixed-spaces-and-tabs': 2,
'no-use-before-define': [2, 'nofunc'],
'no-unreachable': ['warn'],
'no-unused-vars': ['warn'],
'no-extra-parens': ['off'],
'no-mixed-operators': ['off'],
quotes: [2, 'single', 'avoid-escape'],
'block-scoped-var': 2,
'brace-style': [2, '1tbs', { allowSingleLine: true }],
'computed-property-spacing': [2, 'never'],
'keyword-spacing': 2,
'space-unary-ops': 2,
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],
'max-len': ['warn', { code: 140 }],

// newer rules
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
// 'simple-import-sort/imports': 'error',
// 'simple-import-sort/exports': 'error',
},
};
86 changes: 0 additions & 86 deletions .eslintrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-api",
"version": "3.10.24",
"version": "3.10.25",
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
5 changes: 4 additions & 1 deletion src/copy-trading-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ export class CopyTradingClient extends BaseRestClient {
);
}

/** Close Order. This endpoint's rate_limit will decrease by 10 per request; ie, one request to this endpoint consumes 10 from the limit allowed per minute. */
/** Close Order.
* This endpoint's rate_limit will decrease by 10 per request;
* ie, one request to this endpoint consumes 10 from the limit allowed per minute.
*/
closeOrder(
params: CopyTradingCloseOrderRequest,
): Promise<APIResponseV3<any>> {
Expand Down
3 changes: 2 additions & 1 deletion src/rest-client-v5.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-len */
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
APIResponseV3,
Expand Down Expand Up @@ -242,7 +243,7 @@ export class RestClientV5 extends BaseRestClient {
console.log(result);

console.log(
`Your approximate latency to exchange server:
`Your approximate latency to exchange server:
One way: ${estimatedOneWayLatency}ms.
Round trip: ${roundTripTime}ms.
`,
Expand Down
24 changes: 12 additions & 12 deletions src/spot-client-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class SpotClientV3 extends BaseRestClient {
getMergedOrderBook(
symbol: string,
scale?: number,
limit?: number
limit?: number,
): Promise<APIResponseV3<any>> {
return this.get('/spot/v3/public/quote/depth/merged', {
symbol,
Expand All @@ -73,7 +73,7 @@ export class SpotClientV3 extends BaseRestClient {
interval: KlineInterval,
limit?: number,
startTime?: number,
endTime?: number
endTime?: number,
): Promise<APIResponseV3<any>> {
return this.get('/spot/v3/public/quote/kline', {
symbol,
Expand Down Expand Up @@ -124,7 +124,7 @@ export class SpotClientV3 extends BaseRestClient {

/** Batch cancel orders */
cancelOrderBatch(
params: SpotCancelOrderBatchRequest
params: SpotCancelOrderBatchRequest,
): Promise<APIResponseV3<any>> {
const orderTypes = params.orderTypes
? params.orderTypes.join(',')
Expand All @@ -149,7 +149,7 @@ export class SpotClientV3 extends BaseRestClient {
symbol?: string,
orderId?: string,
limit?: number,
orderCategory?: 0 | 1
orderCategory?: 0 | 1,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/spot/v3/private/open-orders', {
symbol,
Expand All @@ -164,7 +164,7 @@ export class SpotClientV3 extends BaseRestClient {
symbol?: string,
orderId?: string,
limit?: number,
orderCategory?: 0 | 1
orderCategory?: 0 | 1,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/spot/v3/private/history-orders', {
symbol,
Expand Down Expand Up @@ -224,7 +224,7 @@ export class SpotClientV3 extends BaseRestClient {
purchaseLeveragedToken(
ltCode: string,
ltAmount: string,
serialNo?: string
serialNo?: string,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/spot/v3/private/purchase', {
ltCode,
Expand All @@ -237,7 +237,7 @@ export class SpotClientV3 extends BaseRestClient {
redeemLeveragedToken(
ltCode: string,
ltAmount: string,
serialNo?: string
serialNo?: string,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/spot/v3/private/redeem', {
ltCode,
Expand All @@ -248,7 +248,7 @@ export class SpotClientV3 extends BaseRestClient {

/** Get leveraged token purchase/redemption history */
getLeveragedTokenPRHistory(
params?: SpotLeveragedTokenPRHistoryRequest
params?: SpotLeveragedTokenPRHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/spot/v3/private/record', params);
}
Expand All @@ -262,7 +262,7 @@ export class SpotClientV3 extends BaseRestClient {
/** Borrow margin loan */
borrowCrossMarginLoan(
coin: string,
qty: string
qty: string,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/spot/v3/private/cross-margin-loan', {
coin,
Expand All @@ -280,7 +280,7 @@ export class SpotClientV3 extends BaseRestClient {

/** Query borrowing info */
getCrossMarginBorrowingInfo(
params?: SpotCrossMarginBorrowingInfoRequest
params?: SpotCrossMarginBorrowingInfoRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/spot/v3/private/cross-margin-orders', params);
}
Expand All @@ -297,11 +297,11 @@ export class SpotClientV3 extends BaseRestClient {

/** Query repayment history */
getCrossMarginRepaymentHistory(
params?: SpotCrossMarginRepaymentHistoryRequest
params?: SpotCrossMarginRepaymentHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate(
'/spot/v3/private/cross-margin-repay-history',
params
params,
);
}
}
4 changes: 2 additions & 2 deletions src/types/request/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ export interface LinearSetMarginSwitchRequest {

export interface LinearSetPositionModeRequest {
symbol: string;
mode: typeof linearPositionModeEnum[keyof typeof linearPositionModeEnum];
mode: (typeof linearPositionModeEnum)[keyof typeof linearPositionModeEnum];
}

export interface LinearSetPositionTpSlModeRequest {
symbol: string;
tp_sl_mode: typeof positionTpSlModeEnum[keyof typeof positionTpSlModeEnum];
tp_sl_mode: (typeof positionTpSlModeEnum)[keyof typeof positionTpSlModeEnum];
}

export interface LinearSetAddReduceMarginRequest {
Expand Down
8 changes: 5 additions & 3 deletions src/types/v5-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type InstrumentStatusV5 =
| 'Settling'
| 'Delivering'
| 'Closed';


export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly';

Expand Down Expand Up @@ -156,7 +155,7 @@ export type PositionIdx = 0 | 1 | 2;

/**
* Position status.
*
*
* - 'Normal'
* - 'Liq' in the liquidation progress
* - 'Adl' in the auto-deleverage progress
Expand All @@ -175,7 +174,10 @@ export type OptionTypeV5 = 'Call' | 'Put';
export type TradeModeV5 = 0 | 1;

export type TPSLModeV5 = 'Full' | 'Partial';
export type AccountMarginModeV5 = 'ISOLATED_MARGIN' | 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN';
export type AccountMarginModeV5 =
| 'ISOLATED_MARGIN'
| 'REGULAR_MARGIN'
| 'PORTFOLIO_MARGIN';
export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS';

export type AccountTypeV5 =
Expand Down
Loading

0 comments on commit 304d5c2

Please sign in to comment.