fix(): eslint configuration
This commit is contained in:
34
.eslintrc.cjs
Normal file
34
.eslintrc.cjs
Normal file
@@ -0,0 +1,34 @@
|
||||
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/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
'@typescript-eslint/ban-types': 'off',
|
||||
'simple-import-sort/imports': 'error',
|
||||
'simple-import-sort/exports': 'error',
|
||||
},
|
||||
};
|
||||
36
.eslintrc.js
36
.eslintrc.js
@@ -1,36 +0,0 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
node: true,
|
||||
},
|
||||
extends: ['eslint:recommended'],
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 9
|
||||
},
|
||||
|
||||
plugins: [],
|
||||
rules: {
|
||||
'array-bracket-spacing': ['error', 'never'],
|
||||
indent: ['warn', 2],
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
'lines-between-class-members': ['warn', 'always'],
|
||||
semi: ['error', 'always'],
|
||||
'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,
|
||||
'max-len': ['warn', { 'code': 140 }]
|
||||
}
|
||||
};
|
||||
1132
package-lock.json
generated
1132
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,12 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.0.3",
|
||||
"@types/node": "^18.7.23",
|
||||
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"eslint-plugin-require-extensions": "^0.1.3",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"jest": "^29.1.1",
|
||||
"source-map-loader": "^4.0.0",
|
||||
"ts-jest": "^29.0.2",
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
||||
import EventEmitter from 'events';
|
||||
import WebSocket from 'isomorphic-ws';
|
||||
|
||||
import { WebsocketClientOptions, WSClientConfigurableOptions } from '../types';
|
||||
import WsStore from './WsStore';
|
||||
import { WsConnectionStateEnum } from './WsStore.types';
|
||||
import { DefaultLogger } from './logger';
|
||||
import { isWsPong } from './requestUtils';
|
||||
import { getWsAuthSignature } from './websocket-util';
|
||||
import {
|
||||
WebsocketClientOptions,
|
||||
WSClientConfigurableOptions,
|
||||
} from '../types/index.js';
|
||||
import { DefaultLogger } from './logger.js';
|
||||
import { isWsPong } from './requestUtils.js';
|
||||
import { getWsAuthSignature } from './websocket-util.js';
|
||||
import WsStore from './WsStore.js';
|
||||
import { WsConnectionStateEnum } from './WsStore.types.js';
|
||||
|
||||
interface WSClientEventMap<WsKey extends string> {
|
||||
/** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
|
||||
@@ -30,6 +34,7 @@ interface WSClientEventMap<WsKey extends string> {
|
||||
// Type safety for on and emit handlers: https://stackoverflow.com/a/61609010/880837
|
||||
export interface BaseWebsocketClient<
|
||||
TWSKey extends string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
TWSTopicSubscribeEventArgs extends object,
|
||||
> {
|
||||
on<U extends keyof WSClientEventMap<TWSKey>>(
|
||||
@@ -43,8 +48,6 @@ export interface BaseWebsocketClient<
|
||||
): boolean;
|
||||
}
|
||||
|
||||
export interface BaseWSClientImpl {}
|
||||
|
||||
const LOGGER_CATEGORY = { category: 'bitget-ws' };
|
||||
|
||||
export abstract class BaseWebsocketClient<
|
||||
@@ -382,7 +385,7 @@ export abstract class BaseWebsocketClient<
|
||||
this.logger.silly(
|
||||
`Subscribing to topics in batches of ${maxTopicsPerEvent}`,
|
||||
);
|
||||
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||
for (let i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
||||
this.logger.silly(`Subscribing to batch of ${batch.length}`);
|
||||
this.requestSubscribeTopics(wsKey, batch);
|
||||
@@ -417,7 +420,7 @@ export abstract class BaseWebsocketClient<
|
||||
this.logger.silly(
|
||||
`Unsubscribing to topics in batches of ${maxTopicsPerEvent}`,
|
||||
);
|
||||
for (var i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||
for (let i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
||||
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
||||
this.logger.silly(`Unsubscribing to batch of ${batch.length}`);
|
||||
this.requestUnsubscribeTopics(wsKey, batch);
|
||||
|
||||
17
tsconfig.linting.json
Normal file
17
tsconfig.linting.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"outDir": "dist/cjs",
|
||||
"target": "esnext",
|
||||
"rootDir": "../",
|
||||
"allowJs": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.*",
|
||||
"test/**/*.*",
|
||||
"examples/**/*.*",
|
||||
".eslintrc.cjs",
|
||||
"jest.config.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user