litellm/ui/litellm-dashboard/scripts/lint-budget-lib.mjs
Yuneng Jiang 7cdf42d770
chore(ui): remove eslint-metrics.json lint-count snapshot
The eslint-metrics.json snapshot duplicated the violation counts already
enforced by eslint-budgets.json. Keeping it current added a CI drift check,
a pre-commit regenerate-and-flag step, and a standalone npm run lint:metrics
script, none of which caught anything the budget gate did not, yet all of
which failed noisily whenever the snapshot went stale. This drops the file
and that machinery while leaving eslint-budgets.json as the actual ratchet
gate
2026-07-11 11:54:42 -07:00

15 lines
401 B
JavaScript

export function countBudgetViolations(report, budgets) {
const counts = {};
for (const file of report) {
for (const message of file.messages) {
if (message.ruleId in budgets) {
counts[message.ruleId] = (counts[message.ruleId] || 0) + 1;
}
}
}
return Object.fromEntries(
Object.keys(budgets)
.sort()
.map((rule) => [rule, counts[rule] || 0]),
);
}