Skip to content

Commit 5d5a2d8

Browse files
committed
inlineTypeImport to preferInline
1 parent 5d26984 commit 5d5a2d8

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/rules/no-duplicates.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ import * from './mod.js?minify'
6969

7070
### Inline Type imports
7171

72-
TypeScript 4.5 introduced a new [feature](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names) that allows mixing of named value and type imports. In order to support fixing to an inline type import when duplicate imports are detected, `inlineTypeImport` can be set to true.
72+
TypeScript 4.5 introduced a new [feature](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names) that allows mixing of named value and type imports. In order to support fixing to an inline type import when duplicate imports are detected, `preferInline` can be set to true.
7373

7474
Config:
7575

7676
```json
77-
"import/no-duplicates": ["error", {"inlineTypeImport": true}]
77+
"import/no-duplicates": ["error", {"preferInline": true}]
7878
```
7979

8080
```js

src/rules/no-duplicates.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ function getFix(first, rest, sourceCode, context) {
109109
const [specifiersText] = specifiers.reduce(
110110
([result, needsComma], specifier) => {
111111
const isTypeSpecifier = specifier.importNode.importKind === 'type';
112-
const inlineTypeImport = context.options[0] && context.options[0].inlineTypeImport;
113-
const insertText = `${inlineTypeImport && isTypeSpecifier ? 'type ' : ''}${specifier.text}`;
112+
const preferInline = context.options[0] && context.options[0].preferInline;
113+
const insertText = `${preferInline && isTypeSpecifier ? 'type ' : ''}${specifier.text}`;
114114
return [
115115
needsComma && !specifier.isEmpty
116116
? `${result},${insertText}`
@@ -260,7 +260,7 @@ module.exports = {
260260
considerQueryString: {
261261
type: 'boolean',
262262
},
263-
inlineTypeImport: {
263+
preferInline: {
264264
type: 'boolean',
265265
},
266266
},

tests/src/rules/no-duplicates.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ context('TypeScript', function () {
538538
test({
539539
code: "import {type x} from './foo'; import type {y} from './foo'",
540540
...parserConfig,
541-
options: [{ 'inlineTypeImport': false }],
541+
options: [{ 'preferInline': false }],
542542
output: `import {type x,y} from './foo'; `,
543543
errors: [
544544
{
@@ -556,7 +556,7 @@ context('TypeScript', function () {
556556
test({
557557
code: "import {type x} from 'foo'; import type {y} from 'foo'",
558558
...parserConfig,
559-
options: [{ 'inlineTypeImport': true }],
559+
options: [{ 'preferInline': true }],
560560
output: `import {type x,type y} from 'foo'; `,
561561
errors: [
562562
{

0 commit comments

Comments
 (0)