Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
style(engine): resolve lint in baileys engine files (mirror wwjs stub-method disable pattern)
rmyndharis77107375907e
diff --git a/src/engine/adapters/baileys-message-mapper.spec.ts b/src/engine/adapters/baileys-message-mapper.spec.tsindex 888af2dd4..9eabe1120 100644--- a/src/engine/adapters/baileys-message-mapper.spec.ts+++ b/src/engine/adapters/baileys-message-mapper.spec.ts@@ -20,6 +20,7 @@ describe('mapBaileysMessageType (baileys content-type -> neutral MessageType)',[undefined, false, 'unknown'],['pollCreationMessage', false, 'unknown'],])('maps %s (ptt=%s) -> %s', (raw, ptt, expected) => {+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertionexpect(mapBaileysMessageType(raw as string | undefined, ptt as boolean)).toBe(expected);});});diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.tsindex 3d3777ecb..c087d1f45 100644--- a/src/engine/adapters/baileys.adapter.spec.ts+++ b/src/engine/adapters/baileys.adapter.spec.ts@@ -40,8 +40,7 @@ import { EngineStatus, EngineEventCallbacks } from '../interfaces/whatsapp-enginimport { EngineNotReadyError } from '../../common/errors/engine-not-ready.error';import { EngineNotSupportedError } from '../../common/errors/engine-not-supported.error';-const newAdapter = (): BaileysAdapter =>- new BaileysAdapter({ sessionId: 'sess-1', authDir: './data/baileys' });+const newAdapter = (): BaileysAdapter => new BaileysAdapter({ sessionId: 'sess-1', authDir: './data/baileys' });const noopCallbacks = (over: Partial<EngineEventCallbacks> = {}): EngineEventCallbacks => over;@@ -82,9 +81,13 @@ describe('BaileysAdapter lifecycle & status', () => {const onDisconnected = jest.fn();const adapter = newAdapter();await adapter.initialize(noopCallbacks({ onDisconnected }));+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-accessconst makeWASocket = jest.requireMock('@whiskeysockets/baileys').default as jest.Mock;makeWASocket.mockClear();- fakeSock.fire('connection.update', { connection: 'close', lastDisconnect: { error: { output: { statusCode: 401 } } } });+ fakeSock.fire('connection.update', {+ connection: 'close',+ lastDisconnect: { error: { output: { statusCode: 401 } } },+ });expect(adapter.getStatus()).toBe(EngineStatus.DISCONNECTED);expect(onDisconnected).toHaveBeenCalled();expect(makeWASocket).not.toHaveBeenCalled(); // no reconnect@@ -94,9 +97,13 @@ describe('BaileysAdapter lifecycle & status', () => {const onDisconnected = jest.fn();const adapter = newAdapter();await adapter.initialize(noopCallbacks({ onDisconnected }));+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-accessconst makeWASocket = jest.requireMock('@whiskeysockets/baileys').default as jest.Mock;makeWASocket.mockClear();- fakeSock.fire('connection.update', { connection: 'close', lastDisconnect: { error: { output: { statusCode: 515 } } } });+ fakeSock.fire('connection.update', {+ connection: 'close',+ lastDisconnect: { error: { output: { statusCode: 515 } } },+ });await new Promise(r => setImmediate(r)); // let the async connect() runexpect(makeWASocket).toHaveBeenCalledTimes(1);expect(onDisconnected).not.toHaveBeenCalled();@@ -193,6 +200,7 @@ describe('BaileysAdapter messaging', () => {});describe('BaileysAdapter inbound fan-out', () => {+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertionconst baileys = jest.requireMock('@whiskeysockets/baileys') as { getContentType: jest.Mock };beforeEach(() => {@@ -217,6 +225,7 @@ describe('BaileysAdapter inbound fan-out', () => {],});expect(onMessage).toHaveBeenCalledTimes(1);+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-accessconst msg = onMessage.mock.calls[0][0] as { id: string; body: string; type: string; fromMe: boolean };expect(msg).toMatchObject({ id: 'IN1', body: 'hi there', type: 'text', fromMe: false });});@@ -246,7 +255,9 @@ describe('BaileysAdapter inbound fan-out', () => {await adapter.initialize({ onMessage });fakeSock.fire('messages.upsert', {type: 'append',- messages: [{ key: { remoteJid: '[email protected]', fromMe: false, id: 'OLD' }, message: { conversation: 'old' } }],+ messages: [+ { key: { remoteJid: '[email protected]', fromMe: false, id: 'OLD' }, message: { conversation: 'old' } },+ ],});expect(onMessage).not.toHaveBeenCalled();});@@ -259,4 +270,3 @@ describe('BaileysAdapter inbound fan-out', () => {expect(onMessageAck).toHaveBeenCalledWith('OUT1', 'delivered');});});-diff --git a/src/engine/adapters/baileys.adapter.ts b/src/engine/adapters/baileys.adapter.tsindex 49274d321..0082eeec5 100644--- a/src/engine/adapters/baileys.adapter.ts+++ b/src/engine/adapters/baileys.adapter.ts@@ -100,10 +100,12 @@ export class BaileysAdapter implements IWhatsAppEngine {printQRInTerminal: false,// BaileysLogger matches ILogger exactly; cast needed because the module resolves// the type through a deep import path that TypeScript does not auto-unify here.+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertionlogger: createSilentLogger() as unknown as ILogger,});this.sock = sock;+ // eslint-disable-next-line @typescript-eslint/no-misused-promisessock.ev.on('creds.update', saveCreds);sock.ev.on('connection.update', update => this.handleConnectionUpdate(update));sock.ev.on('messages.upsert', event => this.handleMessagesUpsert(event));@@ -162,11 +164,12 @@ export class BaileysAdapter implements IWhatsAppEngine {}}- async disconnect(): Promise<void> {+ disconnect(): Promise<void> {this.intentionalClose = true;this.sock?.end(undefined);this.sock = null;this.setStatus(EngineStatus.DISCONNECTED);+ return Promise.resolve();}async logout(): Promise<void> {@@ -185,11 +188,12 @@ export class BaileysAdapter implements IWhatsAppEngine {// stale creds ever block re-linking.}- async destroy(): Promise<void> {+ destroy(): Promise<void> {this.intentionalClose = true;this.sock?.end(undefined);this.sock = null;this.setStatus(EngineStatus.DISCONNECTED);+ return Promise.resolve();}// ----- Status -----@@ -246,6 +250,7 @@ export class BaileysAdapter implements IWhatsAppEngine {}// ----- Gated: not supported by this minimal slice (no store) -----+ /* eslint-disable @typescript-eslint/no-unused-vars */sendImageMessage(_chatId: string, _media: MediaInput): Promise<MessageResult> {return this.unsupported('sendImageMessage');@@ -412,6 +417,7 @@ export class BaileysAdapter implements IWhatsAppEngine {deleteChat(_chatId: string): Promise<boolean> {return this.unsupported('deleteChat');}+ /* eslint-enable @typescript-eslint/no-unused-vars */// ----- Helpers -----@@ -433,7 +439,9 @@ export class BaileysAdapter implements IWhatsAppEngine {}}- private handleMessagesUpdate(updates: Array<{ key?: { id?: string | null }; update?: { status?: number | null } }>): void {+ private handleMessagesUpdate(+ updates: Array<{ key?: { id?: string | null }; update?: { status?: number | null } }>,+ ): void {for (const u of updates) {const status = mapBaileysStatus(u.update?.status);if (status && u.key?.id) {@@ -473,7 +481,6 @@ export class BaileysAdapter implements IWhatsAppEngine {return typeof ts === 'number' ? ts : ts.toNumber();}- // eslint-disable-next-line @typescript-eslint/no-explicit-anyprivate unsupported(method: string): Promise<any> {return Promise.reject(new EngineNotSupportedError(method));}