chore: migrate to oxlint and oxfmt

Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
Peter Steinberger
2026-01-14 14:31:43 +00:00
parent 912ebffc63
commit c379191f80
1480 changed files with 28608 additions and 43547 deletions

View File

@@ -64,8 +64,7 @@ export async function resolveDiscordChannelInfo(
}
const name = "name" in channel ? (channel.name ?? undefined) : undefined;
const topic = "topic" in channel ? (channel.topic ?? undefined) : undefined;
const parentId =
"parentId" in channel ? (channel.parentId ?? undefined) : undefined;
const parentId = "parentId" in channel ? (channel.parentId ?? undefined) : undefined;
const payload: DiscordChannelInfo = {
type: channel.type,
name,
@@ -113,9 +112,7 @@ export async function resolveMediaList(
});
} catch (err) {
const id = attachment.id ?? attachment.url;
logVerbose(
`discord: failed to download attachment ${id}: ${String(err)}`,
);
logVerbose(`discord: failed to download attachment ${id}: ${String(err)}`);
}
}
return out;
@@ -137,9 +134,7 @@ function isImageAttachment(attachment: APIAttachment): boolean {
return /\.(avif|bmp|gif|heic|heif|jpe?g|png|tiff?|webp)$/.test(name);
}
function buildDiscordAttachmentPlaceholder(
attachments?: APIAttachment[],
): string {
function buildDiscordAttachmentPlaceholder(attachments?: APIAttachment[]): string {
if (!attachments || attachments.length === 0) return "";
const count = attachments.length;
const allImages = attachments.every(isImageAttachment);
@@ -186,29 +181,21 @@ function resolveDiscordForwardedMessagesText(message: Message): string {
return forwardedBlocks.join("\n\n");
}
function resolveDiscordMessageSnapshots(
message: Message,
): DiscordMessageSnapshot[] {
const rawData = (message as { rawData?: { message_snapshots?: unknown } })
.rawData;
function resolveDiscordMessageSnapshots(message: Message): DiscordMessageSnapshot[] {
const rawData = (message as { rawData?: { message_snapshots?: unknown } }).rawData;
const snapshots =
rawData?.message_snapshots ??
(message as { message_snapshots?: unknown }).message_snapshots ??
(message as { messageSnapshots?: unknown }).messageSnapshots;
if (!Array.isArray(snapshots)) return [];
return snapshots.filter(
(entry): entry is DiscordMessageSnapshot =>
Boolean(entry) && typeof entry === "object",
(entry): entry is DiscordMessageSnapshot => Boolean(entry) && typeof entry === "object",
);
}
function resolveDiscordSnapshotMessageText(
snapshot: DiscordSnapshotMessage,
): string {
function resolveDiscordSnapshotMessageText(snapshot: DiscordSnapshotMessage): string {
const content = snapshot.content?.trim() ?? "";
const attachmentText = buildDiscordAttachmentPlaceholder(
snapshot.attachments ?? undefined,
);
const attachmentText = buildDiscordAttachmentPlaceholder(snapshot.attachments ?? undefined);
const embed = snapshot.embeds?.[0];
const embedText = embed?.description?.trim() || embed?.title?.trim() || "";
return content || attachmentText || embedText || "";
@@ -243,9 +230,7 @@ export function buildDiscordMediaPayload(
} {
const first = mediaList[0];
const mediaPaths = mediaList.map((media) => media.path);
const mediaTypes = mediaList
.map((media) => media.contentType)
.filter(Boolean) as string[];
const mediaTypes = mediaList.map((media) => media.contentType).filter(Boolean) as string[];
return {
MediaPath: first?.path,
MediaType: first?.contentType,