From 9f92d7c5f609ed55d1cc5415adaef69d80211a15 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 | 41 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/src/rules/no-duplicates.js b/tests/src/rules/no-duplicates.js index 97dfe3413d..ae8ead693d 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, @@ -603,7 +614,7 @@ context('TypeScript', function () { }, ], }), - ], + ] }); }); });