console.log or a sibling writes output directly

tx0/ts:console-callstrictwarningsmell

What it finds

Output written with console.log and its siblings goes wherever the environment sends it, without levels, structure or a way to turn it off, and calls left over from debugging end up in production. A logger, or removing the call, keeps output deliberate.

Reported are calls of log, debug, info, trace, dir and table on the global console. console.warn and console.error, which report problems, are left alone.

From the rule's source, console_call.rs.

Example from the rule's tests
export function run() {  console.log("starting");tx0 reports: console.log writes output directly  console.error("failed");  logger.log("fine");}declare const logger: { log(s: string): void };
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:console-call" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:console-call] reason="..."

tx0 explain tx0/ts:console-call shows the same in the terminal. Found a false positive? Report it.