fix(config): apply filtered doctor compat at read time

This commit is contained in:
Vincent Koc
2026-04-06 20:45:07 +01:00
parent 78639eff76
commit 7d54f2a3c2
11 changed files with 252 additions and 50 deletions

View File

@@ -1,9 +1,27 @@
import type { LegacyConfigRule } from "../../config/legacy.shared.js";
import { iterateBootstrapChannelPlugins } from "./bootstrap-registry.js";
import { getBootstrapChannelPlugin } from "./bootstrap-registry.js";
import type { ChannelId } from "./types.js";
export function collectChannelLegacyConfigRules(): LegacyConfigRule[] {
function collectConfiguredChannelIds(raw: unknown): ChannelId[] {
if (!raw || typeof raw !== "object") {
return [];
}
const channels = (raw as { channels?: unknown }).channels;
if (!channels || typeof channels !== "object" || Array.isArray(channels)) {
return [];
}
return Object.keys(channels)
.filter((channelId) => channelId !== "defaults")
.map((channelId) => channelId as ChannelId);
}
export function collectChannelLegacyConfigRules(raw?: unknown): LegacyConfigRule[] {
const rules: LegacyConfigRule[] = [];
for (const plugin of iterateBootstrapChannelPlugins()) {
for (const channelId of collectConfiguredChannelIds(raw)) {
const plugin = getBootstrapChannelPlugin(channelId);
if (!plugin) {
continue;
}
rules.push(...(plugin.doctor?.legacyConfigRules ?? []));
}
return rules;