refactor(lint): enable map spread rule

This commit is contained in:
Peter Steinberger
2026-04-18 19:53:02 +01:00
parent 0c245c35c5
commit 4fa961d4f1
73 changed files with 352 additions and 344 deletions

View File

@@ -36,10 +36,9 @@ export function buildArceeCatalogModels(): NonNullable<ModelProviderConfig["mode
}
export function buildArceeOpenRouterCatalogModels(): NonNullable<ModelProviderConfig["models"]> {
return buildArceeCatalogModels().map((model) => ({
...model,
id: toArceeOpenRouterModelId(model.id),
}));
return buildArceeCatalogModels().map((model) =>
Object.assign({}, model, { id: toArceeOpenRouterModelId(model.id) }),
);
}
export function buildArceeProvider(): ModelProviderConfig {

View File

@@ -25,10 +25,11 @@ export const listDiscordDirectoryPeersFromConfig = createResolvedDirectoryEntrie
resolveAccount: (cfg, accountId) => resolveDiscordDirectoryConfigAccount(cfg, accountId),
resolveSources: (account) => {
const allowFrom = account.config.allowFrom ?? account.config.dm?.allowFrom ?? [];
const guildUsers = Object.values(account.config.guilds ?? {}).flatMap((guild) => [
...(guild.users ?? []),
...Object.values(guild.channels ?? {}).flatMap((channel) => channel.users ?? []),
]);
const guildUsers = Object.values(account.config.guilds ?? {}).flatMap((guild) =>
(guild.users ?? []).concat(
Object.values(guild.channels ?? {}).flatMap((channel) => channel.users ?? []),
),
);
return [allowFrom, Object.keys(account.config.dms ?? {}), guildUsers];
},
normalizeId: (raw) => {

View File

@@ -110,7 +110,7 @@ function cleanBlocksForInsert(blocks: FeishuDocxBlock[]): {
.map((block) => {
if (block.block_type === 31 && block.table?.merge_info) {
const { merge_info: _merge_info, ...tableRest } = block.table;
return { ...block, table: tableRest };
return Object.assign({}, block, { table: tableRest });
}
return block;
});

View File

@@ -141,7 +141,7 @@ function normalizeProviderModels(
return model;
}
mutated = true;
return { ...model, id: nextId };
return Object.assign({}, model, { id: nextId });
});
return mutated ? { ...provider, models: nextModels } : provider;

View File

@@ -120,10 +120,9 @@ async function runGeminiSearch(params: {
for (let index = 0; index < rawCitations.length; index += 10) {
const batch = rawCitations.slice(index, index + 10);
const resolved = await Promise.all(
batch.map(async (citation) => ({
...citation,
url: await resolveCitationRedirectUrl(citation.url),
})),
batch.map(async (citation) =>
Object.assign({}, citation, { url: await resolveCitationRedirectUrl(citation.url) }),
),
);
citations.push(...resolved);
}

View File

@@ -279,7 +279,7 @@ export const ircPlugin: ChannelPlugin<ResolvedIrcAccount, IrcProbe> = createChat
listPeers: async (params) => listIrcDirectoryPeersFromConfig(params),
listGroups: async (params) => {
const entries = await listIrcDirectoryGroupsFromConfig(params);
return entries.map((entry) => ({ ...entry, name: entry.id }));
return entries.map((entry) => Object.assign({}, entry, { name: entry.id }));
},
}),
status: createComputedAccountStatusAdapter<ResolvedIrcAccount, IrcProbe>({

View File

@@ -817,10 +817,11 @@ export async function prepareLmstudioDynamicModels(
headers,
quiet: true,
});
return discoveredModels.map((model) => ({
...model,
provider: PROVIDER_ID,
api: ctx.providerConfig?.api ?? "openai-completions",
baseUrl,
}));
return discoveredModels.map((model) =>
Object.assign({}, model, {
provider: PROVIDER_ID,
api: ctx.providerConfig?.api ?? `openai-completions`,
baseUrl,
}),
);
}

View File

@@ -364,7 +364,9 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount, MatrixProbe> =
return entries.map((entry) => {
const raw = entry.id.startsWith("user:") ? entry.id.slice("user:".length) : entry.id;
const incomplete = !raw.startsWith("@") || !raw.includes(":");
return incomplete ? { ...entry, name: "incomplete id; expected @user:server" } : entry;
return incomplete
? Object.assign({}, entry, { name: `incomplete id; expected @user:server` })
: entry;
});
},
listGroups: async (params) => await listMatrixDirectoryGroupsFromConfig(params),

View File

@@ -840,35 +840,45 @@ function buildAgentDigest(params: {
.toSorted((left, right) => left.relativePath.localeCompare(right.relativePath))
.map((page) => {
const pageFreshness = assessPageFreshness(page);
return {
...(page.id ? { id: page.id } : {}),
title: page.title,
kind: page.kind,
path: page.relativePath,
sourceIds: [...page.sourceIds],
questions: [...page.questions],
contradictions: [...page.contradictions],
...(typeof page.confidence === "number" ? { confidence: page.confidence } : {}),
freshnessLevel: pageFreshness.level,
...(pageFreshness.lastTouchedAt ? { lastTouchedAt: pageFreshness.lastTouchedAt } : {}),
claimCount: page.claims.length,
topClaims: sortClaims(page)
.slice(0, 5)
.map((claim) => {
const freshness = assessClaimFreshness({ page, claim });
return {
...(claim.id ? { id: claim.id } : {}),
text: claim.text,
status: normalizeClaimStatus(claim.status),
...(typeof claim.confidence === "number" ? { confidence: claim.confidence } : {}),
evidenceCount: claim.evidence.length,
missingEvidence: claim.evidence.length === 0,
evidence: [...claim.evidence],
freshnessLevel: freshness.level,
...(freshness.lastTouchedAt ? { lastTouchedAt: freshness.lastTouchedAt } : {}),
};
}),
};
return Object.assign(
{},
page.id ? { id: page.id } : {},
{
title: page.title,
kind: page.kind,
path: page.relativePath,
sourceIds: [...page.sourceIds],
questions: [...page.questions],
contradictions: [...page.contradictions],
},
typeof page.confidence === "number" ? { confidence: page.confidence } : {},
{ freshnessLevel: pageFreshness.level },
pageFreshness.lastTouchedAt ? { lastTouchedAt: pageFreshness.lastTouchedAt } : {},
{
claimCount: page.claims.length,
topClaims: sortClaims(page)
.slice(0, 5)
.map((claim) => {
const freshness = assessClaimFreshness({ page, claim });
return Object.assign(
{},
claim.id ? { id: claim.id } : {},
{
text: claim.text,
status: normalizeClaimStatus(claim.status),
},
typeof claim.confidence === "number" ? { confidence: claim.confidence } : {},
{
evidenceCount: claim.evidence.length,
missingEvidence: claim.evidence.length === 0,
evidence: [...claim.evidence],
freshnessLevel: freshness.level,
},
freshness.lastTouchedAt ? { lastTouchedAt: freshness.lastTouchedAt } : {},
);
}),
},
);
});
return {
pageCounts: params.pageCounts,

View File

@@ -93,5 +93,7 @@ export function buildMistralModelDefinition(): ModelDefinitionConfig {
}
export function buildMistralCatalogModels(): ModelDefinitionConfig[] {
return MISTRAL_MODEL_CATALOG.map((model) => ({ ...model, input: [...model.input] }));
return MISTRAL_MODEL_CATALOG.map((model) =>
Object.assign({}, model, { input: [...model.input] }),
);
}

View File

@@ -75,6 +75,8 @@ export function buildMoonshotProvider(): ModelProviderConfig {
return {
baseUrl: MOONSHOT_BASE_URL,
api: "openai-completions",
models: MOONSHOT_MODEL_CATALOG.map((model) => ({ ...model, input: [...model.input] })),
models: MOONSHOT_MODEL_CATALOG.map((model) =>
Object.assign({}, model, { input: [...model.input] }),
),
};
}

View File

@@ -194,11 +194,10 @@ export async function enrichOllamaModelsWithContext(
const batchResults = await Promise.all(
batch.map(async (model) => {
const showInfo = await queryOllamaModelShowInfoCached(apiBase, model);
return {
...model,
return Object.assign({}, model, {
contextWindow: showInfo.contextWindow,
capabilities: showInfo.capabilities,
};
});
}),
);
enriched.push(...batchResults);

View File

@@ -85,10 +85,10 @@ export function buildQaBusSnapshot(params: {
}): QaBusStateSnapshot {
return {
cursor: params.cursor,
conversations: Array.from(params.conversations.values()).map((conversation) => ({
...conversation,
})),
threads: Array.from(params.threads.values()).map((thread) => ({ ...thread })),
conversations: Array.from(params.conversations.values()).map((conversation) =>
Object.assign({}, conversation),
),
threads: Array.from(params.threads.values()).map((thread) => Object.assign({}, thread)),
messages: Array.from(params.messages.values()).map((message) => cloneMessage(message)),
events: params.events.map((event) => cloneEvent(event)),
};

View File

@@ -651,10 +651,10 @@ export async function runQaCharacterEval(params: QaCharacterEvalParams) {
timeoutMs: judgeTimeoutMs,
});
rankings = parseJudgeReply(rawReply, new Set(judgePrompt.labelToModel.keys())).map(
(ranking) => ({
...ranking,
model: judgePrompt.labelToModel.get(ranking.model) ?? ranking.model,
}),
(ranking) =>
Object.assign({}, ranking, {
model: judgePrompt.labelToModel.get(ranking.model) ?? ranking.model,
}),
);
} catch (error) {
judgeError = formatErrorMessage(error);

View File

@@ -6,7 +6,7 @@ export function buildQwenProvider(params?: { baseUrl?: string }): ModelProviderC
return {
baseUrl,
api: "openai-completions",
models: buildQwenModelCatalogForBaseUrl(baseUrl).map((model) => ({ ...model })),
models: buildQwenModelCatalogForBaseUrl(baseUrl).map((model) => Object.assign({}, model)),
};
}

View File

@@ -446,7 +446,7 @@ export async function handleSlackAction(
(pin.message as { ts?: unknown }).ts,
)
: pin.message;
return message ? { ...pin, message } : pin;
return message ? Object.assign({}, pin, { message }) : pin;
});
return jsonResult({ ok: true, pins: normalizedPins });
}

View File

@@ -70,7 +70,7 @@ function fitTelegramCommandsWithinTextBudget(
const description = truncateTelegramCommandText(command.description, descriptionCap);
if (description !== command.description) {
descriptionTrimmed = true;
return { ...command, description };
return Object.assign({}, command, { description });
}
return command;
});

View File

@@ -86,7 +86,7 @@ export function buildVydraSpeechProvider(): SpeechProviderPlugin {
models: [DEFAULT_VYDRA_SPEECH_MODEL],
voices: VYDRA_SPEECH_VOICES.map((voice) => voice.id),
resolveConfig: ({ rawConfig }) => normalizeVydraSpeechConfig(rawConfig),
listVoices: async () => VYDRA_SPEECH_VOICES.map((voice) => ({ ...voice })),
listVoices: async () => VYDRA_SPEECH_VOICES.map((voice) => Object.assign({}, voice)),
isConfigured: ({ providerConfig }) =>
Boolean(readVydraSpeechConfig(providerConfig).apiKey || process.env.VYDRA_API_KEY),
synthesize: async (req) => {

View File

@@ -169,10 +169,9 @@ describe("web auto-reply", () => {
const sharedRaw = crypto.randomBytes(width * height * 3);
const renderedFormats = await Promise.all(
formats.map(async (fmt) => ({
...fmt,
image: await fmt.make(sharedRaw, { width, height }),
})),
formats.map(async (fmt) =>
Object.assign({}, fmt, { image: await fmt.make(sharedRaw, { width, height }) }),
),
);
await withMediaCap(SMALL_MEDIA_CAP_MB, async () => {