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.
Examples
Section titled “Examples”console.log("text ");console.error(" error message");console.warn("warning ", "message");console.log("text");// Leading spaces on a first argument are allowed as a form of indentationconsole.log(" text");console.log("text", "message");console.error("error message");console.warn("warning", "message");Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
unicorn/no-console-spaces - Oxlint:
unicorn/no-console-spaces
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.