Skip to content

Commit

Permalink
Only run tests using typescript-eslint-parser on eslint@<6
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepsteak committed Jun 23, 2019
1 parent c2b19d0 commit d9b7258
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tests/src/core/getExports.js
Expand Up @@ -336,13 +336,16 @@ describe('ExportMap', function () {

const configs = [
// ['string form', { 'typescript-eslint-parser': '.ts' }],
['array form', { 'typescript-eslint-parser': ['.ts', '.tsx'] }],
]

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

if (semver.satisfies(eslintPkg.version, '<6.0.0')) {
configs.push(['array form', { 'typescript-eslint-parser': ['.ts', '.tsx'] }])
}

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

describe(description, function () {
Expand Down
6 changes: 5 additions & 1 deletion tests/src/rules/export.js
Expand Up @@ -112,12 +112,16 @@ ruleTester.run('export', rule, {

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

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

if (semver.satisfies(eslintPkg.version, '<6.0.0')) {
parsers.push(require.resolve('typescript-eslint-parser'))
}

parsers.forEach((parser) => {
const parserConfig = {
parser: parser,
Expand Down
6 changes: 5 additions & 1 deletion tests/src/rules/named.js
Expand Up @@ -286,12 +286,16 @@ ruleTester.run('named (export *)', rule, {

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

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

if (semver.satisfies(eslintPkg.version, '<6.0.0')) {
parsers.push(require.resolve('typescript-eslint-parser'))
}

parsers.forEach((parser) => {
['typescript', 'typescript-declare', 'typescript-export-assign'].forEach((source) => {
ruleTester.run(`named`, rule, {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/order.js
Expand Up @@ -1373,7 +1373,7 @@ ruleTester.run('order', rule, {
}],
})),
// fix incorrect order with typescript-eslint-parser
test({
testVersion('<6.0.0', {
code: `
var async = require('async');
var fs = require('fs');
Expand Down

0 comments on commit d9b7258

Please sign in to comment.