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

@@ -45,7 +45,9 @@ type DiscordClientOpts = {
function resolveToken(params: { explicit?: string; accountId: string; fallbackToken?: string }) {
const explicit = normalizeDiscordToken(params.explicit);
if (explicit) return explicit;
if (explicit) {
return explicit;
}
const fallback = normalizeDiscordToken(params.fallbackToken);
if (!fallback) {
throw new Error(
@@ -183,14 +185,18 @@ function normalizeDiscordPollInput(input: PollInput): RESTAPIPoll {
}
function getDiscordErrorCode(err: unknown) {
if (!err || typeof err !== "object") return undefined;
if (!err || typeof err !== "object") {
return undefined;
}
const candidate =
"code" in err && err.code !== undefined
? err.code
: "rawError" in err && err.rawError && typeof err.rawError === "object"
? (err.rawError as { code?: unknown }).code
: undefined;
if (typeof candidate === "number") return candidate;
if (typeof candidate === "number") {
return candidate;
}
if (typeof candidate === "string" && /^\d+$/.test(candidate)) {
return Number(candidate);
}
@@ -206,7 +212,9 @@ async function buildDiscordSendError(
hasMedia: boolean;
},
) {
if (err instanceof DiscordSendError) return err;
if (err instanceof DiscordSendError) {
return err;
}
const code = getDiscordErrorCode(err);
if (code === DISCORD_CANNOT_DM) {
return new DiscordSendError(
@@ -214,7 +222,9 @@ async function buildDiscordSendError(
{ kind: "dm-blocked" },
);
}
if (code !== DISCORD_MISSING_PERMISSIONS) return err;
if (code !== DISCORD_MISSING_PERMISSIONS) {
return err;
}
let missing: string[] = [];
try {
@@ -288,7 +298,9 @@ async function sendDiscordText(
maxLines: maxLinesPerMessage,
chunkMode,
});
if (!chunks.length && text) chunks.push(text);
if (!chunks.length && text) {
chunks.push(text);
}
if (chunks.length === 1) {
const res = (await request(
() =>
@@ -344,7 +356,9 @@ async function sendDiscordMedia(
chunkMode,
})
: [];
if (!chunks.length && text) chunks.push(text);
if (!chunks.length && text) {
chunks.push(text);
}
const caption = chunks[0] ?? "";
const messageReference = replyTo ? { message_id: replyTo, fail_if_not_exists: false } : undefined;
const res = (await request(
@@ -365,7 +379,9 @@ async function sendDiscordMedia(
"media",
)) as { id: string; channel_id: string };
for (const chunk of chunks.slice(1)) {
if (!chunk.trim()) continue;
if (!chunk.trim()) {
continue;
}
await sendDiscordText(
rest,
channelId,