|
4 | 4 | */ |
5 | 5 | 'use strict' |
6 | 6 |
|
7 | | -const RuleTester = require('../../eslint-compat').RuleTester |
| 7 | +const { RuleTester, ESLint } = require('../../eslint-compat') |
| 8 | +const semver = require('semver') |
8 | 9 | const rule = require('../../../lib/rules/no-implicit-coercion') |
9 | 10 |
|
10 | 11 | const tester = new RuleTester({ |
@@ -38,7 +39,9 @@ tester.run('no-implicit-coercion', rule, { |
38 | 39 | ] |
39 | 40 | }, |
40 | 41 | `<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 | + : []), |
42 | 45 | { |
43 | 46 | filename: 'test.vue', |
44 | 47 | code: `<template><div :data-foo="+foo" /></template>`, |
@@ -169,22 +172,26 @@ tester.run('no-implicit-coercion', rule, { |
169 | 172 | } |
170 | 173 | ] |
171 | 174 | }, |
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 | + : []) |
189 | 196 | ] |
190 | 197 | }) |
0 commit comments