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

Commit 56ca72b

Browse files
committed
maximumLineLength: correctly position error for comment nodes
Fixes #2233
1 parent ea1ebb9 commit 56ca72b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/rules/maximum-line-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ module.exports.prototype = {
196196
if (line.length > maximumLineLength) {
197197
errors.add(
198198
'Line must be at most ' + maximumLineLength + ' characters',
199-
file.getLastTokenOnLine(i + 1)
199+
file.getLastTokenOnLine(i + 1, { includeComments: true })
200200
);
201201
}
202202
}

test/specs/rules/maximum-line-length.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ describe('rules/maximum-line-length', function() {
5151
expect(error.line).to.equal(4);
5252
expect(error.column).to.equal(9);
5353
});
54+
55+
it('should get correct line and column', function() {
56+
var error = checker.checkString('\n\n\n123456789').getErrorList()[0];
57+
58+
expect(error.line).to.equal(4);
59+
expect(error.column).to.equal(9);
60+
});
5461
});
5562

5663
describe('allExcept["comments"] option', function() {

0 commit comments

Comments
 (0)