Skip to content

Commit dfc2088

Browse files
author
Hannu Pelkonen
committed
Fix: Ignored blocks should not change line numbering
1 parent e32e149 commit dfc2088

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/modules/ignore-block.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ function removeIgnoredBlocks(string) {
55
ignoreEnabled = false;
66
lines.forEach(function(line) {
77
if (line.indexOf('styleguide:ignore:start') !== -1) {
8+
results.push('');
89
ignoreEnabled = true;
910
} else if (line.indexOf('styleguide:ignore:end') !== -1) {
11+
results.push('');
1012
ignoreEnabled = false;
11-
} else if (!ignoreEnabled) {
13+
} else if (ignoreEnabled) {
14+
results.push('');
15+
} else {
1216
results.push(line);
1317
}
1418
});

test/unit/modules/ignore-block.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ styleguide:ignore:end
1818
Last line
1919
*/
2020
});
21-
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nLast line');
21+
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line');
2222
});
2323

2424
it('should remove everything on the same line as tags', function() {
@@ -32,7 +32,7 @@ Ignore 2
3232
Last line
3333
*/
3434
});
35-
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nLast line');
35+
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n\nLast line');
3636
});
3737

3838
it('should support multiple blocks', function() {
@@ -49,7 +49,7 @@ styleguide:ignore:end
4949
Last line
5050
*/
5151
});
52-
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\nMiddle line\nLast line');
52+
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\nMiddle line\n\n\n\nLast line');
5353
});
5454

5555
it('should remove everything after start tag even if it is not closed', function() {
@@ -62,6 +62,6 @@ Ignore 2
6262
Ignore 3
6363
*/
6464
});
65-
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line');
65+
expect(ignoreBlock.removeIgnoredBlocks(str)).to.eql('First line\n\n\n\n');
6666
});
6767
});

0 commit comments

Comments
 (0)