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

@@ -41,8 +41,12 @@ function formatZonedTimestamp(date: Date, timeZone?: string): string {
export function formatEnvelopeTimestamp(date: Date, zone: EnvelopeTimestampZone = "utc"): string {
const normalized = zone.trim().toLowerCase();
if (normalized === "utc" || normalized === "gmt") return formatUtcTimestamp(date);
if (normalized === "local" || normalized === "host") return formatZonedTimestamp(date);
if (normalized === "utc" || normalized === "gmt") {
return formatUtcTimestamp(date);
}
if (normalized === "local" || normalized === "host") {
return formatZonedTimestamp(date);
}
return formatZonedTimestamp(date, zone);
}

View File

@@ -8,15 +8,21 @@ function stripAnsi(input: string): string {
}
const next = input[i + 1];
if (next !== "[") continue;
if (next !== "[") {
continue;
}
i += 1;
while (i + 1 < input.length) {
i += 1;
const c = input[i];
if (!c) break;
if (!c) {
break;
}
const isLetter = (c >= "A" && c <= "Z") || (c >= "a" && c <= "z") || c === "~";
if (isLetter) break;
if (isLetter) {
break;
}
}
}
return out;

View File

@@ -17,7 +17,9 @@ export async function pollUntil<T>(
while (Date.now() - start < timeoutMs) {
const value = await fn();
if (value !== null && value !== undefined) return value;
if (value !== null && value !== undefined) {
return value;
}
await sleep(intervalMs);
}

View File

@@ -24,8 +24,11 @@ function snapshotEnv(): EnvSnapshot {
function restoreEnv(snapshot: EnvSnapshot) {
const restoreKey = (key: string, value: string | undefined) => {
if (value === undefined) delete process.env[key];
else process.env[key] = value;
if (value === undefined) {
delete process.env[key];
} else {
process.env[key] = value;
}
};
restoreKey("HOME", snapshot.home);
restoreKey("USERPROFILE", snapshot.userProfile);
@@ -36,14 +39,19 @@ function restoreEnv(snapshot: EnvSnapshot) {
function snapshotExtraEnv(keys: string[]): Record<string, string | undefined> {
const snapshot: Record<string, string | undefined> = {};
for (const key of keys) snapshot[key] = process.env[key];
for (const key of keys) {
snapshot[key] = process.env[key];
}
return snapshot;
}
function restoreExtraEnv(snapshot: Record<string, string | undefined>) {
for (const [key, value] of Object.entries(snapshot)) {
if (value === undefined) delete process.env[key];
else process.env[key] = value;
if (value === undefined) {
delete process.env[key];
} else {
process.env[key] = value;
}
}
}
@@ -52,9 +60,13 @@ function setTempHome(base: string) {
process.env.USERPROFILE = base;
process.env.OPENCLAW_STATE_DIR = path.join(base, ".openclaw");
if (process.platform !== "win32") return;
if (process.platform !== "win32") {
return;
}
const match = base.match(/^([A-Za-z]:)(.*)$/);
if (!match) return;
if (!match) {
return;
}
process.env.HOMEDRIVE = match[1];
process.env.HOMEPATH = match[2] || "\\";
}
@@ -78,8 +90,11 @@ export async function withTempHome<T>(
if (opts.env) {
for (const [key, raw] of Object.entries(opts.env)) {
const value = typeof raw === "function" ? raw(base) : raw;
if (value === undefined) delete process.env[key];
else process.env[key] = value;
if (value === undefined) {
delete process.env[key];
} else {
process.env[key] = value;
}
}
}