chore: Lint extensions folder.

This commit is contained in:
cpojer
2026-01-31 22:13:48 +09:00
parent 4f2166c503
commit 230ca789e2
221 changed files with 4006 additions and 1583 deletions

View File

@@ -3,7 +3,9 @@ import { Urbit } from "@urbit/http-api";
let patched = false;
export function ensureUrbitConnectPatched() {
if (patched) return;
if (patched) {
return;
}
patched = true;
Urbit.prototype.connect = async function patchedConnect() {
const resp = await fetch(`${this.url}/~/login`, {

View File

@@ -121,7 +121,11 @@ export async function sendGroupMessage({
export function buildMediaText(text: string | undefined, mediaUrl: string | undefined): string {
const cleanText = text?.trim() ?? "";
const cleanUrl = mediaUrl?.trim() ?? "";
if (cleanText && cleanUrl) return `${cleanText}\n${cleanUrl}`;
if (cleanUrl) return cleanUrl;
if (cleanText && cleanUrl) {
return `${cleanText}\n${cleanUrl}`;
}
if (cleanUrl) {
return cleanUrl;
}
return cleanText;
}

View File

@@ -180,20 +180,26 @@ export class UrbitSSEClient {
if (!this.aborted) {
this.logger.error?.(`Stream error: ${String(error)}`);
for (const { err } of this.eventHandlers.values()) {
if (err) err(error);
if (err) {
err(error);
}
}
}
});
}
async processStream(body: ReadableStream<Uint8Array> | Readable | null) {
if (!body) return;
if (!body) {
return;
}
const stream = body instanceof ReadableStream ? Readable.fromWeb(body) : body;
let buffer = "";
try {
for await (const chunk of stream) {
if (this.aborted) break;
if (this.aborted) {
break;
}
buffer += chunk.toString();
let eventEnd;
while ((eventEnd = buffer.indexOf("\n\n")) !== -1) {
@@ -221,7 +227,9 @@ export class UrbitSSEClient {
}
}
if (!data) return;
if (!data) {
return;
}
try {
const parsed = JSON.parse(data) as { id?: number; json?: unknown; response?: string };
@@ -229,7 +237,9 @@ export class UrbitSSEClient {
if (parsed.response === "quit") {
if (parsed.id) {
const handlers = this.eventHandlers.get(parsed.id);
if (handlers?.quit) handlers.quit();
if (handlers?.quit) {
handlers.quit();
}
}
return;
}
@@ -241,7 +251,9 @@ export class UrbitSSEClient {
}
} else if (parsed.json) {
for (const { event } of this.eventHandlers.values()) {
if (event) event(parsed.json);
if (event) {
event(parsed.json);
}
}
}
} catch (error) {