From 76a9f7b5f3be25a2889248be249e1a448c8554de Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Fri, 3 Jul 2026 14:35:23 -0700 Subject: [PATCH 1/3] chore(ui): add no-console lint ratchet and strip console from prod builds Introduce a gradual ratchet to remove raw console.* calls from the dashboard, mirroring the existing no-explicit-any budget. The no-console eslint rule is set to warn with allow: [warn, error] so the 486 console.log/debug/info calls are tracked without force-deleting the legitimate console.error/warn error reporting in catch blocks. The count is grandfathered via eslint-budgets.json (max 486, target 0) and eslint-metrics.json, so any newly added console.log fails the budget check and follow-up PRs grind the max down toward zero. Independently, next.config strips console output from production builds via SWC removeConsole (exclude: [error]), gated on NODE_ENV=production so dev keeps full console output. This gives an immediate prod-hygiene net regardless of how long the source cleanup takes. Verified against a real production build: app-code console.log dropped from 675 to 14 in the bundle (remainder is node_modules, which the transform leaves alone), console.warn app calls stripped, console.error preserved 906 to 906. --- ui/litellm-dashboard/eslint-budgets.json | 1 + ui/litellm-dashboard/eslint-metrics.json | 3 ++- ui/litellm-dashboard/eslint.config.mjs | 1 + ui/litellm-dashboard/next.config.mjs | 3 +++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/eslint-budgets.json b/ui/litellm-dashboard/eslint-budgets.json index 2139d177512..4ba3581379f 100644 --- a/ui/litellm-dashboard/eslint-budgets.json +++ b/ui/litellm-dashboard/eslint-budgets.json @@ -1,5 +1,6 @@ { "@typescript-eslint/no-explicit-any": { "max": 2040, "target": 1500 }, + "no-console": { "max": 486, "target": 0 }, "complexity": { "max": 140, "target": 80 }, "max-depth": { "max": 70, "target": 30 } } diff --git a/ui/litellm-dashboard/eslint-metrics.json b/ui/litellm-dashboard/eslint-metrics.json index cf754a1bb75..82afa1cbaaa 100644 --- a/ui/litellm-dashboard/eslint-metrics.json +++ b/ui/litellm-dashboard/eslint-metrics.json @@ -1,5 +1,6 @@ { "@typescript-eslint/no-explicit-any": 1991, "complexity": 128, - "max-depth": 59 + "max-depth": 59, + "no-console": 486 } diff --git a/ui/litellm-dashboard/eslint.config.mjs b/ui/litellm-dashboard/eslint.config.mjs index 10caebb5196..acdd0c91309 100644 --- a/ui/litellm-dashboard/eslint.config.mjs +++ b/ui/litellm-dashboard/eslint.config.mjs @@ -17,6 +17,7 @@ const eslintConfig = [ rules: { "unused-imports/no-unused-imports": "error", "@typescript-eslint/no-explicit-any": "warn", + "no-console": ["warn", { allow: ["warn", "error"] }], "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-unused-expressions": "off", "@typescript-eslint/ban-ts-comment": "off", diff --git a/ui/litellm-dashboard/next.config.mjs b/ui/litellm-dashboard/next.config.mjs index 19a2ca298fe..9cfddfd33ca 100644 --- a/ui/litellm-dashboard/next.config.mjs +++ b/ui/litellm-dashboard/next.config.mjs @@ -7,6 +7,9 @@ const __dirname = path.dirname(__filename); const nextConfig = { output: "export", + compiler: { + removeConsole: process.env.NODE_ENV === "production" ? { exclude: ["error"] } : false, + }, // Required with output: "export" — default image optimizer runs only in server mode. // See https://nextjs.org/docs/messages/export-image-api images: { From 5b7c73a5731a4f108b184b9ab4a07e526fa9576e Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Fri, 3 Jul 2026 14:37:41 -0700 Subject: [PATCH 2/3] chore(ui): sync no-console budget to 484 after staging merge Merging litellm_internal_staging dropped 2 console.log calls (the currentUser logs removed in #32079), so the no-console budget max and metric move from 486 to 484 to match the current count. --- ui/litellm-dashboard/eslint-budgets.json | 2 +- ui/litellm-dashboard/eslint-metrics.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/eslint-budgets.json b/ui/litellm-dashboard/eslint-budgets.json index 4ba3581379f..8dedb9ac9ca 100644 --- a/ui/litellm-dashboard/eslint-budgets.json +++ b/ui/litellm-dashboard/eslint-budgets.json @@ -1,6 +1,6 @@ { "@typescript-eslint/no-explicit-any": { "max": 2040, "target": 1500 }, - "no-console": { "max": 486, "target": 0 }, + "no-console": { "max": 484, "target": 0 }, "complexity": { "max": 140, "target": 80 }, "max-depth": { "max": 70, "target": 30 } } diff --git a/ui/litellm-dashboard/eslint-metrics.json b/ui/litellm-dashboard/eslint-metrics.json index 82afa1cbaaa..d16be0d2b48 100644 --- a/ui/litellm-dashboard/eslint-metrics.json +++ b/ui/litellm-dashboard/eslint-metrics.json @@ -2,5 +2,5 @@ "@typescript-eslint/no-explicit-any": 1991, "complexity": 128, "max-depth": 59, - "no-console": 486 + "no-console": 484 } From 68d52ac251495ac53e69a75ec694d6e160558df9 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Fri, 3 Jul 2026 14:51:14 -0700 Subject: [PATCH 3/3] chore(ui): preserve console.warn in prod builds to match lint allow-list The lint rule allows console.warn (allow: [warn, error]) but removeConsole only excluded error, so approved console.warn calls were silently dropped from production bundles. Add warn to the exclude list so the prod strip and the lint allow-list agree; only console.log/debug/info are stripped now, warn and error both survive (verified: warn 85 to 85, error 906 to 906, log 675 to 14). --- ui/litellm-dashboard/next.config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/next.config.mjs b/ui/litellm-dashboard/next.config.mjs index 9cfddfd33ca..876df2b49cf 100644 --- a/ui/litellm-dashboard/next.config.mjs +++ b/ui/litellm-dashboard/next.config.mjs @@ -8,7 +8,7 @@ const __dirname = path.dirname(__filename); const nextConfig = { output: "export", compiler: { - removeConsole: process.env.NODE_ENV === "production" ? { exclude: ["error"] } : false, + removeConsole: process.env.NODE_ENV === "production" ? { exclude: ["error", "warn"] } : false, }, // Required with output: "export" — default image optimizer runs only in server mode. // See https://nextjs.org/docs/messages/export-image-api