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 9f92d7c
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions tests/src/rules/no-duplicates.js
Original file line number Diff line number Diff line change
@@ -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 Expand Up @@ -603,7 +614,7 @@ context('TypeScript', function () {
},
],
}),
],
]
});
});
});

0 comments on commit 9f92d7c

Please sign in to comment.