Skip to content
Permalink
Browse files

Fix: improve report location for no-tabs (#12471)

  • Loading branch information
mdjermanovic authored and platinumazure committed Oct 23, 2019
1 parent 7dffe48 commit 89e8aafcc622a4763bed6b9d62f148ef95798f38
Showing with 69 additions and 9 deletions.
  1. +8 −2 lib/rules/no-tabs.js
  2. +61 −7 tests/lib/rules/no-tabs.js
@@ -55,8 +55,14 @@ module.exports = {
context.report({
node,
loc: {
line: index + 1,
column: match.index
start: {
line: index + 1,
column: match.index
},
end: {
line: index + 1,
column: match.index + match[0].length
}
},
message: "Unexpected tab character."
});
@@ -40,15 +40,19 @@ ruleTester.run("no-tabs", rule, {
errors: [{
message: ERROR_MESSAGE,
line: 1,
column: 17
column: 17,
endLine: 1,
endColumn: 18
}]
},
{
code: "/** \t comment test */",
errors: [{
message: ERROR_MESSAGE,
line: 1,
column: 5
column: 5,
endLine: 1,
endColumn: 6
}]
},
{
@@ -59,7 +63,9 @@ ruleTester.run("no-tabs", rule, {
errors: [{
message: ERROR_MESSAGE,
line: 2,
column: 5
column: 5,
endLine: 2,
endColumn: 6
}]
},
{
@@ -70,7 +76,9 @@ ruleTester.run("no-tabs", rule, {
errors: [{
message: ERROR_MESSAGE,
line: 1,
column: 9
column: 9,
endLine: 1,
endColumn: 10
}]
},
{
@@ -82,12 +90,16 @@ ruleTester.run("no-tabs", rule, {
{
message: ERROR_MESSAGE,
line: 2,
column: 5
column: 5,
endLine: 2,
endColumn: 6
},
{
message: ERROR_MESSAGE,
line: 3,
column: 1
column: 1,
endLine: 3,
endColumn: 2
}
]
},
@@ -97,8 +109,50 @@ ruleTester.run("no-tabs", rule, {
errors: [{
message: ERROR_MESSAGE,
line: 1,
column: 30
column: 30,
endLine: 1,
endColumn: 31
}]
},
{
code: "\t\ta =\t\t\tb +\tc\t\t;\t\t",
errors: [
{
message: ERROR_MESSAGE,
line: 1,
column: 1,
endLine: 1,
endColumn: 3
},
{
message: ERROR_MESSAGE,
line: 1,
column: 6,
endLine: 1,
endColumn: 9
},
{
message: ERROR_MESSAGE,
line: 1,
column: 12,
endLine: 1,
endColumn: 13
},
{
message: ERROR_MESSAGE,
line: 1,
column: 14,
endLine: 1,
endColumn: 16
},
{
message: ERROR_MESSAGE,
line: 1,
column: 17,
endLine: 1,
endColumn: 19
}
]
}
]
});

0 comments on commit 89e8aaf

Please sign in to comment.