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

@@ -21,7 +21,7 @@ function listConfiguredAccountIds(cfg: OpenClawConfig): string[] {
export function listDiscordAccountIds(cfg: OpenClawConfig): string[] {
const ids = listConfiguredAccountIds(cfg);
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
return ids.sort((a, b) => a.localeCompare(b));
return ids.toSorted((a, b) => a.localeCompare(b));
}
export function resolveDefaultDiscordAccountId(cfg: OpenClawConfig): string {

View File

@@ -49,7 +49,7 @@ function listConfiguredGuildChannelKeys(
ids.add(channelId);
}
}
return [...ids].sort((a, b) => a.localeCompare(b));
return [...ids].toSorted((a, b) => a.localeCompare(b));
}
export function collectDiscordAuditChannelIds(params: {

View File

@@ -17,9 +17,7 @@ vi.mock("@buape/carbon", () => ({
MessageReactionAddListener: class {},
MessageReactionRemoveListener: class {},
PresenceUpdateListener: class {},
Row: class {
constructor(_components: unknown[]) {}
},
Row: class {},
}));
vi.mock("../auto-reply/dispatch.js", async (importOriginal) => {

View File

@@ -154,7 +154,7 @@ export function resolveDiscordCommandAuthorized(params: {
}
export function resolveDiscordGuildEntry(params: {
guild?: Guild<true> | Guild<false> | null;
guild?: Guild<true> | Guild | null;
guildEntries?: Record<string, DiscordGuildEntryResolved>;
}): DiscordGuildEntryResolved | null {
const guild = params.guild;

View File

@@ -77,11 +77,7 @@ async function listGuildChannels(
fetcher: typeof fetch,
guildId: string,
): Promise<DiscordChannelSummary[]> {
const raw = (await fetchDiscord(
`/guilds/${guildId}/channels`,
token,
fetcher,
)) as RESTGetAPIGuildChannelsResult;
const raw = await fetchDiscord(`/guilds/${guildId}/channels`, token, fetcher);
return raw
.filter((channel) => Boolean(channel.id) && "name" in channel)
.map((channel) => {
@@ -105,11 +101,7 @@ async function fetchChannel(
fetcher: typeof fetch,
channelId: string,
): Promise<DiscordChannelSummary | null> {
const raw = (await fetchDiscord(
`/channels/${channelId}`,
token,
fetcher,
)) as RESTGetAPIChannelResult;
const raw = await fetchDiscord(`/channels/${channelId}`, token, fetcher);
if (!raw || !("guild_id" in raw)) return null;
return {
id: raw.id,

View File

@@ -10,7 +10,7 @@ import { normalizeDiscordToken } from "./token.js";
const PERMISSION_ENTRIES = Object.entries(PermissionFlagsBits).filter(
([, value]) => typeof value === "bigint",
) as Array<[string, bigint]>;
);
type DiscordClientOpts = {
token?: string;
@@ -60,7 +60,7 @@ function removePermissionBits(base: bigint, deny?: string) {
function bitfieldToPermissions(bitfield: bigint) {
return PERMISSION_ENTRIES.filter(([, value]) => (bitfield & value) === value)
.map(([name]) => name)
.sort();
.toSorted();
}
export function isThreadChannelType(channelType?: number) {