Skip to content

Commit e9d3f43

Browse files
authored
test: remove type property from asserted errors (#2998)
1 parent ff8c8e0 commit e9d3f43

File tree

2 files changed

+99
-41
lines changed

2 files changed

+99
-41
lines changed

tests/lib/rules/no-duplicate-class-names.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ tester.run('no-duplicate-class-names', rule, {
547547
errors: [
548548
{
549549
message: "Duplicate class name 'bar'.",
550-
type: 'BinaryExpression',
551550
line: 1,
552551
column: 36,
553552
endLine: 1,
@@ -562,7 +561,6 @@ tester.run('no-duplicate-class-names', rule, {
562561
errors: [
563562
{
564563
message: "Duplicate class name 'foo'.",
565-
type: 'TemplateLiteral',
566564
line: 1,
567565
column: 36,
568566
endLine: 1,

tests/lib/rules/this-in-template.js

Lines changed: 99 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,25 @@ function createValidTests(prefix, options) {
7777
]
7878
}
7979

80-
function createInvalidTests(prefix, options, message, type) {
80+
function createInvalidTests(prefix, options, message) {
8181
const comment = options.join('')
82+
const errorLength = options[0] === 'always' ? 3 : 4
8283
return [
8384
{
8485
code: `<template><div>{{ ${prefix}foo }}</div></template><!-- ${comment} -->`,
8586
output: `<template><div>{{ ${suggestionPrefix(
8687
prefix,
8788
options
8889
)}foo }}</div></template><!-- ${comment} -->`,
89-
errors: [{ message, type }],
90+
errors: [
91+
{
92+
message,
93+
line: 1,
94+
column: 19,
95+
endLine: 1,
96+
endColumn: 19 + errorLength
97+
}
98+
],
9099
options
91100
},
92101
{
@@ -95,7 +104,15 @@ function createInvalidTests(prefix, options, message, type) {
95104
prefix,
96105
options
97106
)}foo() }}</div></template><!-- ${comment} -->`,
98-
errors: [{ message, type }],
107+
errors: [
108+
{
109+
message,
110+
line: 1,
111+
column: 19,
112+
endLine: 1,
113+
endColumn: 19 + errorLength
114+
}
115+
],
99116
options
100117
},
101118
{
@@ -104,7 +121,15 @@ function createInvalidTests(prefix, options, message, type) {
104121
prefix,
105122
options
106123
)}foo.bar() }}</div></template><!-- ${comment} -->`,
107-
errors: [{ message, type }],
124+
errors: [
125+
{
126+
message,
127+
line: 1,
128+
column: 19,
129+
endLine: 1,
130+
endColumn: 19 + errorLength
131+
}
132+
],
108133
options
109134
},
110135
{
@@ -113,7 +138,15 @@ function createInvalidTests(prefix, options, message, type) {
113138
prefix,
114139
options
115140
)}foo"></div></template><!-- ${comment} -->`,
116-
errors: [{ message, type }],
141+
errors: [
142+
{
143+
message,
144+
line: 1,
145+
column: 24,
146+
endLine: 1,
147+
endColumn: 24 + errorLength
148+
}
149+
],
117150
options
118151
},
119152
{
@@ -122,7 +155,15 @@ function createInvalidTests(prefix, options, message, type) {
122155
prefix,
123156
options
124157
)}foo}"></div></template><!-- ${comment} -->`,
125-
errors: [{ message, type }],
158+
errors: [
159+
{
160+
message,
161+
line: 1,
162+
column: 30,
163+
endLine: 1,
164+
endColumn: 30 + errorLength
165+
}
166+
],
126167
options
127168
},
128169
{
@@ -131,7 +172,15 @@ function createInvalidTests(prefix, options, message, type) {
131172
prefix,
132173
options
133174
)}foo()}"></div></template><!-- ${comment} -->`,
134-
errors: [{ message, type }],
175+
errors: [
176+
{
177+
message,
178+
line: 1,
179+
column: 30,
180+
endLine: 1,
181+
endColumn: 30 + errorLength
182+
}
183+
],
135184
options
136185
},
137186
{
@@ -140,7 +189,15 @@ function createInvalidTests(prefix, options, message, type) {
140189
prefix,
141190
options
142191
)}foo"></div></template><!-- ${comment} -->`,
143-
errors: [{ message, type }],
192+
errors: [
193+
{
194+
message,
195+
line: 1,
196+
column: 22,
197+
endLine: 1,
198+
endColumn: 22 + errorLength
199+
}
200+
],
144201
options
145202
},
146203
{
@@ -149,14 +206,22 @@ function createInvalidTests(prefix, options, message, type) {
149206
prefix,
150207
options
151208
)}bar"></div></template><!-- ${comment} -->`,
152-
errors: [{ message, type }],
209+
errors: [
210+
{
211+
message,
212+
line: 1,
213+
column: 30,
214+
endLine: 1,
215+
endColumn: 30 + errorLength
216+
}
217+
],
153218
options
154219
}
155220

156221
// We cannot use `.` in dynamic arguments because the right of the `.` becomes a modifier.
157222
// {
158223
// code: `<template><div v-on:[${prefix}name]="1"></div></template><!-- ${comment} -->`,
159-
// errors: [{ message, type }],
224+
// errors: [{ message, line: 1, column: 22, endLine: 1, endColumn: 22 + errorLength }],
160225
// options
161226
// }
162227
]
@@ -207,46 +272,25 @@ ruleTester.run('this-in-template', rule, {
207272
})
208273
],
209274
invalid: [
210-
...createInvalidTests(
211-
'this.',
212-
[],
213-
"Unexpected usage of 'this'.",
214-
'ThisExpression'
215-
),
216-
...createInvalidTests(
217-
'this?.',
218-
[],
219-
"Unexpected usage of 'this'.",
220-
'ThisExpression'
221-
),
222-
...createInvalidTests(
223-
'this.',
224-
['never'],
225-
"Unexpected usage of 'this'.",
226-
'ThisExpression'
227-
),
228-
...createInvalidTests(
229-
'this?.',
230-
['never'],
231-
"Unexpected usage of 'this'.",
232-
'ThisExpression'
233-
),
275+
...createInvalidTests('this.', [], "Unexpected usage of 'this'."),
276+
...createInvalidTests('this?.', [], "Unexpected usage of 'this'."),
277+
...createInvalidTests('this.', ['never'], "Unexpected usage of 'this'."),
278+
...createInvalidTests('this?.', ['never'], "Unexpected usage of 'this'."),
234279
...createInvalidTests('', ['always'], "Expected 'this'.", 'Identifier'),
235280
...[[], ['never']].flatMap((options) => {
236281
const comment = options.join('')
237282
const message = "Unexpected usage of 'this'."
238-
const type = 'ThisExpression'
239283
return [
240284
{
241285
code: `<template><div>{{ this['xs'] }}</div></template><!-- ${comment} -->`,
242286
output: `<template><div>{{ xs }}</div></template><!-- ${comment} -->`,
243-
errors: [{ message, type }],
287+
errors: [{ message, line: 1, column: 19, endLine: 1, endColumn: 23 }],
244288
options
245289
},
246290
{
247291
code: `<template><div>{{ this['xs0AZ_foo'] }}</div></template><!-- ${comment} -->`,
248292
output: `<template><div>{{ xs0AZ_foo }}</div></template><!-- ${comment} -->`,
249-
errors: [{ message, type }],
293+
errors: [{ message, line: 1, column: 19, endLine: 1, endColumn: 23 }],
250294
options
251295
}
252296
]
@@ -255,13 +299,29 @@ ruleTester.run('this-in-template', rule, {
255299
code: `<template><div v-if="fn(this.$foo)"></div></template><!-- never -->`,
256300
output: `<template><div v-if="fn($foo)"></div></template><!-- never -->`,
257301
options: ['never'],
258-
errors: ["Unexpected usage of 'this'."]
302+
errors: [
303+
{
304+
message: "Unexpected usage of 'this'.",
305+
line: 1,
306+
column: 25,
307+
endLine: 1,
308+
endColumn: 29
309+
}
310+
]
259311
},
260312
{
261313
code: `<template><div :class="{ foo: this.$foo }"></div></template><!-- never -->`,
262314
output: `<template><div :class="{ foo: $foo }"></div></template><!-- never -->`,
263315
options: ['never'],
264-
errors: ["Unexpected usage of 'this'."]
316+
errors: [
317+
{
318+
message: "Unexpected usage of 'this'.",
319+
line: 1,
320+
column: 31,
321+
endLine: 1,
322+
endColumn: 35
323+
}
324+
]
265325
}
266326
]
267327
})

0 commit comments

Comments
 (0)