No console.log in production code
Why it matters
Debug console.log statements left in production code expose internal data structures, user data, and system internals in the browser console and server logs — visible to anyone who opens DevTools or has log access. ISO 25010:2011 §6.5.2 classifies this as a maintainability defect. Beyond the information exposure risk, uncontrolled log output fills log aggregators with noise, makes filtering for real errors harder, and signals to engineers that the codebase lacks basic hygiene standards.
Severity rationale
Low because console.log leakage is primarily a hygiene and information-exposure issue rather than an immediate exploitable vulnerability, but it degrades log quality and can expose sensitive internal state.
Remediation
Remove debug console.log statements from production source files. For intentional production logging, use a level-aware logger so output can be controlled by environment:
// src/lib/logger.ts
const isDev = process.env.NODE_ENV === 'development'
export const logger = {
info: (msg: string, data?: unknown) => {
if (isDev) console.info('[info]', msg, data)
},
error: (msg: string, error?: unknown) => {
console.error('[error]', msg, error) // always log errors
},
}
Enforce via ESLint so it is caught in CI:
{ "rules": { "no-console": ["error", { "allow": ["error", "warn"] }] } }
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Code Quality Essentials Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability.analysability — Maintainability — Analysability
Taxons
History
- 2026-04-18·v1.0.0·Initial import from code-quality-essentials·automated