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

@@ -20,10 +20,16 @@ export type AssistantIdentity = {
};
function coerceIdentityValue(value: string | undefined, maxLength: number): string | undefined {
if (typeof value !== "string") return undefined;
if (typeof value !== "string") {
return undefined;
}
const trimmed = value.trim();
if (!trimmed) return undefined;
if (trimmed.length <= maxLength) return trimmed;
if (!trimmed) {
return undefined;
}
if (trimmed.length <= maxLength) {
return trimmed;
}
return trimmed.slice(0, maxLength);
}
@@ -32,17 +38,29 @@ function isAvatarUrl(value: string): boolean {
}
function looksLikeAvatarPath(value: string): boolean {
if (/[\\/]/.test(value)) return true;
if (/[\\/]/.test(value)) {
return true;
}
return /\.(png|jpe?g|gif|webp|svg|ico)$/i.test(value);
}
function normalizeAvatarValue(value: string | undefined): string | undefined {
if (!value) return undefined;
if (!value) {
return undefined;
}
const trimmed = value.trim();
if (!trimmed) return undefined;
if (isAvatarUrl(trimmed)) return trimmed;
if (looksLikeAvatarPath(trimmed)) return trimmed;
if (!/\s/.test(trimmed) && trimmed.length <= 4) return trimmed;
if (!trimmed) {
return undefined;
}
if (isAvatarUrl(trimmed)) {
return trimmed;
}
if (looksLikeAvatarPath(trimmed)) {
return trimmed;
}
if (!/\s/.test(trimmed) && trimmed.length <= 4) {
return trimmed;
}
return undefined;
}