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

@@ -52,7 +52,9 @@ function resolvePayloadLogConfig(env: NodeJS.ProcessEnv): PayloadLogConfig {
function getWriter(filePath: string): PayloadLogWriter {
const existing = writers.get(filePath);
if (existing) return existing;
if (existing) {
return existing;
}
const dir = path.dirname(filePath);
const ready = fs.mkdir(dir, { recursive: true }).catch(() => undefined);
@@ -75,8 +77,12 @@ function getWriter(filePath: string): PayloadLogWriter {
function safeJsonStringify(value: unknown): string | null {
try {
return JSON.stringify(value, (_key, val) => {
if (typeof val === "bigint") return val.toString();
if (typeof val === "function") return "[Function]";
if (typeof val === "bigint") {
return val.toString();
}
if (typeof val === "function") {
return "[Function]";
}
if (val instanceof Error) {
return { name: val.name, message: val.message, stack: val.stack };
}
@@ -91,8 +97,12 @@ function safeJsonStringify(value: unknown): string | null {
}
function formatError(error: unknown): string | undefined {
if (error instanceof Error) return error.message;
if (typeof error === "string") return error;
if (error instanceof Error) {
return error.message;
}
if (typeof error === "string") {
return error;
}
if (typeof error === "number" || typeof error === "boolean" || typeof error === "bigint") {
return String(error);
}
@@ -104,7 +114,9 @@ function formatError(error: unknown): string | undefined {
function digest(value: unknown): string | undefined {
const serialized = safeJsonStringify(value);
if (!serialized) return undefined;
if (!serialized) {
return undefined;
}
return crypto.createHash("sha256").update(serialized).digest("hex");
}
@@ -140,7 +152,9 @@ export function createAnthropicPayloadLogger(params: {
}): AnthropicPayloadLogger | null {
const env = params.env ?? process.env;
const cfg = resolvePayloadLogConfig(env);
if (!cfg.enabled) return null;
if (!cfg.enabled) {
return null;
}
const writer = getWriter(cfg.filePath);
const base: Omit<PayloadLogEvent, "ts" | "stage"> = {
@@ -155,7 +169,9 @@ export function createAnthropicPayloadLogger(params: {
const record = (event: PayloadLogEvent) => {
const line = safeJsonStringify(event);
if (!line) return;
if (!line) {
return;
}
writer.write(`${line}\n`);
};