Enable more biome lints and fix things

This commit is contained in:
Mario Zechner 2025-12-21 22:56:20 +01:00
parent 9c18439c4d
commit d5fd685901
57 changed files with 151 additions and 199 deletions

View file

@ -23,6 +23,8 @@ function defaultMessageTransformer(messages: AppMessage[]): Message[] {
.map((m) => {
if (m.role === "user") {
// Strip attachments field (app-specific)
// biome-ignore lint/correctness/noUnusedVariables: fine here
const { attachments, ...rest } = m as any;
return rest as Message;
}

View file

@ -31,12 +31,6 @@ export class AttachmentTile extends LitElement {
const hasPreview = !!this.attachment.preview;
const isImage = this.attachment.type === "image";
const isPdf = this.attachment.mimeType === "application/pdf";
const isDocx =
this.attachment.mimeType?.includes("wordprocessingml") ||
this.attachment.fileName.toLowerCase().endsWith(".docx");
const isPptx =
this.attachment.mimeType?.includes("presentationml") ||
this.attachment.fileName.toLowerCase().endsWith(".pptx");
const isExcel =
this.attachment.mimeType?.includes("spreadsheetml") ||
this.attachment.fileName.toLowerCase().endsWith(".xlsx") ||
@ -84,7 +78,7 @@ export class AttachmentTile extends LitElement {
<div class="text-[10px] text-center truncate w-full">
${
this.attachment.fileName.length > 10
? this.attachment.fileName.substring(0, 8) + "..."
? `${this.attachment.fileName.substring(0, 8)}...`
: this.attachment.fileName
}
</div>

View file

@ -140,7 +140,7 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
return;
}
const { action, filename, content, mimeType } = message;
const { action, filename, content } = message;
try {
switch (action) {

View file

@ -40,18 +40,18 @@ export class AttachmentsRuntimeProvider implements SandboxRuntimeProvider {
(window as any).readTextAttachment = (attachmentId: string) => {
const a = ((window as any).attachments || []).find((x: any) => x.id === attachmentId);
if (!a) throw new Error("Attachment not found: " + attachmentId);
if (!a) throw new Error(`Attachment not found: ${attachmentId}`);
if (a.extractedText) return a.extractedText;
try {
return atob(a.content);
} catch {
throw new Error("Failed to decode text content for: " + attachmentId);
throw new Error(`Failed to decode text content for: ${attachmentId}`);
}
};
(window as any).readBinaryAttachment = (attachmentId: string) => {
const a = ((window as any).attachments || []).find((x: any) => x.id === attachmentId);
if (!a) throw new Error("Attachment not found: " + attachmentId);
if (!a) throw new Error(`Attachment not found: ${attachmentId}`);
const bin = atob(a.content);
const bytes = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);

View file

@ -92,8 +92,7 @@ export class ConsoleRuntimeProvider implements SandboxRuntimeProvider {
// Error handlers - track errors but don't log them
// (they'll be shown via execution-error message)
window.addEventListener("error", (e) => {
const text =
(e.error?.stack || e.message || String(e)) + " at line " + (e.lineno || "?") + ":" + (e.colno || "?");
const text = `${e.error?.stack || e.message || String(e)} at line ${e.lineno || "?"}:${e.colno || "?"}`;
lastError = {
message: e.error?.message || e.message || String(e),
@ -102,7 +101,7 @@ export class ConsoleRuntimeProvider implements SandboxRuntimeProvider {
});
window.addEventListener("unhandledrejection", (e) => {
const text = "Unhandled promise rejection: " + (e.reason?.message || e.reason || "Unknown error");
const text = `Unhandled promise rejection: ${e.reason?.message || e.reason || "Unknown error"}`;
lastError = {
message: e.reason?.message || String(e.reason) || "Unhandled promise rejection",

View file

@ -65,7 +65,7 @@ export class ProvidersModelsTab extends SettingsTab {
);
this.providerStatus.set(provider.id, { modelCount: models.length, status: "connected" });
} catch (error) {
} catch (_error) {
this.providerStatus.set(provider.id, { modelCount: 0, status: "disconnected" });
}
this.requestUpdate();

View file

@ -87,7 +87,7 @@ export class IndexedDBStorageBackend implements StorageBackend {
if (prefix) {
// Use IDBKeyRange for efficient prefix filtering
const range = IDBKeyRange.bound(prefix, prefix + "\uffff", false, false);
const range = IDBKeyRange.bound(prefix, `${prefix}\uffff`, false, false);
const keys = await this.promisifyRequest(store.getAllKeys(range));
return keys.map((k) => String(k));
} else {

View file

@ -137,7 +137,7 @@ export function createExtractDocumentTool(): AgentTool<typeof extractDocumentSch
const urlParts = url.split("/");
let fileName = urlParts[urlParts.length - 1]?.split("?")[0] || "document";
if (url.startsWith("https://arxiv.org/")) {
fileName = fileName + ".pdf";
fileName = `${fileName}.pdf`;
}
// Use loadAttachment to process the document

View file

@ -51,7 +51,7 @@ export async function executeJavaScript(
// Add console output - result.console contains { type: string, text: string } from sandbox.js
if (result.console && result.console.length > 0) {
for (const entry of result.console) {
output += entry.text + "\n";
output += `${entry.text}\n`;
}
}
@ -230,7 +230,7 @@ export const javascriptReplRenderer: ToolRenderer<JavaScriptReplParams, JavaScri
if (isTextBased && f.contentBase64) {
try {
extractedText = atob(f.contentBase64);
} catch (e) {
} catch (_e) {
console.warn("Failed to decode base64 content for", f.fileName);
}
}

View file

@ -343,7 +343,7 @@ function extractTextFromElement(element: any): string {
}
}
if (tableTexts.length > 0) {
text = "\n[Table]\n" + tableTexts.join("\n") + "\n[/Table]\n";
text = `\n[Table]\n${tableTexts.join("\n")}\n[/Table]\n`;
}
}
}
@ -397,7 +397,7 @@ async function processPptx(arrayBuffer: ArrayBuffer, fileName: string): Promise<
.filter((t) => t.trim());
if (slideTexts.length > 0) {
extractedText += "\n" + slideTexts.join("\n");
extractedText += `\n${slideTexts.join("\n")}`;
}
extractedText += "\n</slide>";
}

View file

@ -37,6 +37,6 @@ export function formatUsage(usage: Usage) {
export function formatTokenCount(count: number): string {
if (count < 1000) return count.toString();
if (count < 10000) return (count / 1000).toFixed(1) + "k";
return Math.round(count / 1000) + "k";
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
return `${Math.round(count / 1000)}k`;
}