Skip to content

Commit 7d94ef0

Browse files
committed
Don't ignore comments in no-empty-rulesets
This commit makes the no-empty-rulesets rule trigger when a ruleset contains only comments. Closes #968.
1 parent d96ed96 commit 7d94ef0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/rules/no-empty-rulesets.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ module.exports = {
1818
else {
1919
block.traverse(function (item) {
2020
if (!helpers.isEqual(block, item)) {
21-
if (item.type !== 'space') {
21+
if (item.type !== 'space' &&
22+
item.type !== 'singlelineComment' &&
23+
item.type !== 'multilineComment') {
2224
nonSpaceCount++;
2325
}
2426
}

tests/rules/no-empty-rulesets.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('no empty rulesets - scss', function () {
1212
lint.test(file, {
1313
'no-empty-rulesets': 1
1414
}, function (data) {
15-
lint.assert.equal(3, data.warningCount);
15+
lint.assert.equal(4, data.warningCount);
1616
done();
1717
});
1818
});

tests/sass/no-empty-rulesets.scss

+7
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@
99
}
1010

1111
.bar{}
12+
13+
.baz {
14+
// a comment
15+
/* and
16+
yet
17+
another */
18+
}

0 commit comments

Comments
 (0)