diff --git a/tests/src/rules/first.js b/tests/src/rules/first.js index 9d27870677..05328e51e9 100644 --- a/tests/src/rules/first.js +++ b/tests/src/rules/first.js @@ -80,7 +80,6 @@ ruleTester.run('first', rule, { context('TypeScript', function () { getTSParsers() - .filter((parser) => parser !== require.resolve('typescript-eslint-parser')) .forEach((parser) => { const parserConfig = { parser, diff --git a/tests/src/rules/max-dependencies.js b/tests/src/rules/max-dependencies.js index bab38496e0..30e6951d3c 100644 --- a/tests/src/rules/max-dependencies.js +++ b/tests/src/rules/max-dependencies.js @@ -1,7 +1,7 @@ import { test, getTSParsers } from '../utils'; import { RuleTester } from 'eslint'; -import eslintPkg from 'eslint/package.json'; +import estreePkg from '@typescript-eslint/typescript-estree/package.json'; import semver from 'semver'; const ruleTester = new RuleTester(); @@ -91,7 +91,7 @@ ruleTester.run('max-dependencies', rule, { ], }); -(semver.satisfies(eslintPkg.version, '>5.0.0') ? describe.skip : describe)('TypeScript', () => { +(semver.satisfies(estreePkg.version, '<2.23.0') ? describe.skip : describe)('TypeScript', () => { getTSParsers().forEach((parser) => { ruleTester.run(`max-dependencies (${parser.replace(process.cwd(), '.')})`, rule, { valid: [ diff --git a/tests/src/rules/no-duplicates.js b/tests/src/rules/no-duplicates.js index e550b63ce7..f27c848434 100644 --- a/tests/src/rules/no-duplicates.js +++ b/tests/src/rules/no-duplicates.js @@ -4,6 +4,7 @@ import { test as testUtil, getNonDefaultParsers } from '../utils'; import { RuleTester } from 'eslint'; import eslintPkg from 'eslint/package.json'; import semver from 'semver'; +import estreePkg from '@typescript-eslint/typescript-estree/package.json'; const ruleTester = new RuleTester(); const rule = require('rules/no-duplicates'); @@ -415,9 +416,8 @@ import {x,y} from './foo' ], }); -context('TypeScript', function () { +(semver.satisfies(estreePkg.version, '<2.23.0') ? describe.skip : describe)('TypeScript', () => { getNonDefaultParsers() - .filter((parser) => parser !== require.resolve('typescript-eslint-parser')) .forEach((parser) => { const parserConfig = { parser, diff --git a/tests/src/rules/no-extraneous-dependencies.js b/tests/src/rules/no-extraneous-dependencies.js index 29604af170..5d7f75d928 100644 --- a/tests/src/rules/no-extraneous-dependencies.js +++ b/tests/src/rules/no-extraneous-dependencies.js @@ -3,7 +3,7 @@ import typescriptConfig from '../../../config/typescript'; import path from 'path'; import fs from 'fs'; import semver from 'semver'; -import eslintPkg from 'eslint/package.json'; +import estreePkg from '@typescript-eslint/typescript-estree/package.json'; import { RuleTester } from 'eslint'; import flatMap from 'array.prototype.flatmap'; @@ -380,8 +380,7 @@ ruleTester.run('no-extraneous-dependencies', rule, { ], }); -// TODO: figure out why these tests fail in eslint 4 -(semver.satisfies(eslintPkg.version, '^4') ? describe.skip : describe)('TypeScript', () => { +(semver.satisfies(estreePkg.version, '<2.23.0') ? describe.skip : describe)('TypeScript', () => { getTSParsers().forEach((parser) => { const parserConfig = { parser, @@ -391,63 +390,39 @@ ruleTester.run('no-extraneous-dependencies', rule, { }, }; - if (parser !== require.resolve('typescript-eslint-parser')) { - ruleTester.run('no-extraneous-dependencies', rule, { - valid: [ - test(Object.assign({ - code: 'import type T from "a";', - options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], - }, parserConfig)), - ], - invalid: [ - test(Object.assign({ - code: 'import T from "a";', - options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], - errors: [{ - message: "'a' should be listed in the project's dependencies, not devDependencies.", - }], - }, parserConfig)), - ], - }); - } else { - ruleTester.run('no-extraneous-dependencies', rule, { - valid: [], - invalid: [ - test(Object.assign({ - code: 'import T from "a"; /* typescript-eslint-parser */', - options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], - errors: [{ - message: "'a' should be listed in the project's dependencies, not devDependencies.", - }], - }, parserConfig)), - test(Object.assign({ - code: 'import type T from "a"; /* typescript-eslint-parser */', - options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], - errors: [{ - message: "'a' should be listed in the project's dependencies, not devDependencies.", - }], - }, parserConfig)), - ], - }); - } + ruleTester.run('no-extraneous-dependencies', rule, { + valid: [ + test(Object.assign({ + code: 'import type T from "a";', + options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], + }, parserConfig)), + ], + invalid: [ + test(Object.assign({ + code: 'import T from "a";', + options: [{ packageDir: packageDirWithTypescriptDevDependencies, devDependencies: false }], + errors: [{ + message: "'a' should be listed in the project's dependencies, not devDependencies.", + }], + }, parserConfig)), + ], + }); }); }); -if (semver.satisfies(eslintPkg.version, '>5.0.0')) { - typescriptRuleTester.run('no-extraneous-dependencies typescript type imports', rule, { - valid: [ - test({ - code: 'import type MyType from "not-a-dependency";', - filename: testFilePath('./no-unused-modules/typescript/file-ts-a.ts'), - parser: require.resolve('babel-eslint'), - }), - test({ - code: 'import type { MyType } from "not-a-dependency";', - filename: testFilePath('./no-unused-modules/typescript/file-ts-a.ts'), - parser: require.resolve('babel-eslint'), - }), - ], - invalid: [ - ], - }); -} +typescriptRuleTester.run('no-extraneous-dependencies typescript type imports', rule, { + valid: [ + test({ + code: 'import type MyType from "not-a-dependency";', + filename: testFilePath('./no-unused-modules/typescript/file-ts-a.ts'), + parser: require.resolve('babel-eslint'), + }), + test({ + code: 'import type { MyType } from "not-a-dependency";', + filename: testFilePath('./no-unused-modules/typescript/file-ts-a.ts'), + parser: require.resolve('babel-eslint'), + }), + ], + invalid: [ + ], +}); diff --git a/tests/src/rules/no-unresolved.js b/tests/src/rules/no-unresolved.js index 9e6db8c04b..e1d1ca5033 100644 --- a/tests/src/rules/no-unresolved.js +++ b/tests/src/rules/no-unresolved.js @@ -5,6 +5,8 @@ import { getTSParsers, test, SYNTAX_CASES, testVersion } from '../utils'; import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'; import { RuleTester } from 'eslint'; +import semver from 'semver'; +import estreePkg from '@typescript-eslint/typescript-estree/package.json'; const ruleTester = new RuleTester(); const rule = require('rules/no-unresolved'); @@ -442,8 +444,8 @@ ruleTester.run('import() with built-in parser', rule, { ), }); -context('TypeScript', () => { - getTSParsers().filter(x => x !== require.resolve('typescript-eslint-parser')).forEach((parser) => { +(semver.satisfies(estreePkg.version, '<2.23.0') ? describe.skip : describe)('TypeScript', () => { + getTSParsers().forEach((parser) => { ruleTester.run(`${parser}: no-unresolved ignore type-only`, rule, { valid: [ test({ diff --git a/tests/src/rules/order.js b/tests/src/rules/order.js index 146306259f..c39295962a 100644 --- a/tests/src/rules/order.js +++ b/tests/src/rules/order.js @@ -3,6 +3,7 @@ import { test, getTSParsers, getNonDefaultParsers } from '../utils'; import { RuleTester } from 'eslint'; import eslintPkg from 'eslint/package.json'; import semver from 'semver'; +import estreePkg from '@typescript-eslint/typescript-estree/package.json'; import flatMap from 'array.prototype.flatmap'; const ruleTester = new RuleTester(); @@ -2281,9 +2282,8 @@ ruleTester.run('order', rule, { }); -context('TypeScript', function () { +(semver.satisfies(estreePkg.version, '<2.23.0') ? describe.skip : describe)('TypeScript', () => { getNonDefaultParsers() - .filter((parser) => parser !== require.resolve('typescript-eslint-parser')) .forEach((parser) => { const parserConfig = { parser,