comment-space
What it does
Section titled “What it does”Reports a line comment whose text starts right after the marker (//text, #text). Not reported: a comment with nothing after the marker, a repeated marker (////, ##), a -- separator line and a #! shebang on the first line. With the option block it also checks block comments (/*a*/: text right after the opening or before the closing delimiter). The fix inserts the space.
Why it matters
Section titled “Why it matters”One space after the marker is the common way to write comments, and it separates the text from the marker so that the comment reads as text and not as a disabled piece of code. A comment without it is also hard to tell from commented-out code (//foo();).
To fix, add the space; the fix does it.
Example
Section titled “Example”{ //no space /// fine "a": 1, //tail "b": 2}{ // no space /// fine "a": 1, // tail "b": 2}Configuration
Section titled “Configuration”lint: rules: comment-space: level: warn # off (default), warn, error options: line: true block: false| Option | Type | Default | Description |
|---|---|---|---|
line |
bool | true |
Check line comments (// a). Off, only block comments are checked (with block). |
block |
bool | false |
Also check block comments: text right after the opening or before the closing delimiter is reported (/*a*/). Exempt: an empty comment, and a delimiter repeated (/**, /***/). The fix inserts the space. |
Enabled by the presets: css/stylelint-standard, kotlin/ktlint, yaml/yamllint, csharp/stylecop.
Suppress one line with sudsy-disable-next-line comment-space in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| ktlint | comment-spacing |
partial | Line comments only. |
| StyleCop | SA1005 |
full | |
| stylelint | comment-whitespace-inside |
full | |
| yamllint | comments.require-starting-space |
full |