Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit f3be3d6

Browse files
committed
disallowPaddingNewlinesBeforeKeywords: should not ignore comments
Fixes #2237
1 parent 29d1b00 commit f3be3d6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/rules/disallow-padding-newlines-before-keywords.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module.exports.prototype = {
8888
check: function(file, errors) {
8989
file.iterateTokensByTypeAndValue('Keyword', this._keywords, function(token) {
9090
errors.assert.linesBetween({
91-
token: file.getPrevToken(token),
91+
token: file.getPrevToken(token, { includeComments: true }),
9292
nextToken: token,
9393
atMost: 1,
9494
message: 'Keyword `' + token.value + '` should not have an empty line above it'

test/specs/rules/disallow-padding-newlines-before-keywords.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,11 @@ describe('rules/disallow-padding-newlines-before-keywords', function() {
7373
'function x() { var a;\n\nreturn; }'
7474
)).to.have.one.validation.error.from('disallowPaddingNewlinesBeforeKeywords');
7575
});
76+
77+
it('should not ignore comments', function() {
78+
expect(checker.checkString(
79+
'if (true) {} \n //comment \n else {}'
80+
)).to.not.have.errors();
81+
});
7682
});
7783
});

0 commit comments

Comments
 (0)