Skip to content

unicorn/no-console-spaces Style

🛠️ An auto-fix is available for this rule.

What it does

Disallows leading/trailing space inside console.log() and similar methods.

Why is this bad?

The console.log() method and similar methods join the parameters with a space so adding a leading/trailing space to a parameter, results in two spaces being added.

Example

Examples of incorrect code for this rule:

javascript
console.log("abc ", "def");

Examples of correct code for this rule:

javascript
console.log("abc", "def");

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny unicorn/no-console-spaces
json
{
  "rules": {
    "unicorn/no-console-spaces": "error"
  }
}

References

Released under the MIT License.