Skip to content

Commit

Permalink
add ts version satisfies
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Oct 2, 2022
1 parent 2a18098 commit bc2f797
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions 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';
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bc2f797

Please sign in to comment.