44 */
55'use strict'
66
7- const { RuleTester, ESLint } = require ( '../../eslint-compat' )
7+ const { RuleTester } = require ( '../../eslint-compat' )
88const rule = require ( '../../../lib/rules/multiline-ternary' )
9- const semver = require ( 'semver' )
109
1110const tester = new RuleTester ( {
1211 languageOptions : {
@@ -80,8 +79,7 @@ tester.run('multiline-ternary', rule, {
8079 </div>
8180 </template>
8281 ` ,
83- output : semver . gte ( ESLint . version , '7.1.0' )
84- ? `
82+ output : `
8583 <template>
8684 <div :class="{
8785 'test': someReallyLongCondition ?
@@ -90,15 +88,16 @@ tester.run('multiline-ternary', rule, {
9088 }">
9189 </div>
9290 </template>
93- `
94- : null ,
91+ ` ,
9592 options : [ 'always-multiline' ] ,
9693 errors : [
9794 {
9895 message :
9996 'Expected newline between consequent and alternate of ternary expression.' ,
10097 line : 5 ,
101- column : 15
98+ column : 15 ,
99+ endLine : 5 ,
100+ endColumn : 30
102101 }
103102 ]
104103 } ,
@@ -113,23 +112,23 @@ tester.run('multiline-ternary', rule, {
113112 </div>
114113 </template>
115114 ` ,
116- output : semver . gte ( ESLint . version , '7.1.0' )
117- ? `
115+ output : `
118116 <template>
119117 <div :class="{
120118 'test': someReallyLongCondition ?aVeryLongOutput : thisCantFitOnASingleLine
121119 }">
122120 </div>
123121 </template>
124- `
125- : null ,
122+ ` ,
126123 options : [ 'never' ] ,
127124 errors : [
128125 {
129126 message :
130127 'Unexpected newline between test and consequent of ternary expression.' ,
131128 line : 4 ,
132- column : 21
129+ column : 21 ,
130+ endLine : 4 ,
131+ endColumn : 44
133132 }
134133 ]
135134 } ,
@@ -143,8 +142,7 @@ tester.run('multiline-ternary', rule, {
143142 </div>
144143 </template>
145144 ` ,
146- output : semver . gte ( ESLint . version , '7.1.0' )
147- ? `
145+ output : `
148146 <template>
149147 <div :class="{
150148 'test': someReallyLongCondition
@@ -153,20 +151,23 @@ tester.run('multiline-ternary', rule, {
153151 }">
154152 </div>
155153 </template>
156- `
157- : null ,
154+ ` ,
158155 errors : [
159156 {
160157 message :
161158 'Expected newline between test and consequent of ternary expression.' ,
162159 line : 4 ,
163- column : 21
160+ column : 21 ,
161+ endLine : 4 ,
162+ endColumn : 44
164163 } ,
165164 {
166165 message :
167166 'Expected newline between consequent and alternate of ternary expression.' ,
168167 line : 4 ,
169- column : 47
168+ column : 47 ,
169+ endLine : 4 ,
170+ endColumn : 62
170171 }
171172 ]
172173 } ,
@@ -180,8 +181,7 @@ tester.run('multiline-ternary', rule, {
180181 </div>
181182 </template>
182183 ` ,
183- output : semver . gte ( ESLint . version , '7.1.0' )
184- ? `
184+ output : `
185185 <template>
186186 <div :style="{
187187 'test': someReallyLongCondition
@@ -190,20 +190,23 @@ tester.run('multiline-ternary', rule, {
190190 }">
191191 </div>
192192 </template>
193- `
194- : null ,
193+ ` ,
195194 errors : [
196195 {
197196 message :
198197 'Expected newline between test and consequent of ternary expression.' ,
199198 line : 4 ,
200- column : 21
199+ column : 21 ,
200+ endLine : 4 ,
201+ endColumn : 44
201202 } ,
202203 {
203204 message :
204205 'Expected newline between consequent and alternate of ternary expression.' ,
205206 line : 4 ,
206- column : 47
207+ column : 47 ,
208+ endLine : 4 ,
209+ endColumn : 62
207210 }
208211 ]
209212 } ,
@@ -220,8 +223,7 @@ tester.run('multiline-ternary', rule, {
220223 }
221224 </style>
222225 ` ,
223- output : semver . gte ( ESLint . version , '7.1.0' )
224- ? `
226+ output : `
225227 <template>
226228 <div class="test">
227229 </div>
@@ -233,20 +235,23 @@ tester.run('multiline-ternary', rule, {
233235: thisCantFitOnASingleLine')
234236 }
235237 </style>
236- `
237- : null ,
238+ ` ,
238239 errors : [
239240 {
240241 message :
241242 'Expected newline between test and consequent of ternary expression.' ,
242243 line : 8 ,
243- column : 30
244+ column : 30 ,
245+ endLine : 8 ,
246+ endColumn : 53
244247 } ,
245248 {
246249 message :
247250 'Expected newline between consequent and alternate of ternary expression.' ,
248251 line : 8 ,
249- column : 56
252+ column : 56 ,
253+ endLine : 8 ,
254+ endColumn : 71
250255 }
251256 ]
252257 } ,
@@ -263,8 +268,7 @@ tester.run('multiline-ternary', rule, {
263268 let test = someReallyLongCondition ? aVeryLongOutput : thisCantFitOnASingleLine
264269 </script>
265270 ` ,
266- output : semver . gte ( ESLint . version , '7.1.0' )
267- ? `
271+ output : `
268272 <template>
269273 <div :class="{
270274 'test': someReallyLongCondition
@@ -276,20 +280,23 @@ tester.run('multiline-ternary', rule, {
276280 <script>
277281 let test = someReallyLongCondition ? aVeryLongOutput : thisCantFitOnASingleLine
278282 </script>
279- `
280- : null ,
283+ ` ,
281284 errors : [
282285 {
283286 message :
284287 'Expected newline between test and consequent of ternary expression.' ,
285288 line : 4 ,
286- column : 19
289+ column : 19 ,
290+ endLine : 4 ,
291+ endColumn : 42
287292 } ,
288293 {
289294 message :
290295 'Expected newline between consequent and alternate of ternary expression.' ,
291296 line : 4 ,
292- column : 45
297+ column : 45 ,
298+ endLine : 4 ,
299+ endColumn : 60
293300 }
294301 ]
295302 }
0 commit comments