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

@@ -89,10 +89,14 @@ async function promptRemovalAccountId(params: {
}): Promise<string> {
const { cfg, prompter, label, channel } = params;
const plugin = getChannelPlugin(channel);
if (!plugin) return DEFAULT_ACCOUNT_ID;
if (!plugin) {
return DEFAULT_ACCOUNT_ID;
}
const accountIds = plugin.config.listAccountIds(cfg).filter(Boolean);
const defaultAccountId = resolveChannelDefaultAccountId({ plugin, cfg, accountIds });
if (accountIds.length <= 1) return defaultAccountId;
if (accountIds.length <= 1) {
return defaultAccountId;
}
const selected = await prompter.select({
message: `${label} account`,
options: accountIds.map((accountId) => ({
@@ -204,7 +208,9 @@ function resolveQuickstartDefault(
): ChannelChoice | undefined {
let best: { channel: ChannelChoice; score: number } | null = null;
for (const [channel, status] of statusByChannel) {
if (status.quickstartScore == null) continue;
if (status.quickstartScore == null) {
continue;
}
if (!best || status.quickstartScore > best.score) {
best = { channel, score: status.quickstartScore };
}
@@ -222,13 +228,17 @@ async function maybeConfigureDmPolicies(params: {
const dmPolicies = selection
.map((channel) => getChannelOnboardingAdapter(channel)?.dmPolicy)
.filter(Boolean) as ChannelOnboardingDmPolicy[];
if (dmPolicies.length === 0) return params.cfg;
if (dmPolicies.length === 0) {
return params.cfg;
}
const wants = await prompter.confirm({
message: "Configure DM access policies now? (default: pairing)",
initialValue: false,
});
if (!wants) return params.cfg;
if (!wants) {
return params.cfg;
}
let cfg = params.cfg;
const selectPolicy = async (policy: ChannelOnboardingDmPolicy) => {
@@ -301,7 +311,9 @@ export async function setupChannels(
message: "Configure chat channels now?",
initialValue: true,
});
if (!shouldConfigure) return cfg;
if (!shouldConfigure) {
return cfg;
}
const corePrimer = listChatChannels().map((meta) => ({
id: meta.id,
@@ -342,14 +354,20 @@ export async function setupChannels(
const selection: ChannelChoice[] = [];
const addSelection = (channel: ChannelChoice) => {
if (!selection.includes(channel)) selection.push(channel);
if (!selection.includes(channel)) {
selection.push(channel);
}
};
const resolveDisabledHint = (channel: ChannelChoice): string | undefined => {
const plugin = getChannelPlugin(channel);
if (!plugin) {
if (next.plugins?.entries?.[channel]?.enabled === false) return "plugin disabled";
if (next.plugins?.enabled === false) return "plugins disabled";
if (next.plugins?.entries?.[channel]?.enabled === false) {
return "plugin disabled";
}
if (next.plugins?.enabled === false) {
return "plugins disabled";
}
return undefined;
}
const accountId = resolveChannelDefaultAccountId({ plugin, cfg: next });
@@ -418,13 +436,17 @@ export async function setupChannels(
const refreshStatus = async (channel: ChannelChoice) => {
const adapter = getChannelOnboardingAdapter(channel);
if (!adapter) return;
if (!adapter) {
return;
}
const status = await adapter.getStatus({ cfg: next, options, accountOverrides });
statusByChannel.set(channel, status);
};
const ensureBundledPluginEnabled = async (channel: ChannelChoice): Promise<boolean> => {
if (getChannelPlugin(channel)) return true;
if (getChannelPlugin(channel)) {
return true;
}
const result = enablePluginInConfig(next, channel);
next = result.config;
if (!result.enabled) {
@@ -485,12 +507,16 @@ export async function setupChannels(
supportsDelete,
});
if (action === "skip") return;
if (action === "skip") {
return;
}
if (action === "update") {
await configureChannel(channel);
return;
}
if (!options?.allowDisable) return;
if (!options?.allowDisable) {
return;
}
if (action === "delete" && !supportsDelete) {
await prompter.note(`${label} does not support deleting config entries.`, "Remove channel");
@@ -519,7 +545,9 @@ export async function setupChannels(
message: `Delete ${label} account "${accountLabel}"?`,
initialValue: false,
});
if (!confirmed) return;
if (!confirmed) {
return;
}
if (plugin?.config.deleteAccount) {
next = plugin.config.deleteAccount({ cfg: next, accountId: resolvedAccountId });
}
@@ -552,7 +580,9 @@ export async function setupChannels(
workspaceDir,
});
next = result.cfg;
if (!result.installed) return;
if (!result.installed) {
return;
}
reloadOnboardingPluginRegistry({
cfg: next,
runtime,
@@ -561,7 +591,9 @@ export async function setupChannels(
await refreshStatus(channel);
} else {
const enabled = await ensureBundledPluginEnabled(channel);
if (!enabled) return;
if (!enabled) {
return;
}
}
const plugin = getChannelPlugin(channel);
@@ -609,7 +641,9 @@ export async function setupChannels(
],
initialValue,
})) as ChannelChoice | typeof doneValue;
if (choice === doneValue) break;
if (choice === doneValue) {
break;
}
await handleChannelChoice(choice);
}
}