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

Commit

Permalink
maximumLineLength: correctly position error for comment nodes
Browse files Browse the repository at this point in the history
Fixes #2233
  • Loading branch information
markelog committed Jun 4, 2016
1 parent ea1ebb9 commit 56ca72b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/maximum-line-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ module.exports.prototype = {
if (line.length > maximumLineLength) {
errors.add(
'Line must be at most ' + maximumLineLength + ' characters',
file.getLastTokenOnLine(i + 1)
file.getLastTokenOnLine(i + 1, { includeComments: true })
);
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/specs/rules/maximum-line-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ describe('rules/maximum-line-length', function() {
expect(error.line).to.equal(4);
expect(error.column).to.equal(9);
});

it('should get correct line and column', function() {
var error = checker.checkString('\n\n\n123456789').getErrorList()[0];

expect(error.line).to.equal(4);
expect(error.column).to.equal(9);
});
});

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

0 comments on commit 56ca72b

Please sign in to comment.