noConsoleSpaces (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Rule available since:
v2.6.4 - Diagnostic Category:
lint/nursery/noConsoleSpaces - This rule has an unsafe fix.
- The default severity of this rule is warning.
- Sources:
- Same as
unicorn/no-console-spaces
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noConsoleSpaces": "error" } } }}Description
Section titled “Description”Disallow leading and trailing spaces in console method arguments.
console.log(), console.debug(), console.info(), console.warn(), and console.error()
put a space between their arguments when printing them.
A string argument that starts or ends with a space next to another argument
prints two spaces instead of one.
The first argument may start with a space, and the last argument may end with one, because nothing is printed before or after them. Strings that contain only one space, or that start or end with two or more spaces, are allowed because the extra spacing is likely intentional.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”console.log("abc ", "def");code-block.js:1:17 lint/nursery/noConsoleSpaces FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This argument ends with a space.
> 1 │ console.log("abc ", "def");
│ ^
2 │
ℹ console.log() already prints a space between its arguments, so this space adds a second one.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Remove the trailing space.
1 │ console.log("abc·",·"def");
│ -
console.error("abc", " def");code-block.js:1:23 lint/nursery/noConsoleSpaces FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This argument starts with a space.
> 1 │ console.error("abc", " def");
│ ^
2 │
ℹ console.error() already prints a space between its arguments, so this space adds a second one.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Remove the leading space.
1 │ console.error("abc",·"·def");
│ -
console.warn(`abc `, "def");code-block.js:1:18 lint/nursery/noConsoleSpaces FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This argument ends with a space.
> 1 │ console.warn(`abc `, "def");
│ ^
2 │
ℹ console.warn() already prints a space between its arguments, so this space adds a second one.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
ℹ Unsafe fix: Remove the trailing space.
1 │ console.warn(`abc·`,·"def");
│ -
console.log("abc", "def");console.log(" abc", "def ");console.log("abc ", "def");console.log("abc\t", "def");console.log("abc", " ", "def");Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.