Skip to content

Commit 45ba358

Browse files
authored
test: add exact error positions (#3064)
1 parent 2abe771 commit 45ba358

File tree

161 files changed

+11368
-2276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+11368
-2276
lines changed

tests/lib/rules/attributes-order.test.ts

Lines changed: 89 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,15 @@ tester.run('attributes-order', rule, {
22372237
</div>
22382238
</template>`,
22392239
options: [{ sortLineLength: true }],
2240-
errors: ['Attribute "short" should go before "medium-attr".']
2240+
errors: [
2241+
{
2242+
message: 'Attribute "short" should go before "medium-attr".',
2243+
line: 5,
2244+
column: 11,
2245+
endLine: 5,
2246+
endColumn: 22
2247+
}
2248+
]
22412249
},
22422250
{
22432251
filename: 'test.vue',
@@ -2256,7 +2264,16 @@ tester.run('attributes-order', rule, {
22562264
</div>
22572265
</template>`,
22582266
options: [{ sortLineLength: true }],
2259-
errors: ['Attribute "short" should go before "very-long-attribute-name".']
2267+
errors: [
2268+
{
2269+
message:
2270+
'Attribute "short" should go before "very-long-attribute-name".',
2271+
line: 5,
2272+
column: 11,
2273+
endLine: 5,
2274+
endColumn: 22
2275+
}
2276+
]
22602277
},
22612278
{
22622279
filename: 'test.vue',
@@ -2279,7 +2296,16 @@ tester.run('attributes-order', rule, {
22792296
</div>
22802297
</template>`,
22812298
options: [{ sortLineLength: true }],
2282-
errors: ['Attribute "short" should go before "very-long-attribute-name".']
2299+
errors: [
2300+
{
2301+
message:
2302+
'Attribute "short" should go before "very-long-attribute-name".',
2303+
line: 7,
2304+
column: 11,
2305+
endLine: 7,
2306+
endColumn: 22
2307+
}
2308+
]
22832309
},
22842310
{
22852311
filename: 'test.vue',
@@ -2301,8 +2327,20 @@ tester.run('attributes-order', rule, {
23012327
</template>`,
23022328
options: [{ sortLineLength: true }],
23032329
errors: [
2304-
'Attribute "@click" should go before "@mouseover".',
2305-
'Attribute "@input" should go before "@mouseover".'
2330+
{
2331+
message: 'Attribute "@click" should go before "@mouseover".',
2332+
line: 5,
2333+
column: 11,
2334+
endLine: 5,
2335+
endColumn: 22
2336+
},
2337+
{
2338+
message: 'Attribute "@input" should go before "@mouseover".',
2339+
line: 6,
2340+
column: 11,
2341+
endLine: 6,
2342+
endColumn: 31
2343+
}
23062344
]
23072345
},
23082346
{
@@ -2325,8 +2363,20 @@ tester.run('attributes-order', rule, {
23252363
</template>`,
23262364
options: [{ sortLineLength: true }],
23272365
errors: [
2328-
'Attribute ":a" should go before ":abc".',
2329-
'Attribute ":ab" should go before ":abc".'
2366+
{
2367+
message: 'Attribute ":a" should go before ":abc".',
2368+
line: 5,
2369+
column: 11,
2370+
endLine: 5,
2371+
endColumn: 21
2372+
},
2373+
{
2374+
message: 'Attribute ":ab" should go before ":abc".',
2375+
line: 6,
2376+
column: 11,
2377+
endLine: 6,
2378+
endColumn: 22
2379+
}
23302380
]
23312381
},
23322382
{
@@ -2348,7 +2398,15 @@ tester.run('attributes-order', rule, {
23482398
</div>
23492399
</template>`,
23502400
options: [{ sortLineLength: true }],
2351-
errors: ['Attribute "short" should go before "very-long-binding".']
2401+
errors: [
2402+
{
2403+
message: 'Attribute "short" should go before "very-long-binding".',
2404+
line: 5,
2405+
column: 11,
2406+
endLine: 5,
2407+
endColumn: 22
2408+
}
2409+
]
23522410
},
23532411
{
23542412
filename: 'test.vue',
@@ -2367,7 +2425,15 @@ tester.run('attributes-order', rule, {
23672425
></div>
23682426
</template>`,
23692427
options: [{ sortLineLength: true, alphabetical: true }],
2370-
errors: [{ message: 'Attribute "z" should go before "aa".' }]
2428+
errors: [
2429+
{
2430+
message: 'Attribute "z" should go before "aa".',
2431+
line: 5,
2432+
column: 11,
2433+
endLine: 5,
2434+
endColumn: 16
2435+
}
2436+
]
23712437
},
23722438
{
23732439
filename: 'test.vue',
@@ -2391,8 +2457,20 @@ tester.run('attributes-order', rule, {
23912457
</template>`,
23922458
options: [{ sortLineLength: true, alphabetical: true }],
23932459
errors: [
2394-
{ message: 'Attribute "bb" should go before "zz".' },
2395-
{ message: 'Attribute "@click" should go before "@keyup".' }
2460+
{
2461+
message: 'Attribute "bb" should go before "zz".',
2462+
line: 5,
2463+
column: 11,
2464+
endLine: 5,
2465+
endColumn: 17
2466+
},
2467+
{
2468+
message: 'Attribute "@click" should go before "@keyup".',
2469+
line: 7,
2470+
column: 11,
2471+
endLine: 7,
2472+
endColumn: 22
2473+
}
23962474
]
23972475
}
23982476
]

tests/lib/rules/eqeqeq.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ tester.run('eqeqeq', rule, {
2727
errors: [
2828
{
2929
message: "Expected '===' and instead saw '=='.",
30+
line: 1,
31+
column: 25,
32+
endLine: 1,
33+
endColumn: 27,
3034
suggestions: semver.gte(ESLint.version, '9.26.0')
3135
? [
3236
{
3337
desc: "Use '===' instead of '=='.",
3438
output: `<template><div :attr="a === 1" /></template>`
3539
}
3640
]
37-
: [],
38-
line: 1,
39-
column: 25,
40-
endLine: 1,
41-
endColumn: 27
41+
: []
4242
}
4343
]
4444
},
@@ -53,6 +53,10 @@ tester.run('eqeqeq', rule, {
5353
errors: [
5454
{
5555
message: "Expected '===' and instead saw '=='.",
56+
line: 4,
57+
column: 25,
58+
endLine: 4,
59+
endColumn: 27,
5660
suggestions: semver.gte(ESLint.version, '9.26.0')
5761
? [
5862
{
@@ -65,11 +69,7 @@ tester.run('eqeqeq', rule, {
6569
</style>`
6670
}
6771
]
68-
: [],
69-
line: 4,
70-
column: 25,
71-
endLine: 4,
72-
endColumn: 27
72+
: []
7373
}
7474
]
7575
}

tests/lib/rules/html-button-has-type.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ ruleTester.run('html-button-has-type', rule, {
5656
errors: [
5757
{
5858
message: 'Missing an explicit type attribute for button.',
59-
column: 11,
6059
line: 1,
60+
column: 11,
6161
endLine: 1,
6262
endColumn: 19
6363
}
@@ -69,8 +69,8 @@ ruleTester.run('html-button-has-type', rule, {
6969
errors: [
7070
{
7171
message: 'A value must be set for button type attribute.',
72-
column: 24,
7372
line: 1,
73+
column: 24,
7474
endLine: 1,
7575
endColumn: 26
7676
}
@@ -82,8 +82,8 @@ ruleTester.run('html-button-has-type', rule, {
8282
errors: [
8383
{
8484
message: 'A value must be set for button type attribute.',
85-
column: 19,
8685
line: 1,
86+
column: 19,
8787
endLine: 1,
8888
endColumn: 23
8989
}
@@ -95,8 +95,8 @@ ruleTester.run('html-button-has-type', rule, {
9595
errors: [
9696
{
9797
message: 'foo is an invalid value for button type attribute.',
98-
column: 24,
9998
line: 1,
99+
column: 24,
100100
endLine: 1,
101101
endColumn: 29
102102
}
@@ -109,8 +109,8 @@ ruleTester.run('html-button-has-type', rule, {
109109
errors: [
110110
{
111111
message: 'button is a forbidden value for button type attribute.',
112-
column: 24,
113112
line: 1,
113+
column: 24,
114114
endLine: 1,
115115
endColumn: 32
116116
}
@@ -123,8 +123,8 @@ ruleTester.run('html-button-has-type', rule, {
123123
errors: [
124124
{
125125
message: 'submit is a forbidden value for button type attribute.',
126-
column: 24,
127126
line: 1,
127+
column: 24,
128128
endLine: 1,
129129
endColumn: 32
130130
}
@@ -137,8 +137,8 @@ ruleTester.run('html-button-has-type', rule, {
137137
errors: [
138138
{
139139
message: 'reset is a forbidden value for button type attribute.',
140-
column: 24,
141140
line: 1,
141+
column: 24,
142142
endLine: 1,
143143
endColumn: 31
144144
}
@@ -216,15 +216,15 @@ ruleTester.run('html-button-has-type', rule, {
216216
errors: [
217217
{
218218
message: 'Missing an explicit type attribute for button.',
219-
column: 11,
220219
line: 1,
220+
column: 11,
221221
endLine: 1,
222222
endColumn: 19
223223
},
224224
{
225225
message: 'Missing an explicit type attribute for button.',
226-
column: 39,
227226
line: 1,
227+
column: 39,
228228
endLine: 1,
229229
endColumn: 47
230230
}
@@ -236,8 +236,8 @@ ruleTester.run('html-button-has-type', rule, {
236236
errors: [
237237
{
238238
message: 'A value must be set for button type attribute.',
239-
column: 25,
240239
line: 1,
240+
column: 25,
241241
endLine: 1,
242242
endColumn: 27
243243
}

tests/lib/rules/html-closing-bracket-newline.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -564,48 +564,48 @@ tester.run('html-closing-bracket-newline', rule, {
564564
'Expected 1 line break before closing bracket, but no line breaks found.',
565565
line: 2,
566566
column: 18,
567-
endColumn: 18,
568-
endLine: 2
567+
endLine: 2,
568+
endColumn: 18
569569
},
570570
{
571571
message:
572572
'Expected 1 line break before closing bracket, but no line breaks found.',
573573
line: 3,
574574
column: 19,
575-
endColumn: 19,
576-
endLine: 3
575+
endLine: 3,
576+
endColumn: 19
577577
},
578578
{
579579
message:
580580
'Expected 1 line break before closing bracket, but no line breaks found.',
581581
line: 4,
582582
column: 16,
583-
endColumn: 16,
584-
endLine: 4
583+
endLine: 4,
584+
endColumn: 16
585585
},
586586
{
587587
message:
588588
'Expected 1 line break before closing bracket, but no line breaks found.',
589589
line: 5,
590590
column: 17,
591-
endColumn: 17,
592-
endLine: 5
591+
endLine: 5,
592+
endColumn: 17
593593
},
594594
{
595595
message:
596596
'Expected 1 line break before closing bracket, but no line breaks found.',
597597
line: 6,
598598
column: 15,
599-
endColumn: 15,
600-
endLine: 6
599+
endLine: 6,
600+
endColumn: 15
601601
},
602602
{
603603
message:
604604
'Expected 1 line break before closing bracket, but no line breaks found.',
605605
line: 6,
606606
column: 23,
607-
endColumn: 23,
608-
endLine: 6
607+
endLine: 6,
608+
endColumn: 23
609609
}
610610
]
611611
},

0 commit comments

Comments
 (0)