Skip to content

Commit 89e8aaf

Browse files
mdjermanovicplatinumazure
authored andcommitted
Fix: improve report location for no-tabs (#12471)
1 parent 7dffe48 commit 89e8aaf

2 files changed

Lines changed: 69 additions & 9 deletions

File tree

lib/rules/no-tabs.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ module.exports = {
5555
context.report({
5656
node,
5757
loc: {
58-
line: index + 1,
59-
column: match.index
58+
start: {
59+
line: index + 1,
60+
column: match.index
61+
},
62+
end: {
63+
line: index + 1,
64+
column: match.index + match[0].length
65+
}
6066
},
6167
message: "Unexpected tab character."
6268
});

tests/lib/rules/no-tabs.js

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,19 @@ ruleTester.run("no-tabs", rule, {
4040
errors: [{
4141
message: ERROR_MESSAGE,
4242
line: 1,
43-
column: 17
43+
column: 17,
44+
endLine: 1,
45+
endColumn: 18
4446
}]
4547
},
4648
{
4749
code: "/** \t comment test */",
4850
errors: [{
4951
message: ERROR_MESSAGE,
5052
line: 1,
51-
column: 5
53+
column: 5,
54+
endLine: 1,
55+
endColumn: 6
5256
}]
5357
},
5458
{
@@ -59,7 +63,9 @@ ruleTester.run("no-tabs", rule, {
5963
errors: [{
6064
message: ERROR_MESSAGE,
6165
line: 2,
62-
column: 5
66+
column: 5,
67+
endLine: 2,
68+
endColumn: 6
6369
}]
6470
},
6571
{
@@ -70,7 +76,9 @@ ruleTester.run("no-tabs", rule, {
7076
errors: [{
7177
message: ERROR_MESSAGE,
7278
line: 1,
73-
column: 9
79+
column: 9,
80+
endLine: 1,
81+
endColumn: 10
7482
}]
7583
},
7684
{
@@ -82,12 +90,16 @@ ruleTester.run("no-tabs", rule, {
8290
{
8391
message: ERROR_MESSAGE,
8492
line: 2,
85-
column: 5
93+
column: 5,
94+
endLine: 2,
95+
endColumn: 6
8696
},
8797
{
8898
message: ERROR_MESSAGE,
8999
line: 3,
90-
column: 1
100+
column: 1,
101+
endLine: 3,
102+
endColumn: 2
91103
}
92104
]
93105
},
@@ -97,8 +109,50 @@ ruleTester.run("no-tabs", rule, {
97109
errors: [{
98110
message: ERROR_MESSAGE,
99111
line: 1,
100-
column: 30
112+
column: 30,
113+
endLine: 1,
114+
endColumn: 31
101115
}]
116+
},
117+
{
118+
code: "\t\ta =\t\t\tb +\tc\t\t;\t\t",
119+
errors: [
120+
{
121+
message: ERROR_MESSAGE,
122+
line: 1,
123+
column: 1,
124+
endLine: 1,
125+
endColumn: 3
126+
},
127+
{
128+
message: ERROR_MESSAGE,
129+
line: 1,
130+
column: 6,
131+
endLine: 1,
132+
endColumn: 9
133+
},
134+
{
135+
message: ERROR_MESSAGE,
136+
line: 1,
137+
column: 12,
138+
endLine: 1,
139+
endColumn: 13
140+
},
141+
{
142+
message: ERROR_MESSAGE,
143+
line: 1,
144+
column: 14,
145+
endLine: 1,
146+
endColumn: 16
147+
},
148+
{
149+
message: ERROR_MESSAGE,
150+
line: 1,
151+
column: 17,
152+
endLine: 1,
153+
endColumn: 19
154+
}
155+
]
102156
}
103157
]
104158
});

0 commit comments

Comments
 (0)