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

@@ -16,23 +16,33 @@ function isRecord(value: unknown): value is Record<string, unknown> {
}
function collectScopes(value: unknown, into: string[]) {
if (!value) return;
if (!value) {
return;
}
if (Array.isArray(value)) {
for (const entry of value) {
if (typeof entry === "string" && entry.trim()) into.push(entry.trim());
if (typeof entry === "string" && entry.trim()) {
into.push(entry.trim());
}
}
return;
}
if (typeof value === "string") {
const raw = value.trim();
if (!raw) return;
if (!raw) {
return;
}
const parts = raw.split(/[,\s]+/).map((part) => part.trim());
for (const part of parts) {
if (part) into.push(part);
if (part) {
into.push(part);
}
}
return;
}
if (!isRecord(value)) return;
if (!isRecord(value)) {
return;
}
for (const entry of Object.values(value)) {
if (Array.isArray(entry) || typeof entry === "string") {
collectScopes(entry, into);
@@ -45,7 +55,9 @@ function normalizeScopes(scopes: string[]) {
}
function extractScopes(payload: unknown): string[] {
if (!isRecord(payload)) return [];
if (!isRecord(payload)) {
return [];
}
const scopes: string[] = [];
collectScopes(payload.scopes, scopes);
collectScopes(payload.scope, scopes);
@@ -59,7 +71,9 @@ function extractScopes(payload: unknown): string[] {
}
function readError(payload: unknown): string | undefined {
if (!isRecord(payload)) return undefined;
if (!isRecord(payload)) {
return undefined;
}
const error = payload.error;
return typeof error === "string" && error.trim() ? error.trim() : undefined;
}
@@ -94,7 +108,9 @@ export async function fetchSlackScopes(
return { ok: true, scopes, source: method };
}
const error = readError(result);
if (error) errors.push(`${method}: ${error}`);
if (error) {
errors.push(`${method}: ${error}`);
}
}
return {