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.
This commit is contained in:
Yuneng Jiang 2026-07-03 14:35:23 -07:00
parent 5f4b9ad51c
commit 76a9f7b5f3
No known key found for this signature in database
4 changed files with 7 additions and 1 deletions

View file

@ -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 }
}

View file

@ -1,5 +1,6 @@
{
"@typescript-eslint/no-explicit-any": 1991,
"complexity": 128,
"max-depth": 59
"max-depth": 59,
"no-console": 486
}

View file

@ -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",

View file

@ -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: {