chore: Enable "curly" rule to avoid single-statement if confusion/errors.

This commit is contained in:
cpojer
2026-01-31 16:19:20 +09:00
parent 009b16fab8
commit 5ceff756e1
1266 changed files with 27871 additions and 9393 deletions

View File

@@ -3,8 +3,12 @@ import { describe, expect, it } from "vitest";
import { transcribeDeepgramAudio } from "./audio.js";
const resolveRequestUrl = (input: RequestInfo | URL) => {
if (typeof input === "string") return input;
if (input instanceof URL) return input.toString();
if (typeof input === "string") {
return input;
}
if (input instanceof URL) {
return input.toString();
}
return input.url;
};

View File

@@ -28,10 +28,14 @@ export async function transcribeDeepgramAudio(
const url = new URL(`${baseUrl}/listen`);
url.searchParams.set("model", model);
if (params.language?.trim()) url.searchParams.set("language", params.language.trim());
if (params.language?.trim()) {
url.searchParams.set("language", params.language.trim());
}
if (params.query) {
for (const [key, value] of Object.entries(params.query)) {
if (value === undefined) continue;
if (value === undefined) {
continue;
}
url.searchParams.set(key, String(value));
}
}

View File

@@ -8,7 +8,9 @@ const DEFAULT_GOOGLE_AUDIO_PROMPT = "Transcribe the audio.";
function resolveModel(model?: string): string {
const trimmed = model?.trim();
if (!trimmed) return DEFAULT_GOOGLE_AUDIO_MODEL;
if (!trimmed) {
return DEFAULT_GOOGLE_AUDIO_MODEL;
}
return normalizeGoogleModelId(trimmed);
}

View File

@@ -3,8 +3,12 @@ import { describe, expect, it } from "vitest";
import { describeGeminiVideo } from "./video.js";
const resolveRequestUrl = (input: RequestInfo | URL) => {
if (typeof input === "string") return input;
if (input instanceof URL) return input.toString();
if (typeof input === "string") {
return input;
}
if (input instanceof URL) {
return input.toString();
}
return input.url;
};

View File

@@ -8,7 +8,9 @@ const DEFAULT_GOOGLE_VIDEO_PROMPT = "Describe the video.";
function resolveModel(model?: string): string {
const trimmed = model?.trim();
if (!trimmed) return DEFAULT_GOOGLE_VIDEO_MODEL;
if (!trimmed) {
return DEFAULT_GOOGLE_VIDEO_MODEL;
}
return normalizeGoogleModelId(trimmed);
}

View File

@@ -18,7 +18,9 @@ const PROVIDERS: MediaUnderstandingProvider[] = [
export function normalizeMediaProviderId(id: string): string {
const normalized = normalizeProviderId(id);
if (normalized === "gemini") return "google";
if (normalized === "gemini") {
return "google";
}
return normalized;
}

View File

@@ -3,8 +3,12 @@ import { describe, expect, it } from "vitest";
import { transcribeOpenAiCompatibleAudio } from "./audio.js";
const resolveRequestUrl = (input: RequestInfo | URL) => {
if (typeof input === "string") return input;
if (input instanceof URL) return input.toString();
if (typeof input === "string") {
return input;
}
if (input instanceof URL) {
return input.toString();
}
return input.url;
};

View File

@@ -27,8 +27,12 @@ export async function transcribeOpenAiCompatibleAudio(
});
form.append("file", blob, fileName);
form.append("model", model);
if (params.language?.trim()) form.append("language", params.language.trim());
if (params.prompt?.trim()) form.append("prompt", params.prompt.trim());
if (params.language?.trim()) {
form.append("language", params.language.trim());
}
if (params.prompt?.trim()) {
form.append("prompt", params.prompt.trim());
}
const headers = new Headers(params.headers);
if (!headers.has("authorization")) {

View File

@@ -24,8 +24,12 @@ export async function readErrorResponse(res: Response): Promise<string | undefin
try {
const text = await res.text();
const collapsed = text.replace(/\s+/g, " ").trim();
if (!collapsed) return undefined;
if (collapsed.length <= MAX_ERROR_CHARS) return collapsed;
if (!collapsed) {
return undefined;
}
if (collapsed.length <= MAX_ERROR_CHARS) {
return collapsed;
}
return `${collapsed.slice(0, MAX_ERROR_CHARS)}`;
} catch {
return undefined;