mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
* feat(ui): track frontend lint counts in a committed snapshot Persist the eslint budget-rule counts (no-explicit-any, complexity, max-depth) to eslint-metrics.json so the trend is queryable straight from git history and can later feed a dashboard. A CI drift check regenerated from the same lint report keeps the snapshot honest, so a PR that shifts a count has to run npm run lint:metrics and commit it * fix(ui): harden lint-metrics drift check and eslint failure handling Make the drift comparison symmetric over the union of committed and actual keys so a phantom rule left in eslint-metrics.json (for example after a rule is dropped from eslint-budgets.json) is caught instead of silently passing. Only swallow eslint's lint-errors exit code in the generator and rethrow anything else, so a fatal eslint failure surfaces its real output rather than a confusing ENOENT on the missing report
22 lines
710 B
JavaScript
22 lines
710 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]),
|
|
);
|
|
}
|
|
|
|
export function findDrift(committed, actual) {
|
|
const rules = [...new Set([...Object.keys(actual), ...Object.keys(committed)])].sort();
|
|
return rules
|
|
.filter((rule) => committed[rule] !== actual[rule])
|
|
.map((rule) => ({ rule, committed: committed[rule] ?? null, actual: actual[rule] ?? null }));
|
|
}
|