Skip to content

consoleSpaces

Disallow leading or trailing spaces in console method string arguments.

✅ This rule is included in the node stylistic preset.

Leading or trailing spaces in console output are often unintentional and can make debugging harder. They can be difficult to spot in console output and may lead to confusion about the actual content being logged.

console.log("text ");
console.error(" error message");
console.warn("warning ", "message");

This rule is not configurable.

If you intentionally need leading or trailing spaces in console output for formatting purposes, you might choose not to enable this rule. However, consider using explicit spacing methods or separate arguments instead for better clarity.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.