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

@@ -34,7 +34,9 @@ type SignalTarget =
function parseTarget(raw: string): SignalTarget {
let value = raw.trim();
if (!value) throw new Error("Signal recipient is required");
if (!value) {
throw new Error("Signal recipient is required");
}
const lower = value.toLowerCase();
if (lower.startsWith("signal:")) {
value = value.slice("signal:".length).trim();
@@ -72,15 +74,21 @@ function buildTargetParams(
allow: SignalTargetAllowlist,
): SignalTargetParams | null {
if (target.type === "recipient") {
if (!allow.recipient) return null;
if (!allow.recipient) {
return null;
}
return { recipient: [target.recipient] };
}
if (target.type === "group") {
if (!allow.group) return null;
if (!allow.group) {
return null;
}
return { groupId: target.groupId };
}
if (target.type === "username") {
if (!allow.username) return null;
if (!allow.username) {
return null;
}
return { username: [target.username] };
}
return null;
@@ -139,7 +147,9 @@ export async function sendMessageSignal(
let textStyles: SignalTextStyleRange[] = [];
const textMode = opts.textMode ?? "markdown";
const maxBytes = (() => {
if (typeof opts.maxBytes === "number") return opts.maxBytes;
if (typeof opts.maxBytes === "number") {
return opts.maxBytes;
}
if (typeof accountInfo.config.mediaMaxMb === "number") {
return accountInfo.config.mediaMaxMb * 1024 * 1024;
}
@@ -186,7 +196,9 @@ export async function sendMessageSignal(
(style) => `${style.start}:${style.length}:${style.style}`,
);
}
if (account) params.account = account;
if (account) {
params.account = account;
}
if (attachments && attachments.length > 0) {
params.attachments = attachments;
}
@@ -221,10 +233,16 @@ export async function sendTypingSignal(
recipient: true,
group: true,
});
if (!targetParams) return false;
if (!targetParams) {
return false;
}
const params: Record<string, unknown> = { ...targetParams };
if (account) params.account = account;
if (opts.stop) params.stop = true;
if (account) {
params.account = account;
}
if (opts.stop) {
params.stop = true;
}
await signalRpcRequest("sendTyping", params, {
baseUrl,
timeoutMs: opts.timeoutMs,
@@ -237,18 +255,24 @@ export async function sendReadReceiptSignal(
targetTimestamp: number,
opts: SignalRpcOpts & { type?: SignalReceiptType } = {},
): Promise<boolean> {
if (!Number.isFinite(targetTimestamp) || targetTimestamp <= 0) return false;
if (!Number.isFinite(targetTimestamp) || targetTimestamp <= 0) {
return false;
}
const { baseUrl, account } = resolveSignalRpcContext(opts);
const targetParams = buildTargetParams(parseTarget(to), {
recipient: true,
});
if (!targetParams) return false;
if (!targetParams) {
return false;
}
const params: Record<string, unknown> = {
...targetParams,
targetTimestamp,
type: opts.type ?? "read",
};
if (account) params.account = account;
if (account) {
params.account = account;
}
await signalRpcRequest("sendReceipt", params, {
baseUrl,
timeoutMs: opts.timeoutMs,