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

@@ -34,7 +34,9 @@ function stripQuotes(value: string): string {
}
function parseContentDispositionFileName(header?: string | null): string | undefined {
if (!header) return undefined;
if (!header) {
return undefined;
}
const starMatch = /filename\*\s*=\s*([^;]+)/i.exec(header);
if (starMatch?.[1]) {
const cleaned = stripQuotes(starMatch[1].trim());
@@ -46,17 +48,25 @@ function parseContentDispositionFileName(header?: string | null): string | undef
}
}
const match = /filename\s*=\s*([^;]+)/i.exec(header);
if (match?.[1]) return path.basename(stripQuotes(match[1].trim()));
if (match?.[1]) {
return path.basename(stripQuotes(match[1].trim()));
}
return undefined;
}
async function readErrorBodySnippet(res: Response, maxChars = 200): Promise<string | undefined> {
try {
const text = await res.text();
if (!text) return undefined;
if (!text) {
return undefined;
}
const collapsed = text.replace(/\s+/g, " ").trim();
if (!collapsed) return undefined;
if (collapsed.length <= maxChars) return collapsed;
if (!collapsed) {
return undefined;
}
if (collapsed.length <= maxChars) {
return collapsed;
}
return `${collapsed.slice(0, maxChars)}`;
} catch {
return undefined;
@@ -85,7 +95,9 @@ export async function fetchRemoteMedia(options: FetchMediaOptions): Promise<Fetc
detail = `HTTP ${res.status}${statusText}; empty response body`;
} else {
const snippet = await readErrorBodySnippet(res);
if (snippet) detail += `; body: ${snippet}`;
if (snippet) {
detail += `; body: ${snippet}`;
}
}
throw new MediaFetchError(
"http_error",
@@ -129,7 +141,9 @@ export async function fetchRemoteMedia(options: FetchMediaOptions): Promise<Fetc
});
if (fileName && !path.extname(fileName) && contentType) {
const ext = extensionForMime(contentType);
if (ext) fileName = `${fileName}${ext}`;
if (ext) {
fileName = `${fileName}${ext}`;
}
}
return {
@@ -158,7 +172,9 @@ async function readResponseWithLimit(res: Response, maxBytes: number): Promise<B
try {
while (true) {
const { done, value } = await reader.read();
if (done) break;
if (done) {
break;
}
if (value?.length) {
total += value.length;
if (total > maxBytes) {