Skip to content

Commit

Permalink
dep-time-travel: use older versions of dependencies
Browse files Browse the repository at this point in the history
for tests against older ESLint versions.
  • Loading branch information
Ben Mosher authored and ljharb committed Jan 17, 2019
1 parent 05c3935 commit 73080d0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -32,6 +32,7 @@ matrix:
node_js: 6
- env: PACKAGE=resolvers/webpack
node_js: 4

- os: osx
env: ESLINT_VERSION=5
node_js: 10
Expand All @@ -54,7 +55,7 @@ before_install:
- 'if [ -n "${PACKAGE-}" ]; then cd "${PACKAGE}"; fi'
install:
- npm install
- npm install --no-save eslint@$ESLINT_VERSION --ignore-scripts || true
- 'if [ -n "${ESLINT_VERSION}" ]; then ./tests/dep-time-travel.sh; fi'

script:
- 'npm test'
Expand Down
20 changes: 20 additions & 0 deletions tests/dep-time-travel.sh
@@ -0,0 +1,20 @@
#!/bin/bash

# expected: ESLINT_VERSION numeric env var

npm install --no-save eslint@$ESLINT_VERSION --ignore-scripts || true

# use these alternate typescript dependencies for ESLint < v4
if [[ "$ESLINT_VERSION" -lt "4" ]]; then
echo "Downgrading babel-eslint..."
npm i --no-save babel-eslint@8.0.3

echo "Downgrading TypeScript dependencies..."
npm i --no-save typescript-eslint-parser@15 typescript@2.8.1
fi

# typescript-eslint-parser 1.1.1+ is not compatible with node 6
if [[ "$TRAVIS_NODE_VERSION" -lt "8" ]]; then
echo "Downgrading eslint-import-resolver-typescript..."
npm i --no-save eslint-import-resolver-typescript@1.0.2
fi
4 changes: 2 additions & 2 deletions tests/src/core/getExports.js
Expand Up @@ -3,7 +3,7 @@ import ExportMap from '../../../src/ExportMap'

import * as fs from 'fs'

import { getFilename, skipESLints } from '../utils'
import { getFilename } from '../utils'
import * as unambiguous from 'eslint-module-utils/unambiguous'

describe('ExportMap', function () {
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('ExportMap', function () {

})

skipESLints([2, 3])('alternate parsers', function () {
context('alternate parsers', function () {

const configs = [
// ['string form', { 'typescript-eslint-parser': '.ts' }],
Expand Down
4 changes: 2 additions & 2 deletions tests/src/rules/named.js
@@ -1,4 +1,4 @@
import { test, SYNTAX_CASES, skipESLints } from '../utils'
import { test, SYNTAX_CASES } from '../utils'
import { RuleTester } from 'eslint'

import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'
Expand Down Expand Up @@ -254,7 +254,7 @@ ruleTester.run('named (export *)', rule, {
})


skipESLints([2, 3])("Typescript", function () {
context("Typescript", function () {
// Typescript
ruleTester.run("named", rule, {
valid: [
Expand Down
11 changes: 0 additions & 11 deletions tests/src/utils.js
Expand Up @@ -29,17 +29,6 @@ export function getFilename(file) {
return path.join(__dirname, '..', 'files', file || 'foo.js')
}

/**
* skip tests iff ESLINT_VERSION is in provided `versions` array
*/
export function skipESLints(versions) {
if (versions.indexOf(+process.env.ESLINT_VERSION) === -1) {
return describe
} else {
return describe.skip
}
}

/**
* to be added as valid cases just to ensure no nullable fields are going
* to crash at runtime
Expand Down

0 comments on commit 73080d0

Please sign in to comment.