Skip to content

Commit

Permalink
Don't ignore comments in no-empty-rulesets
Browse files Browse the repository at this point in the history
This commit makes the no-empty-rulesets rule trigger when a ruleset
contains only comments. Closes sasstools#968.
  • Loading branch information
royaldark authored and bgriffith committed Aug 27, 2017
1 parent a8e5019 commit a8a5ec2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/rules/no-empty-rulesets.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ module.exports = {
else {
block.traverse(function (item) {
if (!helpers.isEqual(block, item)) {
if (item.type !== 'space') {
if (item.type !== 'space' &&
item.type !== 'singlelineComment' &&
item.type !== 'multilineComment') {
nonSpaceCount++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/rules/no-empty-rulesets.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('no empty rulesets - scss', function () {
lint.test(file, {
'no-empty-rulesets': 1
}, function (data) {
lint.assert.equal(3, data.warningCount);
lint.assert.equal(4, data.warningCount);
done();
});
});
Expand Down
7 changes: 7 additions & 0 deletions tests/sass/no-empty-rulesets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
}

.bar{}

.baz {
// a comment
/* and
yet
another */
}

0 comments on commit a8a5ec2

Please sign in to comment.