chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.

This commit is contained in:
cpojer
2026-01-31 16:03:28 +09:00
parent 481f696a87
commit 15792b153f
292 changed files with 643 additions and 699 deletions

View File

@@ -347,7 +347,7 @@ export async function tryHandleDiscordMessageActionGuildAdmin(params: {
const deleteMessageDays = readNumberParam(actionParams, "deleteDays", {
integer: true,
});
const discordAction = action as "timeout" | "kick" | "ban";
const discordAction = action;
return await handleDiscordAction(
{
action: discordAction,

View File

@@ -268,7 +268,7 @@ export function listChannelPluginCatalogEntries(
return Array.from(resolved.values())
.map(({ entry }) => entry)
.sort((a, b) => {
.toSorted((a, b) => {
const orderA = a.meta.order ?? 999;
const orderB = b.meta.order ?? 999;
if (orderA !== orderB) return orderA - orderB;

View File

@@ -30,7 +30,7 @@ export function setAccountEnabledInConfigSection(params: {
} as OpenClawConfig;
}
const baseAccounts = (base?.accounts ?? {}) as Record<string, Record<string, unknown>>;
const baseAccounts = base?.accounts ?? {};
const existing = baseAccounts[accountKey] ?? {};
return {
...params.cfg,

View File

@@ -30,7 +30,7 @@ describe("directory (config-backed)", () => {
query: null,
limit: null,
});
expect(peers?.map((e) => e.id).sort()).toEqual([
expect(peers?.map((e) => e.id).toSorted()).toEqual([
"user:u123",
"user:u234",
"user:u777",
@@ -73,7 +73,7 @@ describe("directory (config-backed)", () => {
query: null,
limit: null,
});
expect(peers?.map((e) => e.id).sort()).toEqual(["user:111", "user:12345", "user:222"]);
expect(peers?.map((e) => e.id).toSorted()).toEqual(["user:111", "user:12345", "user:222"]);
const groups = await listDiscordDirectoryGroupsFromConfig({
cfg,
@@ -81,7 +81,7 @@ describe("directory (config-backed)", () => {
query: null,
limit: null,
});
expect(groups?.map((e) => e.id).sort()).toEqual(["channel:555", "channel:666"]);
expect(groups?.map((e) => e.id).toSorted()).toEqual(["channel:555", "channel:666"]);
});
it("lists Telegram peers/groups from config", async () => {
@@ -102,7 +102,7 @@ describe("directory (config-backed)", () => {
query: null,
limit: null,
});
expect(peers?.map((e) => e.id).sort()).toEqual(["123", "456", "@alice", "@bob"]);
expect(peers?.map((e) => e.id).toSorted()).toEqual(["123", "456", "@alice", "@bob"]);
const groups = await listTelegramDirectoryGroupsFromConfig({
cfg,

View File

@@ -28,7 +28,7 @@ function dedupeChannels(channels: ChannelPlugin[]): ChannelPlugin[] {
export function listChannelPlugins(): ChannelPlugin[] {
const combined = dedupeChannels(listPluginChannels());
return combined.sort((a, b) => {
return combined.toSorted((a, b) => {
const indexA = CHAT_CHANNEL_ORDER.indexOf(a.id as ChatChannelId);
const indexB = CHAT_CHANNEL_ORDER.indexOf(b.id as ChatChannelId);
const orderA = a.meta.order ?? (indexA === -1 ? 999 : indexA);

View File

@@ -33,11 +33,11 @@ export async function promptChannelAccessPolicy(params: {
options.push({ value: "disabled", label: "Disabled (block all channels)" });
}
const initialValue = params.currentPolicy ?? "allowlist";
return (await params.prompter.select({
return await params.prompter.select({
message: `${params.label} access`,
options,
initialValue,
})) as ChannelAccessPolicy;
});
}
export async function promptChannelAllowlist(params: {

View File

@@ -4,7 +4,7 @@ import type { PromptAccountId, PromptAccountIdParams } from "../onboarding-types
export const promptAccountId: PromptAccountId = async (params: PromptAccountIdParams) => {
const existingIds = params.listAccountIds(params.cfg);
const initial = params.currentId?.trim() || params.defaultAccountId || DEFAULT_ACCOUNT_ID;
const choice = (await params.prompter.select({
const choice = await params.prompter.select({
message: `${params.label} account`,
options: [
...existingIds.map((id) => ({
@@ -14,7 +14,7 @@ export const promptAccountId: PromptAccountId = async (params: PromptAccountIdPa
{ value: "__new__", label: "Add a new account" },
],
initialValue: initial,
})) as string;
});
if (choice !== "__new__") return normalizeAccountId(choice);

View File

@@ -107,13 +107,13 @@ async function promptWhatsAppAllowFrom(
"WhatsApp DM access",
);
const phoneMode = (await prompter.select({
const phoneMode = await prompter.select({
message: "WhatsApp phone setup",
options: [
{ value: "personal", label: "This is my personal phone number" },
{ value: "separate", label: "Separate phone just for OpenClaw" },
],
})) as "personal" | "separate";
});
if (phoneMode === "personal") {
await prompter.note(
@@ -187,13 +187,13 @@ async function promptWhatsAppAllowFrom(
{ value: "list", label: "Set allowFrom to specific numbers" },
] as const);
const mode = (await prompter.select({
const mode = await prompter.select({
message: "WhatsApp allowFrom (optional pre-allowlist)",
options: allowOptions.map((opt) => ({
value: opt.value,
label: opt.label,
})),
})) as (typeof allowOptions)[number]["value"];
});
if (mode === "keep") {
// Keep allowFrom as-is.

View File

@@ -27,7 +27,7 @@ function getSessionRecipients(cfg: OpenClawConfig) {
updatedAt: entry?.updatedAt ?? 0,
}))
.filter(({ to }) => to.length > 1)
.sort((a, b) => b.updatedAt - a.updatedAt);
.toSorted((a, b) => b.updatedAt - a.updatedAt);
// Dedupe while preserving recency ordering.
const seen = new Set<string>();