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

@@ -7,12 +7,20 @@ function normalizeFlag(value: string): string {
}
function parseEnvFlags(raw?: string): string[] {
if (!raw) return [];
if (!raw) {
return [];
}
const trimmed = raw.trim();
if (!trimmed) return [];
if (!trimmed) {
return [];
}
const lowered = trimmed.toLowerCase();
if (["0", "false", "off", "none"].includes(lowered)) return [];
if (["1", "true", "all", "*"].includes(lowered)) return ["*"];
if (["0", "false", "off", "none"].includes(lowered)) {
return [];
}
if (["1", "true", "all", "*"].includes(lowered)) {
return ["*"];
}
return trimmed
.split(/[,\s]+/)
.map(normalizeFlag)
@@ -24,7 +32,9 @@ function uniqueFlags(flags: string[]): string[] {
const out: string[] = [];
for (const flag of flags) {
const normalized = normalizeFlag(flag);
if (!normalized || seen.has(normalized)) continue;
if (!normalized || seen.has(normalized)) {
continue;
}
seen.add(normalized);
out.push(normalized);
}
@@ -42,20 +52,32 @@ export function resolveDiagnosticFlags(
export function matchesDiagnosticFlag(flag: string, enabledFlags: string[]): boolean {
const target = normalizeFlag(flag);
if (!target) return false;
if (!target) {
return false;
}
for (const raw of enabledFlags) {
const enabled = normalizeFlag(raw);
if (!enabled) continue;
if (enabled === "*" || enabled === "all") return true;
if (!enabled) {
continue;
}
if (enabled === "*" || enabled === "all") {
return true;
}
if (enabled.endsWith(".*")) {
const prefix = enabled.slice(0, -2);
if (target === prefix || target.startsWith(`${prefix}.`)) return true;
if (target === prefix || target.startsWith(`${prefix}.`)) {
return true;
}
}
if (enabled.endsWith("*")) {
const prefix = enabled.slice(0, -1);
if (target.startsWith(prefix)) return true;
if (target.startsWith(prefix)) {
return true;
}
}
if (enabled === target) {
return true;
}
if (enabled === target) return true;
}
return false;
}