Skip to content

Commit e52da40

Browse files
committed
chore: add version checking to some test cases
1 parent 644f97d commit e52da40

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

Diff for: tests/lib/rules/no-implicit-coercion.js

+26-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*/
55
'use strict'
66

7-
const RuleTester = require('../../eslint-compat').RuleTester
7+
const { RuleTester, ESLint } = require('../../eslint-compat')
8+
const semver = require('semver')
89
const rule = require('../../../lib/rules/no-implicit-coercion')
910

1011
const tester = new RuleTester({
@@ -38,7 +39,9 @@ tester.run('no-implicit-coercion', rule, {
3839
]
3940
},
4041
`<template><div :data-foo="Number(foo)" /></template>`,
41-
`<template><div :data-foo="foo * 1/4" /></template>`,
42+
...(semver.gte(ESLint.version, '8.28.0')
43+
? [`<template><div :data-foo="foo * 1/4" /></template>`]
44+
: []),
4245
{
4346
filename: 'test.vue',
4447
code: `<template><div :data-foo="+foo" /></template>`,
@@ -169,22 +172,26 @@ tester.run('no-implicit-coercion', rule, {
169172
}
170173
]
171174
},
172-
{
173-
filename: 'test.vue',
174-
code: `<template><div :data-foo="\`\${foo}\`" /></template>`,
175-
output: `<template><div :data-foo="String(foo)" /></template>`,
176-
options: [
177-
{
178-
disallowTemplateShorthand: true
179-
}
180-
],
181-
errors: [
182-
{
183-
message: 'use `String(foo)` instead.',
184-
line: 1,
185-
column: 27
186-
}
187-
]
188-
}
175+
...(semver.gte(ESLint.version, '7.24.0')
176+
? [
177+
{
178+
filename: 'test.vue',
179+
code: `<template><div :data-foo="\`\${foo}\`" /></template>`,
180+
output: `<template><div :data-foo="String(foo)" /></template>`,
181+
options: [
182+
{
183+
disallowTemplateShorthand: true
184+
}
185+
],
186+
errors: [
187+
{
188+
message: 'use `String(foo)` instead.',
189+
line: 1,
190+
column: 27
191+
}
192+
]
193+
}
194+
]
195+
: [])
189196
]
190197
})

0 commit comments

Comments
 (0)