Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-multiple-empty-lines: Adjust reported loc #12594

Merged
merged 1 commit into from Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/no-multiple-empty-lines.js
Expand Up @@ -110,7 +110,7 @@ module.exports = {
if (lineNumber - lastLineNumber - 1 > maxAllowed) {
context.report({
node,
loc: { start: { line: lastLineNumber + 1, column: 0 }, end: { line: lineNumber, column: 0 } },
loc: { start: { line: lastLineNumber + maxAllowed + 1, column: 0 }, end: { line: lineNumber, column: 0 } },
message,
data: { max: maxAllowed, pluralizedLines: maxAllowed === 1 ? "line" : "lines" },
fix(fixer) {
Expand Down
26 changes: 26 additions & 0 deletions tests/lib/rules/no-multiple-empty-lines.js
Expand Up @@ -316,6 +316,32 @@ ruleTester.run("no-multiple-empty-lines", rule, {
output: "foo\n",
options: [{ max: 1, maxEOF: 0 }],
errors: [getExpectedErrorEOF(0)]
},
{

// https://github.com/eslint/eslint/pull/12594
code: "var a;\n\n\n\n\nvar b;",
output: "var a;\n\nvar b;",
options: [{ max: 1 }],
errors: [{
message: "More than 1 blank line not allowed.",
type: "Program",
line: 3,
column: 1
}]
},
{

// https://github.com/eslint/eslint/pull/12594
code: "var a;\n\n\n\n\nvar b;",
output: "var a;\n\n\nvar b;",
options: [{ max: 2 }],
errors: [{
message: "More than 2 blank lines not allowed.",
type: "Program",
line: 4,
column: 1
}]
}
]
});