Skip to content

Commit

Permalink
Fix: improve report location for no-tabs (#12471)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored and platinumazure committed Oct 23, 2019
1 parent 7dffe48 commit 89e8aaf
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
10 changes: 8 additions & 2 deletions lib/rules/no-tabs.js
Expand Up @@ -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."
});
Expand Down
68 changes: 61 additions & 7 deletions tests/lib/rules/no-tabs.js
Expand Up @@ -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
}]
},
{
Expand All @@ -59,7 +63,9 @@ ruleTester.run("no-tabs", rule, {
errors: [{
message: ERROR_MESSAGE,
line: 2,
column: 5
column: 5,
endLine: 2,
endColumn: 6
}]
},
{
Expand All @@ -70,7 +76,9 @@ ruleTester.run("no-tabs", rule, {
errors: [{
message: ERROR_MESSAGE,
line: 1,
column: 9
column: 9,
endLine: 1,
endColumn: 10
}]
},
{
Expand All @@ -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
}
]
},
Expand All @@ -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.