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

@@ -36,7 +36,9 @@ function isUnrecognizedKeysIssue(issue: ZodIssue): issue is UnrecognizedKeysIssu
}
function formatPath(parts: Array<string | number>): string {
if (parts.length === 0) return "<root>";
if (parts.length === 0) {
return "<root>";
}
let out = "";
for (const part of parts) {
if (typeof part === "number") {
@@ -52,14 +54,22 @@ function resolvePathTarget(root: unknown, path: Array<string | number>): unknown
let current: unknown = root;
for (const part of path) {
if (typeof part === "number") {
if (!Array.isArray(current)) return null;
if (part < 0 || part >= current.length) return null;
if (!Array.isArray(current)) {
return null;
}
if (part < 0 || part >= current.length) {
return null;
}
current = current[part];
continue;
}
if (!current || typeof current !== "object" || Array.isArray(current)) return null;
if (!current || typeof current !== "object" || Array.isArray(current)) {
return null;
}
const record = current as Record<string, unknown>;
if (!(part in record)) return null;
if (!(part in record)) {
return null;
}
current = record[part];
}
return current;
@@ -77,14 +87,22 @@ function stripUnknownConfigKeys(config: OpenClawConfig): {
const next = structuredClone(config);
const removed: string[] = [];
for (const issue of parsed.error.issues) {
if (!isUnrecognizedKeysIssue(issue)) continue;
if (!isUnrecognizedKeysIssue(issue)) {
continue;
}
const path = normalizeIssuePath(issue.path);
const target = resolvePathTarget(next, path);
if (!target || typeof target !== "object" || Array.isArray(target)) continue;
if (!target || typeof target !== "object" || Array.isArray(target)) {
continue;
}
const record = target as Record<string, unknown>;
for (const key of issue.keys) {
if (typeof key !== "string") continue;
if (!(key in record)) continue;
if (typeof key !== "string") {
continue;
}
if (!(key in record)) {
continue;
}
delete record[key];
removed.push(formatPath([...path, key]));
}
@@ -95,13 +113,21 @@ function stripUnknownConfigKeys(config: OpenClawConfig): {
function noteOpencodeProviderOverrides(cfg: OpenClawConfig) {
const providers = cfg.models?.providers;
if (!providers) return;
if (!providers) {
return;
}
// 2026-01-10: warn when OpenCode Zen overrides mask built-in routing/costs (8a194b4abc360c6098f157956bb9322576b44d51, 2d105d16f8a099276114173836d46b46cdfbdbae).
const overrides: string[] = [];
if (providers.opencode) overrides.push("opencode");
if (providers["opencode-zen"]) overrides.push("opencode-zen");
if (overrides.length === 0) return;
if (providers.opencode) {
overrides.push("opencode");
}
if (providers["opencode-zen"]) {
overrides.push("opencode-zen");
}
if (overrides.length === 0) {
return;
}
const lines = overrides.flatMap((id) => {
const providerEntry = providers[id];
@@ -125,7 +151,9 @@ function noteOpencodeProviderOverrides(cfg: OpenClawConfig) {
async function maybeMigrateLegacyConfig(): Promise<string[]> {
const changes: string[] = [];
const home = resolveHomeDir();
if (!home) return changes;
if (!home) {
return changes;
}
const targetDir = path.join(home, ".openclaw");
const targetPath = path.join(targetDir, "openclaw.json");
@@ -152,7 +180,9 @@ async function maybeMigrateLegacyConfig(): Promise<string[]> {
// continue
}
}
if (!legacyPath) return changes;
if (!legacyPath) {
return changes;
}
await fs.mkdir(targetDir, { recursive: true });
try {
@@ -214,7 +244,9 @@ export async function loadAndMaybeMigrateDoctorConfig(params: {
}
if (shouldRepair) {
// Legacy migration (2026-01-02, commit: 16420e5b) — normalize per-provider allowlists; move WhatsApp gating into channels.whatsapp.allowFrom.
if (migrated) cfg = migrated;
if (migrated) {
cfg = migrated;
}
} else {
fixHints.push(
`Run "${formatCliCommand("openclaw doctor --fix")}" to apply legacy migrations.`,