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

@@ -106,7 +106,9 @@ function randomChoice(values: string[], fallback: string) {
function createSlugBase(words = 2) {
const parts = [randomChoice(SLUG_ADJECTIVES, "steady"), randomChoice(SLUG_NOUNS, "harbor")];
if (words > 2) parts.push(randomChoice(SLUG_NOUNS, "reef"));
if (words > 2) {
parts.push(randomChoice(SLUG_NOUNS, "reef"));
}
return parts.join("-");
}
@@ -114,18 +116,26 @@ export function createSessionSlug(isTaken?: (id: string) => boolean): string {
const isIdTaken = isTaken ?? (() => false);
for (let attempt = 0; attempt < 12; attempt += 1) {
const base = createSlugBase(2);
if (!isIdTaken(base)) return base;
if (!isIdTaken(base)) {
return base;
}
for (let i = 2; i <= 12; i += 1) {
const candidate = `${base}-${i}`;
if (!isIdTaken(candidate)) return candidate;
if (!isIdTaken(candidate)) {
return candidate;
}
}
}
for (let attempt = 0; attempt < 12; attempt += 1) {
const base = createSlugBase(3);
if (!isIdTaken(base)) return base;
if (!isIdTaken(base)) {
return base;
}
for (let i = 2; i <= 12; i += 1) {
const candidate = `${base}-${i}`;
if (!isIdTaken(candidate)) return candidate;
if (!isIdTaken(candidate)) {
return candidate;
}
}
}
const fallback = `${createSlugBase(3)}-${Math.random().toString(36).slice(2, 5)}`;