4
4
*/
5
5
'use strict'
6
6
7
- const { RuleTester, ESLint } = require ( '../../eslint-compat' )
7
+ const { RuleTester } = require ( '../../eslint-compat' )
8
8
const rule = require ( '../../../lib/rules/multiline-ternary' )
9
- const semver = require ( 'semver' )
10
9
11
10
const tester = new RuleTester ( {
12
11
languageOptions : {
@@ -80,8 +79,7 @@ tester.run('multiline-ternary', rule, {
80
79
</div>
81
80
</template>
82
81
` ,
83
- output : semver . gte ( ESLint . version , '7.1.0' )
84
- ? `
82
+ output : `
85
83
<template>
86
84
<div :class="{
87
85
'test': someReallyLongCondition ?
@@ -90,15 +88,16 @@ tester.run('multiline-ternary', rule, {
90
88
}">
91
89
</div>
92
90
</template>
93
- `
94
- : null ,
91
+ ` ,
95
92
options : [ 'always-multiline' ] ,
96
93
errors : [
97
94
{
98
95
message :
99
96
'Expected newline between consequent and alternate of ternary expression.' ,
100
97
line : 5 ,
101
- column : 15
98
+ column : 15 ,
99
+ endLine : 5 ,
100
+ endColumn : 30
102
101
}
103
102
]
104
103
} ,
@@ -113,23 +112,23 @@ tester.run('multiline-ternary', rule, {
113
112
</div>
114
113
</template>
115
114
` ,
116
- output : semver . gte ( ESLint . version , '7.1.0' )
117
- ? `
115
+ output : `
118
116
<template>
119
117
<div :class="{
120
118
'test': someReallyLongCondition ?aVeryLongOutput : thisCantFitOnASingleLine
121
119
}">
122
120
</div>
123
121
</template>
124
- `
125
- : null ,
122
+ ` ,
126
123
options : [ 'never' ] ,
127
124
errors : [
128
125
{
129
126
message :
130
127
'Unexpected newline between test and consequent of ternary expression.' ,
131
128
line : 4 ,
132
- column : 21
129
+ column : 21 ,
130
+ endLine : 4 ,
131
+ endColumn : 44
133
132
}
134
133
]
135
134
} ,
@@ -143,8 +142,7 @@ tester.run('multiline-ternary', rule, {
143
142
</div>
144
143
</template>
145
144
` ,
146
- output : semver . gte ( ESLint . version , '7.1.0' )
147
- ? `
145
+ output : `
148
146
<template>
149
147
<div :class="{
150
148
'test': someReallyLongCondition
@@ -153,20 +151,23 @@ tester.run('multiline-ternary', rule, {
153
151
}">
154
152
</div>
155
153
</template>
156
- `
157
- : null ,
154
+ ` ,
158
155
errors : [
159
156
{
160
157
message :
161
158
'Expected newline between test and consequent of ternary expression.' ,
162
159
line : 4 ,
163
- column : 21
160
+ column : 21 ,
161
+ endLine : 4 ,
162
+ endColumn : 44
164
163
} ,
165
164
{
166
165
message :
167
166
'Expected newline between consequent and alternate of ternary expression.' ,
168
167
line : 4 ,
169
- column : 47
168
+ column : 47 ,
169
+ endLine : 4 ,
170
+ endColumn : 62
170
171
}
171
172
]
172
173
} ,
@@ -180,8 +181,7 @@ tester.run('multiline-ternary', rule, {
180
181
</div>
181
182
</template>
182
183
` ,
183
- output : semver . gte ( ESLint . version , '7.1.0' )
184
- ? `
184
+ output : `
185
185
<template>
186
186
<div :style="{
187
187
'test': someReallyLongCondition
@@ -190,20 +190,23 @@ tester.run('multiline-ternary', rule, {
190
190
}">
191
191
</div>
192
192
</template>
193
- `
194
- : null ,
193
+ ` ,
195
194
errors : [
196
195
{
197
196
message :
198
197
'Expected newline between test and consequent of ternary expression.' ,
199
198
line : 4 ,
200
- column : 21
199
+ column : 21 ,
200
+ endLine : 4 ,
201
+ endColumn : 44
201
202
} ,
202
203
{
203
204
message :
204
205
'Expected newline between consequent and alternate of ternary expression.' ,
205
206
line : 4 ,
206
- column : 47
207
+ column : 47 ,
208
+ endLine : 4 ,
209
+ endColumn : 62
207
210
}
208
211
]
209
212
} ,
@@ -220,8 +223,7 @@ tester.run('multiline-ternary', rule, {
220
223
}
221
224
</style>
222
225
` ,
223
- output : semver . gte ( ESLint . version , '7.1.0' )
224
- ? `
226
+ output : `
225
227
<template>
226
228
<div class="test">
227
229
</div>
@@ -233,20 +235,23 @@ tester.run('multiline-ternary', rule, {
233
235
: thisCantFitOnASingleLine')
234
236
}
235
237
</style>
236
- `
237
- : null ,
238
+ ` ,
238
239
errors : [
239
240
{
240
241
message :
241
242
'Expected newline between test and consequent of ternary expression.' ,
242
243
line : 8 ,
243
- column : 30
244
+ column : 30 ,
245
+ endLine : 8 ,
246
+ endColumn : 53
244
247
} ,
245
248
{
246
249
message :
247
250
'Expected newline between consequent and alternate of ternary expression.' ,
248
251
line : 8 ,
249
- column : 56
252
+ column : 56 ,
253
+ endLine : 8 ,
254
+ endColumn : 71
250
255
}
251
256
]
252
257
} ,
@@ -263,8 +268,7 @@ tester.run('multiline-ternary', rule, {
263
268
let test = someReallyLongCondition ? aVeryLongOutput : thisCantFitOnASingleLine
264
269
</script>
265
270
` ,
266
- output : semver . gte ( ESLint . version , '7.1.0' )
267
- ? `
271
+ output : `
268
272
<template>
269
273
<div :class="{
270
274
'test': someReallyLongCondition
@@ -276,20 +280,23 @@ tester.run('multiline-ternary', rule, {
276
280
<script>
277
281
let test = someReallyLongCondition ? aVeryLongOutput : thisCantFitOnASingleLine
278
282
</script>
279
- `
280
- : null ,
283
+ ` ,
281
284
errors : [
282
285
{
283
286
message :
284
287
'Expected newline between test and consequent of ternary expression.' ,
285
288
line : 4 ,
286
- column : 19
289
+ column : 19 ,
290
+ endLine : 4 ,
291
+ endColumn : 42
287
292
} ,
288
293
{
289
294
message :
290
295
'Expected newline between consequent and alternate of ternary expression.' ,
291
296
line : 4 ,
292
- column : 45
297
+ column : 45 ,
298
+ endLine : 4 ,
299
+ endColumn : 60
293
300
}
294
301
]
295
302
}
0 commit comments