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

@@ -18,7 +18,9 @@ export type DeliveryContextSessionSource = {
};
export function normalizeDeliveryContext(context?: DeliveryContext): DeliveryContext | undefined {
if (!context) return undefined;
if (!context) {
return undefined;
}
const channel =
typeof context.channel === "string"
? (normalizeMessageChannel(context.channel) ?? context.channel.trim())
@@ -33,13 +35,17 @@ export function normalizeDeliveryContext(context?: DeliveryContext): DeliveryCon
: undefined;
const normalizedThreadId =
typeof threadId === "string" ? (threadId ? threadId : undefined) : threadId;
if (!channel && !to && !accountId && normalizedThreadId == null) return undefined;
if (!channel && !to && !accountId && normalizedThreadId == null) {
return undefined;
}
const normalized: DeliveryContext = {
channel: channel || undefined,
to: to || undefined,
accountId,
};
if (normalizedThreadId != null) normalized.threadId = normalizedThreadId;
if (normalizedThreadId != null) {
normalized.threadId = normalizedThreadId;
}
return normalized;
}
@@ -92,7 +98,9 @@ export function normalizeSessionDeliveryFields(source?: DeliveryContextSessionSo
export function deliveryContextFromSession(
entry?: DeliveryContextSessionSource & { origin?: { threadId?: string | number } },
): DeliveryContext | undefined {
if (!entry) return undefined;
if (!entry) {
return undefined;
}
const source: DeliveryContextSessionSource = {
channel: entry.channel,
lastChannel: entry.lastChannel,
@@ -110,7 +118,9 @@ export function mergeDeliveryContext(
): DeliveryContext | undefined {
const normalizedPrimary = normalizeDeliveryContext(primary);
const normalizedFallback = normalizeDeliveryContext(fallback);
if (!normalizedPrimary && !normalizedFallback) return undefined;
if (!normalizedPrimary && !normalizedFallback) {
return undefined;
}
return normalizeDeliveryContext({
channel: normalizedPrimary?.channel ?? normalizedFallback?.channel,
to: normalizedPrimary?.to ?? normalizedFallback?.to,
@@ -121,7 +131,9 @@ export function mergeDeliveryContext(
export function deliveryContextKey(context?: DeliveryContext): string | undefined {
const normalized = normalizeDeliveryContext(context);
if (!normalized?.channel || !normalized?.to) return undefined;
if (!normalized?.channel || !normalized?.to) {
return undefined;
}
const threadId =
normalized.threadId != null && normalized.threadId !== "" ? String(normalized.threadId) : "";
return `${normalized.channel}|${normalized.to}|${normalized.accountId ?? ""}|${threadId}`;