Skip to content

Commit 85c137b

Browse files
committed
[Tests] order/no-duplicates: make tests check actual eslint version instead of env var
1 parent 3c23c4c commit 85c137b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

tests/src/rules/no-duplicates.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import * as path from 'path';
22
import { test as testUtil, getNonDefaultParsers } from '../utils';
33

44
import { RuleTester } from 'eslint';
5+
import eslintPkg from 'eslint/package.json';
6+
import semver from 'semver';
57

68
const ruleTester = new RuleTester();
79
const rule = require('rules/no-duplicates');
810

9-
const test = process.env.ESLINT_VERSION === '3' || process.env.ESLINT_VERSION === '2'
11+
// autofix only possible with eslint 4+
12+
const test = semver.satisfies(eslintPkg.version, '< 4')
1013
? t => testUtil(Object.assign({}, t, { output: t.code }))
1114
: testUtil;
1215

tests/src/rules/order.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,9 @@ context('TypeScript', function () {
22572257
],
22582258
errors: [
22592259
{
2260-
message: process.env.ESLINT_VERSION === '2' ? '`bar` import should occur after import of `Bar`' : /(`bar` import should occur after import of `Bar`)|(`Bar` import should occur before import of `bar`)/,
2260+
message: semver.satisfies(eslintPkg.version, '< 3')
2261+
? '`bar` import should occur after import of `Bar`'
2262+
: /(`bar` import should occur after import of `Bar`)|(`Bar` import should occur before import of `bar`)/,
22612263
},
22622264
],
22632265
},
@@ -2293,7 +2295,9 @@ context('TypeScript', function () {
22932295
],
22942296
errors: [
22952297
{
2296-
message: process.env.ESLINT_VERSION === '2' ? '`bar` import should occur before import of `Bar`' : /(`bar` import should occur before import of `Bar`)|(`Bar` import should occur after import of `bar`)/,
2298+
message: semver.satisfies(eslintPkg.version, '< 3')
2299+
? '`bar` import should occur before import of `Bar`'
2300+
: /(`bar` import should occur before import of `Bar`)|(`Bar` import should occur after import of `bar`)/,
22972301
},
22982302
],
22992303
},

0 commit comments

Comments
 (0)