Skip to content

console.log(...) calls are typically debugging leftovers. Route logs through a dedicated logger or strip them in CI.

By default only console.log is flagged. console.warn and console.error are not flagged by default — error logging in catch blocks is legitimate and should not produce false positives.

Bare-identifier match only — aliased calls (const c = console; c.log(...)) escape detection until the type-aware pass.

ts
// flagged by default
console.log("debug:", value);
ts
// NOT flagged by default — intentional error logging
try {
  riskyOp();
} catch (err) {
  console.error("operation failed:", err);
}
ts
// fix: route through a logger that strips in production
import { logger } from "./logger";
logger.debug("debug:", value);
logger.error("failed:", err);

Options

methods (string[], default: ["log"])

The list of console methods to flag. Defaults to ["log"] only.

To restore the broad pre-v0.4 behaviour and flag console.log, console.warn, and console.error:

toml
[checks."Warning.NoConsoleLog"]
methods = ["log", "warn", "error"]

To flag only error-level calls:

toml
[checks."Warning.NoConsoleLog"]
methods = ["error"]

To disable the check entirely without touching enabled, set an empty list:

toml
[checks."Warning.NoConsoleLog"]
methods = []

MIT License