From bc2f7977c28638b69a6e7e7fe24315acd1b24db9 Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Sat, 1 Oct 2022 22:29:23 -0500 Subject: [PATCH] add ts version satisfies --- tests/src/rules/no-duplicates.js | 39 ++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/tests/src/rules/no-duplicates.js b/tests/src/rules/no-duplicates.js index 97dfe3413d..263d861f36 100644 --- a/tests/src/rules/no-duplicates.js +++ b/tests/src/rules/no-duplicates.js @@ -1,5 +1,5 @@ import * as path from 'path'; -import { test as testUtil, getNonDefaultParsers, parsers } from '../utils'; +import { test as testUtil, getNonDefaultParsers, parsers, tsVersionSatisfies, typescriptEslintParserSatisfies } from '../utils'; import { RuleTester } from 'eslint'; import eslintPkg from 'eslint/package.json'; @@ -468,19 +468,6 @@ context('TypeScript', function () { `, ...parserConfig, }), - // #2470: ignore duplicate if is a typescript inline type import - test({ - code: "import { type x } from './foo'; import y from './foo'", - ...parserConfig, - }), - test({ - code: "import { type x } from './foo'; import { y } from './foo'", - ...parserConfig, - }), - test({ - code: "import { type x } from './foo'; import type y from 'foo'", - ...parserConfig, - }), ], invalid: [ test({ @@ -533,6 +520,30 @@ context('TypeScript', function () { }, ], }), + ], + }); + + if (!tsVersionSatisfies('>= 4.5') || !typescriptEslintParserSatisfies('>= 5.7.0')) { + return; + } + + ruleTester.run('no-duplicates inline type', rule, { + valid: [ + // #2470: ignore duplicate if is a typescript inline type import + test({ + code: "import { type x } from './foo'; import y from './foo'", + ...parserConfig, + }), + test({ + code: "import { type x } from './foo'; import { y } from './foo'", + ...parserConfig, + }), + test({ + code: "import { type x } from './foo'; import type y from 'foo'", + ...parserConfig, + }), + ], + invalid: [ test({ code: "import {type x} from './foo'; import type {y} from './foo'", ...parserConfig,