Skip to content

Commit

Permalink
Fix: balanced false positive in spaced-comment (fixes #6689) (#6692)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeber authored and alberto committed Jul 18, 2016
1 parent 57f1676 commit 3f206dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules/spaced-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ module.exports = {
}
}

if (balanced && !endMatch) {
if (balanced && type === "block" && !endMatch) {
reportEnd(node, "Expected space or tab before '*/' in comment");
}
} else {
Expand All @@ -354,7 +354,7 @@ module.exports = {
}
}

if (endMatch && balanced) {
if (balanced && type === "block" && endMatch) {
reportEnd(node, "Unexpected space or tab before '*/' in comment", endMatch);
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/spaced-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ ruleTester.run("spaced-comment", rule, {
code: "//\n",
options: ["always"]
},
{
code: "// space only at start; valid since balanced doesn't apply to line comments",
options: ["always", { block: { balanced: true }}]
},
{
code: "//space only at end; valid since balanced doesn't apply to line comments ",
options: ["never", { block: { balanced: true }}]
},

// block comments
{
Expand Down

0 comments on commit 3f206dd

Please sign in to comment.