Skip to content

Commit

Permalink
Fix: no-trailing-spaces wrong fixing (fixes #6933) (#6937)
Browse files Browse the repository at this point in the history
If `skipBlankLines` option is enabled, counting total length for blank
lines was lacking.
  • Loading branch information
mysticatea authored and nzakas committed Aug 21, 2016
1 parent 6a92be5 commit 8561389
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rules/no-trailing-spaces.js
Expand Up @@ -114,6 +114,7 @@ module.exports = {
// If the line has only whitespace, and skipBlankLines
// is true, don't report it
if (skipBlankLines && skipMatch.test(lines[i])) {
totalLength += lineLength;
continue;
}

Expand Down
33 changes: 33 additions & 0 deletions tests/lib/rules/no-trailing-spaces.js
Expand Up @@ -383,6 +383,39 @@ ruleTester.run("no-trailing-spaces", rule, {
column: 7
}
]
},

// https://github.com/eslint/eslint/issues/6933
{
code: " \nabcdefg ",
output: " \nabcdefg",
options: [{skipBlankLines: true}],
errors: [
{
message: "Trailing spaces not allowed.",
type: "Program",
line: 2,
column: 8
}
]
},
{
code: " \nabcdefg ",
output: "\nabcdefg",
errors: [
{
message: "Trailing spaces not allowed.",
type: "Program",
line: 1,
column: 1
},
{
message: "Trailing spaces not allowed.",
type: "Program",
line: 2,
column: 8
}
]
}
]
});

0 comments on commit 8561389

Please sign in to comment.