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

@@ -33,7 +33,9 @@ function normalizeBaseUrl(url: string): string {
if (!trimmed) {
throw new Error("Signal base URL is required");
}
if (/^https?:\/\//i.test(trimmed)) return trimmed.replace(/\/+$/, "");
if (/^https?:\/\//i.test(trimmed)) {
return trimmed.replace(/\/+$/, "");
}
return `http://${trimmed}`.replace(/\/+$/, "");
}
@@ -117,7 +119,9 @@ export async function streamSignalEvents(params: {
}): Promise<void> {
const baseUrl = normalizeBaseUrl(params.baseUrl);
const url = new URL(`${baseUrl}/api/v1/events`);
if (params.account) url.searchParams.set("account", params.account);
if (params.account) {
url.searchParams.set("account", params.account);
}
const fetchImpl = resolveFetch();
if (!fetchImpl) {
@@ -138,7 +142,9 @@ export async function streamSignalEvents(params: {
let currentEvent: SignalSseEvent = {};
const flushEvent = () => {
if (!currentEvent.data && !currentEvent.event && !currentEvent.id) return;
if (!currentEvent.data && !currentEvent.event && !currentEvent.id) {
return;
}
params.onEvent({
event: currentEvent.event,
data: currentEvent.data,
@@ -149,13 +155,17 @@ export async function streamSignalEvents(params: {
while (true) {
const { value, done } = await reader.read();
if (done) break;
if (done) {
break;
}
buffer += decoder.decode(value, { stream: true });
let lineEnd = buffer.indexOf("\n");
while (lineEnd !== -1) {
let line = buffer.slice(0, lineEnd);
buffer = buffer.slice(lineEnd + 1);
if (line.endsWith("\r")) line = line.slice(0, -1);
if (line.endsWith("\r")) {
line = line.slice(0, -1);
}
if (line === "") {
flushEvent();