Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update: Improve report location for linebreak-style (refs #12334) (#1…
  • Loading branch information
mdjermanovic committed May 20, 2020
1 parent 0891379 commit 89e1081
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/rules/linebreak-style.js
Expand Up @@ -86,8 +86,14 @@ module.exports = {
context.report({
node,
loc: {
line: i,
column: sourceCode.lines[i - 1].length
start: {
line: i,
column: sourceCode.lines[i - 1].length
},
end: {
line: i + 1,
column: 0
}
},
messageId: expectedLF ? "expectedLF" : "expectedCRLF",
fix: createFix(range, expectedLFChars)
Expand Down
40 changes: 40 additions & 0 deletions tests/lib/rules/linebreak-style.js
Expand Up @@ -46,6 +46,8 @@ ruleTester.run("linebreak-style", rule, {
errors: [{
line: 1,
column: 13,
endLine: 2,
endColumn: 1,
messageId: "expectedLF"
}]
},
Expand All @@ -56,6 +58,8 @@ ruleTester.run("linebreak-style", rule, {
errors: [{
line: 1,
column: 13,
endLine: 2,
endColumn: 1,
messageId: "expectedLF"
}]
},
Expand All @@ -66,6 +70,8 @@ ruleTester.run("linebreak-style", rule, {
errors: [{
line: 1,
column: 13,
endLine: 2,
endColumn: 1,
messageId: "expectedCRLF"
}]
},
Expand All @@ -75,11 +81,15 @@ ruleTester.run("linebreak-style", rule, {
errors: [{
line: 4,
column: 24,
endLine: 5,
endColumn: 1,
messageId: "expectedLF"
},
{
line: 6,
column: 3,
endLine: 7,
endColumn: 1,
messageId: "expectedLF"
}]
},
Expand All @@ -90,16 +100,46 @@ ruleTester.run("linebreak-style", rule, {
errors: [{
line: 3,
column: 1,
endLine: 4,
endColumn: 1,
messageId: "expectedCRLF"
},
{
line: 5,
column: 1,
endLine: 6,
endColumn: 1,
messageId: "expectedCRLF"
},
{
line: 6,
column: 17,
endLine: 7,
endColumn: 1,
messageId: "expectedCRLF"
}]
},
{
code: "\r\n",
output: "\n",
options: ["unix"],
errors: [{
line: 1,
column: 1,
endLine: 2,
endColumn: 1,
messageId: "expectedLF"
}]
},
{
code: "\n",
output: "\r\n",
options: ["windows"],
errors: [{
line: 1,
column: 1,
endLine: 2,
endColumn: 1,
messageId: "expectedCRLF"
}]
}
Expand Down

0 comments on commit 89e1081

Please sign in to comment.