chore(lint): burn down remaining warnings to zero
This commit is contained in:
@@ -15,7 +15,10 @@ function createMockClient() {
|
||||
user: null as { id: string; tag: string } | null,
|
||||
on: vi.fn((event: string, handler: (...args: unknown[]) => void) => {
|
||||
if (!handlers.has(event)) {handlers.set(event, []);}
|
||||
handlers.get(event)!.push(handler);
|
||||
const eventHandlers = handlers.get(event);
|
||||
if (eventHandlers) {
|
||||
eventHandlers.push(handler);
|
||||
}
|
||||
}),
|
||||
login: vi.fn(async (_token: string) => {
|
||||
// Set user info after login
|
||||
|
||||
@@ -87,7 +87,7 @@ describe('MatrixAdapter', () => {
|
||||
|
||||
it('send delivers a message via PUT', async () => {
|
||||
let syncStarted = false;
|
||||
mockFetch.mockImplementation(async (url: string, init?: any) => {
|
||||
mockFetch.mockImplementation(async (url: string, init?: RequestInit) => {
|
||||
if (url.endsWith('/_matrix/client/v3/account/whoami')) {
|
||||
return jsonResponse({ user_id: '@flynn:example.org' });
|
||||
}
|
||||
@@ -99,7 +99,7 @@ describe('MatrixAdapter', () => {
|
||||
return new Promise<Response>(() => {});
|
||||
}
|
||||
if (init?.method === 'PUT' && url.includes('/send/m.room.message/')) {
|
||||
const body = JSON.parse(init.body);
|
||||
const body = JSON.parse(String(init?.body ?? '{}'));
|
||||
expect(body.msgtype).toBe('m.text');
|
||||
expect(body.body).toBe('Hello there');
|
||||
return jsonResponse({ event_id: '$sent1' });
|
||||
|
||||
@@ -201,8 +201,10 @@ export class MatrixAdapter implements ChannelAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
const err = error as any;
|
||||
if (err && typeof err === 'object' && err.name === 'AbortError') {
|
||||
const errName = error && typeof error === 'object' && 'name' in error
|
||||
? String((error as { name?: unknown }).name)
|
||||
: '';
|
||||
if (errName === 'AbortError') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ describe('PairingManager', () => {
|
||||
|
||||
it('listPendingCodes returns only non-expired codes', () => {
|
||||
vi.useFakeTimers();
|
||||
const code1 = manager.generateCode('first');
|
||||
manager.generateCode('first');
|
||||
|
||||
// Advance time so the first code is almost expired
|
||||
vi.advanceTimersByTime(200_000);
|
||||
|
||||
@@ -226,7 +226,11 @@ export class SlackAdapter implements ChannelAdapter {
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await this.app!.client.users.info({ user: userId });
|
||||
const app = this.app;
|
||||
if (!app) {
|
||||
return userId;
|
||||
}
|
||||
const result = await app.client.users.info({ user: userId });
|
||||
const name = result.user?.real_name || result.user?.name || userId;
|
||||
this.userNameCache.set(userId, { name, expiresAt: now + this.userNameCacheTtlMs });
|
||||
if (this.userNameCache.size > this.userNameCacheMaxEntries) {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Bot, InputFile } from 'grammy';
|
||||
|
||||
import type { HookEngine } from '../../hooks/index.js';
|
||||
import type {
|
||||
Attachment,
|
||||
InboundMessage,
|
||||
OutboundMessage,
|
||||
OutboundAttachment,
|
||||
@@ -438,7 +437,8 @@ export class TelegramAdapter implements ChannelAdapter {
|
||||
|
||||
/** Send an outbound message, automatically chunking if it exceeds Telegram's limit. */
|
||||
async send(peerId: string, message: OutboundMessage): Promise<void> {
|
||||
if (!this.bot) {throw new Error('Telegram adapter not connected');}
|
||||
const bot = this.bot;
|
||||
if (!bot) {throw new Error('Telegram adapter not connected');}
|
||||
|
||||
const chatId = Number(peerId);
|
||||
const text = message.text ?? '';
|
||||
@@ -459,7 +459,7 @@ export class TelegramAdapter implements ChannelAdapter {
|
||||
// is strict and can fail on unescaped characters. If Telegram rejects the
|
||||
// message, retry once without parse_mode so users still get the content.
|
||||
try {
|
||||
await this.bot!.api.sendMessage(chatId, chunk, { parse_mode: 'Markdown' });
|
||||
await bot.api.sendMessage(chatId, chunk, { parse_mode: 'Markdown' });
|
||||
} catch (error) {
|
||||
const description = error && typeof error === 'object' && 'description' in error
|
||||
? String((error as { description?: unknown }).description)
|
||||
@@ -472,7 +472,7 @@ export class TelegramAdapter implements ChannelAdapter {
|
||||
throw error;
|
||||
}
|
||||
|
||||
await this.bot!.api.sendMessage(chatId, chunk);
|
||||
await bot.api.sendMessage(chatId, chunk);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user