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

@@ -12,14 +12,22 @@ import { renderTable } from "../terminal/table.js";
function parseLimit(value: unknown): number | null {
if (typeof value === "number" && Number.isFinite(value)) {
if (value <= 0) return null;
if (value <= 0) {
return null;
}
return Math.floor(value);
}
if (typeof value !== "string") return null;
if (typeof value !== "string") {
return null;
}
const raw = value.trim();
if (!raw) return null;
if (!raw) {
return null;
}
const parsed = Number.parseInt(raw, 10);
if (!Number.isFinite(parsed) || parsed <= 0) return null;
if (!Number.isFinite(parsed) || parsed <= 0) {
return null;
}
return parsed;
}
@@ -60,7 +68,9 @@ export function registerDirectoryCli(program: Command) {
});
const channelId = selection.channel;
const plugin = getChannelPlugin(channelId);
if (!plugin) throw new Error(`Unsupported channel: ${String(channelId)}`);
if (!plugin) {
throw new Error(`Unsupported channel: ${String(channelId)}`);
}
const accountId = opts.account?.trim() || resolveChannelDefaultAccountId({ plugin, cfg });
return { cfg, channelId, accountId, plugin };
};
@@ -73,7 +83,9 @@ export function registerDirectoryCli(program: Command) {
account: opts.account as string | undefined,
});
const fn = plugin.directory?.self;
if (!fn) throw new Error(`Channel ${channelId} does not support directory self`);
if (!fn) {
throw new Error(`Channel ${channelId} does not support directory self`);
}
const result = await fn({ cfg, accountId, runtime: defaultRuntime });
if (opts.json) {
defaultRuntime.log(JSON.stringify(result, null, 2));
@@ -113,7 +125,9 @@ export function registerDirectoryCli(program: Command) {
account: opts.account as string | undefined,
});
const fn = plugin.directory?.listPeers;
if (!fn) throw new Error(`Channel ${channelId} does not support directory peers`);
if (!fn) {
throw new Error(`Channel ${channelId} does not support directory peers`);
}
const result = await fn({
cfg,
accountId,
@@ -158,7 +172,9 @@ export function registerDirectoryCli(program: Command) {
account: opts.account as string | undefined,
});
const fn = plugin.directory?.listGroups;
if (!fn) throw new Error(`Channel ${channelId} does not support directory groups`);
if (!fn) {
throw new Error(`Channel ${channelId} does not support directory groups`);
}
const result = await fn({
cfg,
accountId,
@@ -206,9 +222,13 @@ export function registerDirectoryCli(program: Command) {
account: opts.account as string | undefined,
});
const fn = plugin.directory?.listGroupMembers;
if (!fn) throw new Error(`Channel ${channelId} does not support group members listing`);
if (!fn) {
throw new Error(`Channel ${channelId} does not support group members listing`);
}
const groupId = String(opts.groupId ?? "").trim();
if (!groupId) throw new Error("Missing --group-id");
if (!groupId) {
throw new Error("Missing --group-id");
}
const result = await fn({
cfg,
accountId,