Skip to content

Commit f0eb917

Browse files
Andrew Schmadelljharb
Andrew Schmadel
authored andcommitted
skip @typescript-eslint/parser tests on older eslint versions
1 parent 3134ad3 commit f0eb917

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"nyc": "^11.9.0",
6969
"redux": "^3.7.2",
7070
"rimraf": "^2.6.3",
71+
"semver": "^6.0.0",
7172
"sinon": "^2.4.1",
7273
"typescript": "^3.2.2",
7374
"typescript-eslint-parser": "^22.0.0"

tests/src/core/getExports.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { expect } from 'chai'
2+
import semver from 'semver'
3+
import { linter } from 'eslint'
24
import ExportMap from '../../../src/ExportMap'
35

46
import * as fs from 'fs'
@@ -315,9 +317,12 @@ describe('ExportMap', function () {
315317
const configs = [
316318
// ['string form', { 'typescript-eslint-parser': '.ts' }],
317319
['array form', { 'typescript-eslint-parser': ['.ts', '.tsx'] }],
318-
['array form', { '@typescript-eslint/parser': ['.ts', '.tsx'] }],
319320
]
320321

322+
if (semver.satisfies(linter.version, '>5.0.0')) {
323+
configs.push(['array form', { '@typescript-eslint/parser': ['.ts', '.tsx'] }])
324+
}
325+
321326
configs.forEach(([description, parserConfig]) => {
322327

323328
describe(description, function () {

tests/src/rules/named.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test, SYNTAX_CASES } from '../utils'
2-
import { RuleTester } from 'eslint'
2+
import { RuleTester, linter } from 'eslint'
3+
import semver from 'semver'
34

45
import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'
56

@@ -256,7 +257,11 @@ ruleTester.run('named (export *)', rule, {
256257

257258
context('Typescript', function () {
258259
// Typescript
259-
const parsers = ['@typescript-eslint/parser', 'typescript-eslint-parser']
260+
const parsers = ['typescript-eslint-parser']
261+
262+
if (semver.satisfies(linter.version, '>5.0.0')) {
263+
parsers.push('@typescript-eslint/parser')
264+
}
260265

261266
parsers.forEach((parser) => {
262267
ruleTester.run('named', rule, {

tests/src/rules/order.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from '../utils'
1+
import { test, testVersion } from '../utils'
22

33
import { RuleTester } from 'eslint'
44

@@ -1277,7 +1277,7 @@ ruleTester.run('order', rule, {
12771277
}],
12781278
}),
12791279
// fix incorrect order with @typescript-eslint/parser
1280-
test({
1280+
testVersion('>5.0.0', {
12811281
code: `
12821282
var async = require('async');
12831283
var fs = require('fs');
@@ -1292,5 +1292,5 @@ ruleTester.run('order', rule, {
12921292
message: '`fs` import should occur before import of `async`',
12931293
}],
12941294
}),
1295-
],
1295+
].filter((t) => !!t),
12961296
})

tests/src/utils.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import path from 'path'
2+
import { linter } from 'eslint'
3+
import semver from 'semver'
24

35
// warms up the module cache. this import takes a while (>500ms)
46
import 'babel-eslint'
@@ -9,6 +11,10 @@ export function testFilePath(relativePath) {
911

1012
export const FILENAME = testFilePath('foo.js')
1113

14+
export function testVersion(specifier, t) {
15+
return semver.satisfies(linter.version) && test(t)
16+
}
17+
1218
export function test(t) {
1319
return Object.assign({
1420
filename: FILENAME,

0 commit comments

Comments
 (0)