[core] Add eslint fix import plugin

This commit is contained in:
allburov committed 2023-06-16 16:17:31 +07:00
1 parent aa39aaf489
commit 3322c4e2a5
32 files changed
+169 -135

No files matched your search

+30 -25
View File
@@ -1,27 +1,32 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
root: true,
env: {
node: true,
jest: true,
},
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/ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-comment": "off"
},
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module"
},
plugins: [
"@typescript-eslint/eslint-plugin",
"simple-import-sort"
],
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
root: true,
env: {
node: true,
jest: true
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"@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/ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-comment": "off",
}
};
+1 -1
View File
@@ -3,7 +3,7 @@ repos:
rev: 'v2.7.1'
hooks:
- id: prettier
types_or: [javascript, ts]
types_or: [ javascript, ts ]
files: |
(?x)^(
src/.*|
+7 -6
View File
@@ -62,11 +62,6 @@
"@types/jest": "26.0.10",
"@types/node": "^18.14.2",
"@types/supertest": "^2.0.8",
"@typescript-eslint/eslint-plugin": "3.9.1",
"@typescript-eslint/parser": "3.9.1",
"eslint": "7.7.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"jest": "26.4.2",
"prettier": "^1.19.1",
"supertest": "^4.0.2",
@@ -74,7 +69,13 @@
"ts-loader": "^6.2.1",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.0",
"typescript": "4.7.4"
"typescript": "4.7.4",
"@typescript-eslint/eslint-plugin": "3.9.1",
"@typescript-eslint/parser": "3.9.1",
"eslint": "7.7.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-simple-import-sort": "^10.0.0"
},
"jest": {
"moduleFileExtensions": [
+2 -2
View File
@@ -1,10 +1,11 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { SessionManager } from '../core/abc/manager.abc';
import {
ChatRequest,
CheckNumberStatusQuery,
GetMessageQuery,
GetPresenceQuery,
MessageContactVcardRequest,
MessageFileRequest,
MessageImageRequest,
@@ -19,7 +20,6 @@ import {
SendSeenRequest,
} from '../structures/chatting.dto';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import { SessionManager } from '../core/abc/manager.abc';
@ApiSecurity('api_key')
@Controller('api')
+2 -1
View File
@@ -1,9 +1,10 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { SessionManager } from '../core/abc/manager.abc';
import { ContactQuery, ContactRequest } from '../structures/contacts.dto';
import { SessionQuery } from '../structures/base.dto';
import { CheckNumberStatusQuery } from '../structures/chatting.dto';
import { ContactQuery, ContactRequest } from '../structures/contacts.dto';
import { WANumberExistResult } from '../structures/responses.dto';
@ApiSecurity('api_key')
+1
View File
@@ -6,6 +6,7 @@ import {
HttpStatus,
} from '@nestjs/common';
import { Request, Response } from 'express';
import { VERSION } from '../version';
/**
+2 -1
View File
@@ -8,14 +8,15 @@ import {
Put,
} from '@nestjs/common';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { SessionManager } from '../core/abc/manager.abc';
import { WhatsappSession } from '../core/abc/session.abc';
import {
CreateGroupRequest,
DescriptionRequest,
ParticipantsRequest,
SubjectRequest,
} from '../structures/groups.dto';
import { WhatsappSession } from '../core/abc/session.abc';
import { SessionApiParam, SessionParam } from './helpers';
@ApiSecurity('api_key')
+2 -1
View File
@@ -1,5 +1,6 @@
import { ApiParam } from '@nestjs/swagger';
import { Injectable, Param, PipeTransform } from '@nestjs/common';
import { ApiParam } from '@nestjs/swagger';
import { SessionManager } from '../core/abc/manager.abc';
import { WhatsappSession } from '../core/abc/session.abc';
+2 -1
View File
@@ -1,9 +1,10 @@
import { Controller, Get, Param, Post } from '@nestjs/common';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { SessionManager } from '../core/abc/manager.abc';
import { WhatsappSession } from '../core/abc/session.abc';
import { SessionApiParam, SessionParam } from './helpers';
import { WAHAChatPresences } from '../structures/presence.dto';
import { SessionApiParam, SessionParam } from './helpers';
@ApiSecurity('api_key')
@Controller('api/:session/presence')
+2 -1
View File
@@ -1,7 +1,8 @@
import { Controller, Get, Query, Res } from '@nestjs/common';
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
import { Readable } from 'stream';
import { Response } from 'express';
import { Readable } from 'stream';
import { SessionManager } from '../core/abc/manager.abc';
import { SessionQuery } from '../structures/base.dto';
+6 -5
View File
@@ -1,15 +1,16 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { UnprocessableEntityException } from '@nestjs/common/exceptions/unprocessable-entity.exception';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { SessionManager } from '../core/abc/manager.abc';
import { parseBool } from '../helpers';
import {
SessionLogoutRequest,
ListSessionsQuery,
SessionDTO,
SessionLogoutRequest,
SessionStartRequest,
SessionStopRequest,
ListSessionsQuery,
} from '../structures/sessions.dto';
import { SessionManager } from '../core/abc/manager.abc';
import { UnprocessableEntityException } from '@nestjs/common/exceptions/unprocessable-entity.exception';
import { parseBool } from '../helpers';
@ApiSecurity('api_key')
@Controller('api/sessions')
+1
View File
@@ -1,5 +1,6 @@
import { Controller, Get } from '@nestjs/common';
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
import { VERSION } from '../version';
@ApiSecurity('api_key')
+2 -1
View File
@@ -1,7 +1,8 @@
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { WhatsappEngine } from './structures/enums.dto';
import { parseBool } from './helpers';
import { WhatsappEngine } from './structures/enums.dto';
@Injectable()
export class WhatsappConfigService {
+3 -2
View File
@@ -1,12 +1,13 @@
import { OnApplicationShutdown } from '@nestjs/common';
import { WhatsappEngine } from '../../structures/enums.dto';
import {
SessionLogoutRequest,
SessionDTO,
SessionLogoutRequest,
SessionStartRequest,
SessionStopRequest,
} from '../../structures/sessions.dto';
import { WhatsappSession } from './session.abc';
import { WhatsappEngine } from '../../structures/enums.dto';
import { MediaStorage } from './storage.abc';
import { WebhookConductor } from './webhooks.abc';
+12 -11
View File
@@ -1,9 +1,8 @@
import {
WAEvents,
WhatsappEngine,
WhatsappStatus,
} from '../../structures/enums.dto';
import { ConsoleLogger } from '@nestjs/common';
import { EventEmitter } from 'events';
import * as fs from 'fs';
import { MessageId } from 'whatsapp-web.js';
import {
ChatRequest,
CheckNumberStatusQuery,
@@ -19,20 +18,22 @@ import {
MessageTextRequest,
MessageVoiceRequest,
} from '../../structures/chatting.dto';
import { LocalSessionStorage, MediaStorage } from './storage.abc';
import { MessageId } from 'whatsapp-web.js';
import { ContactQuery, ContactRequest } from '../../structures/contacts.dto';
import { NotImplementedByEngineError } from '../exceptions';
import {
WAEvents,
WhatsappEngine,
WhatsappStatus,
} from '../../structures/enums.dto';
import {
CreateGroupRequest,
ParticipantsRequest,
} from '../../structures/groups.dto';
import * as fs from 'fs';
import { WAHAChatPresences } from '../../structures/presence.dto';
import { NotImplementedByEngineError } from '../exceptions';
import { LocalSessionStorage, MediaStorage } from './storage.abc';
const CHROME_PATH = '/usr/bin/google-chrome-stable';
const CHROMIUM_PATH = '/usr/bin/chromium';
import { EventEmitter } from 'events';
import { WAHAChatPresences } from '../../structures/presence.dto';
export function getBrowserExecutablePath() {
if (fs.existsSync(CHROME_PATH)) {
+8 -7
View File
@@ -1,17 +1,18 @@
import { ConsoleLogger, Module } from '@nestjs/common';
import { ScreenshotController } from '../api/screenshot.controller';
import { ConfigModule } from '@nestjs/config';
import { WhatsappConfigService } from '../config.service';
import { PassportModule } from '@nestjs/passport';
import { ServeStaticModule } from '@nestjs/serve-static';
import { SessionsController } from '../api/sessions.controller';
import { ChattingController } from '../api/chatting.controller';
import { ContactsController } from '../api/contacts.controller';
import { VersionController } from '../api/version.controller';
import { PassportModule } from '@nestjs/passport';
import { SessionManager } from './abc/manager.abc';
import { SessionManagerCore } from './manager.core';
import { GroupsController } from '../api/groups.controller';
import { PresenceController } from '../api/presence.controller';
import { ScreenshotController } from '../api/screenshot.controller';
import { SessionsController } from '../api/sessions.controller';
import { VersionController } from '../api/version.controller';
import { WhatsappConfigService } from '../config.service';
import { SessionManager } from './abc/manager.abc';
import { SessionManagerCore } from './manager.core';
export const IMPORTS = [
ConfigModule.forRoot({
+4 -3
View File
@@ -1,9 +1,10 @@
import { WhatsappConfigService } from '../config.service';
import { WhatsappSession, ProxyConfig } from './abc/session.abc';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { Agent } from 'https';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { URL } from 'url';
import { WhatsappConfigService } from '../config.service';
import { ProxyConfig, WhatsappSession } from './abc/session.abc';
export function getProxyConfig(
config: WhatsappConfigService,
sessions: Record<string, WhatsappSession>,
+14 -13
View File
@@ -4,6 +4,15 @@ import {
NotFoundException,
UnprocessableEntityException,
} from '@nestjs/common';
import { WhatsappConfigService } from '../config.service';
import { WhatsappEngine, WhatsappStatus } from '../structures/enums.dto';
import {
SessionDTO,
SessionLogoutRequest,
SessionStartRequest,
SessionStopRequest,
} from '../structures/sessions.dto';
import { SessionManager } from './abc/manager.abc';
import {
ProxyConfig,
@@ -11,22 +20,14 @@ import {
WhatsappSession,
WhatsAppSessionConfig,
} from './abc/session.abc';
import { WhatsappEngine, WhatsappStatus } from '../structures/enums.dto';
import {
SessionLogoutRequest,
SessionDTO,
SessionStartRequest,
SessionStopRequest,
} from '../structures/sessions.dto';
import { WhatsappConfigService } from '../config.service';
import { LocalSessionStorage } from './abc/storage.abc';
import { DOCS_URL } from './exceptions';
import { getProxyConfig } from './helpers.proxy';
import { WhatsappSessionNoWebCore } from './session.noweb.core';
import { WhatsappSessionVenomCore } from './session.venom.core';
import { WhatsappSessionWebJSCore } from './session.webjs.core';
import { DOCS_URL } from './exceptions';
import { WebhookConductorCore } from './webhooks.core';
import { MediaStorageCore, SessionStorageCore } from './storage.core';
import { WhatsappSessionNoWebCore } from './session.noweb.core';
import { LocalSessionStorage } from './abc/storage.abc';
import { getProxyConfig } from './helpers.proxy';
import { WebhookConductorCore } from './webhooks.core';
export class OnlyDefaultSessionIsAllowed extends UnprocessableEntityException {
constructor() {
+25 -25
View File
@@ -1,10 +1,3 @@
import {
SECOND,
WAEvents,
WAHAPresenceStatus,
WhatsappEngine,
WhatsappStatus,
} from '../structures/enums.dto';
import makeWASocket, {
DisconnectReason,
isJidGroup,
@@ -12,13 +5,12 @@ import makeWASocket, {
PresenceData,
useMultiFileAuthState,
} from '@adiwajshing/baileys';
import { UnprocessableEntityException } from '@nestjs/common';
import * as fs from 'fs';
import { Agent } from 'https';
import * as lodash from 'lodash';
import { Message } from 'whatsapp-web.js';
import {
ensureSuffix,
WAHAInternalEvent,
WhatsappSession,
} from './abc/session.abc';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import {
Button,
ChatRequest,
@@ -36,26 +28,34 @@ import {
MessageVoiceRequest,
SendSeenRequest,
} from '../structures/chatting.dto';
import {
AvailableInPlusVersion,
NotImplementedByEngineError,
} from './exceptions';
import { ContactQuery, ContactRequest } from '../structures/contacts.dto';
import {
SECOND,
WAEvents,
WAHAPresenceStatus,
WhatsappEngine,
WhatsappStatus,
} from '../structures/enums.dto';
import {
CreateGroupRequest,
ParticipantsRequest,
} from '../structures/groups.dto';
import { QR } from './QR';
import { UnprocessableEntityException } from '@nestjs/common';
import { Message } from 'whatsapp-web.js';
import * as fs from 'fs';
import { Agent } from 'https';
import { createAgentProxy } from './helpers.proxy';
import {
WAHAPresenceData,
WAHAChatPresences,
WAHAPresenceData,
} from '../structures/presence.dto';
import * as lodash from 'lodash';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import {
ensureSuffix,
WAHAInternalEvent,
WhatsappSession,
} from './abc/session.abc';
import {
AvailableInPlusVersion,
NotImplementedByEngineError,
} from './exceptions';
import { createAgentProxy } from './helpers.proxy';
import { QR } from './QR';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const QRCode = require('qrcode');
+5 -4
View File
@@ -1,4 +1,6 @@
import { WAHAInternalEvent, WhatsappSession } from './abc/session.abc';
import { UnprocessableEntityException } from '@nestjs/common/exceptions/unprocessable-entity.exception';
import { create, CreateConfig, Message, Whatsapp } from 'venom-bot';
import {
Button,
ChatRequest,
@@ -14,15 +16,14 @@ import {
MessageTextButtonsRequest,
MessageTextRequest,
} from '../structures/chatting.dto';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import { create, CreateConfig, Message, Whatsapp } from 'venom-bot';
import {
WAEvents,
WhatsappEngine,
WhatsappStatus,
} from '../structures/enums.dto';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import { WAHAInternalEvent, WhatsappSession } from './abc/session.abc';
import { NotImplementedByEngineError } from './exceptions';
import { UnprocessableEntityException } from '@nestjs/common/exceptions/unprocessable-entity.exception';
import { QR } from './QR';
export class WhatsappSessionVenomCore extends WhatsappSession {
+12 -11
View File
@@ -11,13 +11,7 @@ import {
Message,
} from 'whatsapp-web.js';
import { Message as MessageInstance } from 'whatsapp-web.js/src/structures';
import {
WAEvents,
WhatsappEngine,
WhatsappStatus,
} from '../structures/enums.dto';
import { WAHAInternalEvent, WhatsappSession } from './abc/session.abc';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import {
Button,
ChatRequest,
@@ -35,15 +29,22 @@ import {
MessageVoiceRequest,
SendSeenRequest,
} from '../structures/chatting.dto';
import {
AvailableInPlusVersion,
NotImplementedByEngineError,
} from './exceptions';
import { ContactQuery, ContactRequest } from '../structures/contacts.dto';
import {
WAEvents,
WhatsappEngine,
WhatsappStatus,
} from '../structures/enums.dto';
import {
CreateGroupRequest,
ParticipantsRequest,
} from '../structures/groups.dto';
import { WAMessage, WANumberExistResult } from '../structures/responses.dto';
import { WAHAInternalEvent, WhatsappSession } from './abc/session.abc';
import {
AvailableInPlusVersion,
NotImplementedByEngineError,
} from './exceptions';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const qrcode = require('qrcode-terminal');
+4 -3
View File
@@ -1,8 +1,9 @@
import { DOCS_URL } from './exceptions';
import { LocalSessionStorage, MediaStorage } from './abc/storage.abc';
import * as path from 'path';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { LocalSessionStorage, MediaStorage } from './abc/storage.abc';
import { DOCS_URL } from './exceptions';
export class MediaStorageCore implements MediaStorage {
async save(
+3 -2
View File
@@ -1,7 +1,8 @@
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { INestApplication } from '@nestjs/common';
import { VERSION } from '../version';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { WhatsappConfigService } from '../config.service';
import { VERSION } from '../version';
export class SwaggerModuleCore {
configure(app: INestApplication) {
+3 -2
View File
@@ -1,9 +1,10 @@
import { WAHAInternalEvent, WhatsappSession } from './abc/session.abc';
import { ConsoleLogger } from '@nestjs/common';
import { WAEvents } from '../structures/enums.dto';
import { WAWebhook } from '../structures/responses.dto';
import { NotImplementedByEngineError } from './exceptions';
import { WhatsappSession } from './abc/session.abc';
import { WebhookConductor } from './abc/webhooks.abc';
import { NotImplementedByEngineError } from './exceptions';
import request = require('request');
export class WebhookConductorCore implements WebhookConductor {
+4 -3
View File
@@ -1,10 +1,11 @@
import { NestFactory } from '@nestjs/core';
import { WhatsappConfigService } from './config.service';
import { json, urlencoded } from 'express';
import { AllExceptionsFilter } from './api/exception.filter';
import { getWAHAVersion, VERSION, WAHAVersion } from './version';
import { WhatsappConfigService } from './config.service';
import { AppModuleCore } from './core/app.module.core';
import { SwaggerModuleCore } from './core/swagger.module.core';
import { json, urlencoded } from 'express';
import { getWAHAVersion, WAHAVersion } from './version';
async function loadModules(): Promise<
[typeof AppModuleCore, typeof SwaggerModuleCore]
+2 -1
View File
@@ -1,5 +1,6 @@
import { IsNotEmpty, IsString, IsOptional, IsNumber } from 'class-validator';
import { ApiExtraModels, ApiProperty, getSchemaPath } from '@nestjs/swagger';
import { IsNumber, IsString } from 'class-validator';
import { SessionBaseRequest, SessionQuery } from './base.dto';
/**
+1
View File
@@ -1,4 +1,5 @@
import { IsString } from 'class-validator';
import { SessionBaseRequest, SessionQuery } from './base.dto';
/**
+1
View File
@@ -1,4 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { WAHAPresenceStatus } from './enums.dto';
export class WAHAPresenceData {
+1
View File
@@ -1,4 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { WAEvents, WhatsappEngine } from './enums.dto';
export class WANumberExistResult {
+2 -1
View File
@@ -1,6 +1,7 @@
import { WhatsappStatus } from './enums.dto';
import { ApiProperty } from '@nestjs/swagger';
import { WhatsappStatus } from './enums.dto';
/**
* Queries
*/
-2
View File
@@ -3,8 +3,6 @@ import { getBrowserExecutablePath } from './core/abc/session.abc';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
export enum WAHAVersion {
PLUS = 'PLUS',
+5
View File
@@ -3543,6 +3543,11 @@ eslint-plugin-import@^2.20.1:
semver "^6.3.0"
tsconfig-paths "^3.14.1"
eslint-plugin-simple-import-sort@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-10.0.0.tgz#cc4ceaa81ba73252427062705b64321946f61351"
integrity sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==
eslint-scope@5.1.1, eslint-scope@^5.0.0, eslint-scope@^5.1.0, eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"