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

@@ -19,10 +19,14 @@ type ClaudeWebUsageResponse = ClaudeUsageResponse;
function resolveClaudeWebSessionKey(): string | undefined {
const direct =
process.env.CLAUDE_AI_SESSION_KEY?.trim() ?? process.env.CLAUDE_WEB_SESSION_KEY?.trim();
if (direct?.startsWith("sk-ant-")) return direct;
if (direct?.startsWith("sk-ant-")) {
return direct;
}
const cookieHeader = process.env.CLAUDE_WEB_COOKIE?.trim();
if (!cookieHeader) return undefined;
if (!cookieHeader) {
return undefined;
}
const stripped = cookieHeader.replace(/^cookie:\\s*/i, "");
const match = stripped.match(/(?:^|;\\s*)sessionKey=([^;\\s]+)/i);
const value = match?.[1]?.trim();
@@ -45,11 +49,15 @@ async function fetchClaudeWebUsage(
timeoutMs,
fetchFn,
);
if (!orgRes.ok) return null;
if (!orgRes.ok) {
return null;
}
const orgs = (await orgRes.json()) as ClaudeWebOrganizationsResponse;
const orgId = orgs?.[0]?.uuid?.trim();
if (!orgId) return null;
if (!orgId) {
return null;
}
const usageRes = await fetchJson(
`https://claude.ai/api/organizations/${orgId}/usage`,
@@ -57,7 +65,9 @@ async function fetchClaudeWebUsage(
timeoutMs,
fetchFn,
);
if (!usageRes.ok) return null;
if (!usageRes.ok) {
return null;
}
const data = (await usageRes.json()) as ClaudeWebUsageResponse;
const windows: UsageWindow[] = [];
@@ -86,7 +96,9 @@ async function fetchClaudeWebUsage(
});
}
if (windows.length === 0) return null;
if (windows.length === 0) {
return null;
}
return {
provider: "anthropic",
displayName: PROVIDER_LABELS.anthropic,
@@ -121,7 +133,9 @@ export async function fetchClaudeUsage(
error?: { message?: unknown } | null;
};
const raw = data?.error?.message;
if (typeof raw === "string" && raw.trim()) message = raw.trim();
if (typeof raw === "string" && raw.trim()) {
message = raw.trim();
}
} catch {
// ignore parse errors
}
@@ -133,7 +147,9 @@ export async function fetchClaudeUsage(
const sessionKey = resolveClaudeWebSessionKey();
if (sessionKey) {
const web = await fetchClaudeWebUsage(sessionKey, timeoutMs, fetchFn);
if (web) return web;
if (web) {
return web;
}
}
}