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

@@ -95,7 +95,9 @@ function resolveSignalReactionTargets(reaction: SignalReactionMessage): SignalRe
function isSignalReactionMessage(
reaction: SignalReactionMessage | null | undefined,
): reaction is SignalReactionMessage {
if (!reaction) return false;
if (!reaction) {
return false;
}
const emoji = reaction.emoji?.trim();
const timestamp = reaction.targetSentTimestamp;
const hasTarget = Boolean(reaction.targetAuthor?.trim() || reaction.targetAuthorUuid?.trim());
@@ -111,10 +113,14 @@ function shouldEmitSignalReactionNotification(params: {
}) {
const { mode, account, targets, sender, allowlist } = params;
const effectiveMode = mode ?? "own";
if (effectiveMode === "off") return false;
if (effectiveMode === "off") {
return false;
}
if (effectiveMode === "own") {
const accountId = account?.trim();
if (!accountId || !targets || targets.length === 0) return false;
if (!accountId || !targets || targets.length === 0) {
return false;
}
const normalizedAccount = normalizeE164(accountId);
return targets.some((target) => {
if (target.kind === "uuid") {
@@ -124,7 +130,9 @@ function shouldEmitSignalReactionNotification(params: {
});
}
if (effectiveMode === "allowlist") {
if (!sender || !allowlist || allowlist.length === 0) return false;
if (!sender || !allowlist || allowlist.length === 0) {
return false;
}
return isSignalSenderAllowed(sender, allowlist);
}
return true;
@@ -160,7 +168,9 @@ async function waitForSignalDaemonReady(params: {
runtime: params.runtime,
check: async () => {
const res = await signalCheck(params.baseUrl, 1000);
if (res.ok) return { ok: true };
if (res.ok) {
return { ok: true };
}
return {
ok: false,
error: res.error ?? (res.status ? `HTTP ${res.status}` : "unreachable"),
@@ -178,7 +188,9 @@ async function fetchAttachment(params: {
maxBytes: number;
}): Promise<{ path: string; contentType?: string } | null> {
const { attachment } = params;
if (!attachment?.id) return null;
if (!attachment?.id) {
return null;
}
if (attachment.size && attachment.size > params.maxBytes) {
throw new Error(
`Signal attachment ${attachment.id} exceeds ${(params.maxBytes / (1024 * 1024)).toFixed(0)}MB limit`,
@@ -187,15 +199,23 @@ async function fetchAttachment(params: {
const rpcParams: Record<string, unknown> = {
id: attachment.id,
};
if (params.account) rpcParams.account = params.account;
if (params.groupId) rpcParams.groupId = params.groupId;
else if (params.sender) rpcParams.recipient = params.sender;
else return null;
if (params.account) {
rpcParams.account = params.account;
}
if (params.groupId) {
rpcParams.groupId = params.groupId;
} else if (params.sender) {
rpcParams.recipient = params.sender;
} else {
return null;
}
const result = await signalRpcRequest<{ data?: string }>("getAttachment", rpcParams, {
baseUrl: params.baseUrl,
});
if (!result?.data) return null;
if (!result?.data) {
return null;
}
const buffer = Buffer.from(result.data, "base64");
const saved = await saveMediaBuffer(
buffer,
@@ -222,7 +242,9 @@ async function deliverReplies(params: {
for (const payload of replies) {
const mediaList = payload.mediaUrls ?? (payload.mediaUrl ? [payload.mediaUrl] : []);
const text = payload.text ?? "";
if (!text && mediaList.length === 0) continue;
if (!text && mediaList.length === 0) {
continue;
}
if (mediaList.length === 0) {
for (const chunk of chunkTextWithMode(text, textLimit, chunkMode)) {
await sendMessageSignal(target, chunk, {
@@ -367,7 +389,9 @@ export async function monitorSignalProvider(opts: MonitorSignalOpts = {}): Promi
},
});
} catch (err) {
if (opts.abortSignal?.aborted) return;
if (opts.abortSignal?.aborted) {
return;
}
throw err;
} finally {
opts.abortSignal?.removeEventListener("abort", onAbort);