litellm/ui/litellm-dashboard/scripts/check-lint-budgets.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

22 lines
871 B
JavaScript

import { readFileSync } from "fs";
import { countBudgetViolations } from "./lint-budget-lib.mjs";
const [reportPath, budgetsPath] = process.argv.slice(2);
const report = JSON.parse(readFileSync(reportPath, "utf8"));
const budgets = JSON.parse(readFileSync(budgetsPath, "utf8"));
const counts = countBudgetViolations(report, budgets);
let failed = false;
for (const [rule, { max, target }] of Object.entries(budgets)) {
const count = counts[rule];
const note = count > max ? "OVER BUDGET" : count <= target ? "at target" : `${max - count} of headroom`;
console.log(`${rule}: ${count} | max: ${max} | target: ${target} | ${note}`);
if (count > max) {
console.error(
`::error::${rule} budget exceeded (${count} > ${max}). Reduce usage; lower max in eslint-budgets.json as the count drops.`,
);
failed = true;
}
}
process.exit(failed ? 1 : 0);