Skip to content

Commit

Permalink
skip @typescript-eslint/parser tests on older eslint versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Schmadel committed Apr 3, 2019
1 parent 43353f5 commit 8355aaf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"nyc": "^11.9.0",
"redux": "^3.7.2",
"rimraf": "^2.6.3",
"semver": "^6.0.0",
"sinon": "^2.4.1",
"typescript": "^3.2.2",
"typescript-eslint-parser": "^22.0.0"
Expand Down
7 changes: 6 additions & 1 deletion tests/src/core/getExports.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { expect } from 'chai'
import semver from 'semver'
import { linter } from 'eslint'
import ExportMap from '../../../src/ExportMap'

import * as fs from 'fs'
Expand Down Expand Up @@ -315,9 +317,12 @@ describe('ExportMap', function () {
const configs = [
// ['string form', { 'typescript-eslint-parser': '.ts' }],
['array form', { 'typescript-eslint-parser': ['.ts', '.tsx'] }],
['array form', { '@typescript-eslint/parser': ['.ts', '.tsx'] }],
]

if (semver.satisfies(linter.version, '>5.0.0')) {
configs.push(['array form', { '@typescript-eslint/parser': ['.ts', '.tsx'] }])
}

configs.forEach(([description, parserConfig]) => {

describe(description, function () {
Expand Down
9 changes: 7 additions & 2 deletions tests/src/rules/named.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, SYNTAX_CASES } from '../utils'
import { RuleTester } from 'eslint'
import { RuleTester, linter } from 'eslint'
import semver from 'semver'

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

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

context('Typescript', function () {
// Typescript
const parsers = ['@typescript-eslint/parser', 'typescript-eslint-parser']
const parsers = ['typescript-eslint-parser']

if (semver.satisfies(linter.version, '>5.0.0')) {
parsers.push('@typescript-eslint/parser')
}

parsers.forEach((parser) => {
ruleTester.run('named', rule, {
Expand Down
6 changes: 3 additions & 3 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test } from '../utils'
import { test, testVersion } from '../utils'

import { RuleTester } from 'eslint'

Expand Down Expand Up @@ -1277,7 +1277,7 @@ ruleTester.run('order', rule, {
}],
}),
// fix incorrect order with @typescript-eslint/parser
test({
testVersion('>5.0.0', {
code: `
var async = require('async');
var fs = require('fs');
Expand All @@ -1292,5 +1292,5 @@ ruleTester.run('order', rule, {
message: '`fs` import should occur before import of `async`',
}],
}),
],
].filter((t) => !!t),
})
6 changes: 6 additions & 0 deletions tests/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import path from 'path'
import { linter } from 'eslint'
import semver from 'semver'

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

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

export function testVersion(specifier, t) {
return semver.satisfies(linter.version) && test(t)
}

export function test(t) {
return Object.assign({
filename: FILENAME,
Expand Down

0 comments on commit 8355aaf

Please sign in to comment.