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

@@ -21,7 +21,9 @@ export const ensureRecord = (
key: string,
): Record<string, unknown> => {
const existing = root[key];
if (isRecord(existing)) return existing;
if (isRecord(existing)) {
return existing;
}
const next: Record<string, unknown> = {};
root[key] = next;
return next;
@@ -29,7 +31,9 @@ export const ensureRecord = (
export const mergeMissing = (target: Record<string, unknown>, source: Record<string, unknown>) => {
for (const [key, value] of Object.entries(source)) {
if (value === undefined) continue;
if (value === undefined) {
continue;
}
const existing = target[key];
if (existing === undefined) {
target[key] = value;
@@ -46,19 +50,29 @@ const AUDIO_TRANSCRIPTION_CLI_ALLOWLIST = new Set(["whisper"]);
export const mapLegacyAudioTranscription = (value: unknown): Record<string, unknown> | null => {
const transcriber = getRecord(value);
const command = Array.isArray(transcriber?.command) ? transcriber?.command : null;
if (!command || command.length === 0) return null;
if (!command || command.length === 0) {
return null;
}
const rawExecutable = String(command[0] ?? "").trim();
if (!rawExecutable) return null;
if (!rawExecutable) {
return null;
}
const executableName = rawExecutable.split(/[\\/]/).pop() ?? rawExecutable;
if (!AUDIO_TRANSCRIPTION_CLI_ALLOWLIST.has(executableName)) return null;
if (!AUDIO_TRANSCRIPTION_CLI_ALLOWLIST.has(executableName)) {
return null;
}
const args = command.slice(1).map((part) => String(part));
const timeoutSeconds =
typeof transcriber?.timeoutSeconds === "number" ? transcriber?.timeoutSeconds : undefined;
const result: Record<string, unknown> = { command: rawExecutable, type: "cli" };
if (args.length > 0) result.args = args;
if (timeoutSeconds !== undefined) result.timeoutSeconds = timeoutSeconds;
if (args.length > 0) {
result.args = args;
}
if (timeoutSeconds !== undefined) {
result.timeoutSeconds = timeoutSeconds;
}
return result;
};
@@ -77,16 +91,22 @@ export const resolveDefaultAgentIdFromRaw = (raw: Record<string, unknown>) => {
typeof entry.id === "string" &&
entry.id.trim() !== "",
);
if (defaultEntry) return defaultEntry.id.trim();
if (defaultEntry) {
return defaultEntry.id.trim();
}
const routing = getRecord(raw.routing);
const routingDefault =
typeof routing?.defaultAgentId === "string" ? routing.defaultAgentId.trim() : "";
if (routingDefault) return routingDefault;
if (routingDefault) {
return routingDefault;
}
const firstEntry = list.find(
(entry): entry is { id: string } =>
isRecord(entry) && typeof entry.id === "string" && entry.id.trim() !== "",
);
if (firstEntry) return firstEntry.id.trim();
if (firstEntry) {
return firstEntry.id.trim();
}
return "main";
};
@@ -96,7 +116,9 @@ export const ensureAgentEntry = (list: unknown[], id: string): Record<string, un
(entry): entry is Record<string, unknown> =>
isRecord(entry) && typeof entry.id === "string" && entry.id.trim() === normalized,
);
if (existing) return existing;
if (existing) {
return existing;
}
const created: Record<string, unknown> = { id: normalized };
list.push(created);
return created;