Skip to content

Commit 4345915

Browse files
committed
prefer-export-from: type-import removed when using namespace import
1 parent 44e2394 commit 4345915

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

rules/prefer-export-from.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ function getFixFunction({
8383
/** @param {import('eslint').Rule.RuleFixer} fixer */
8484
return function * (fixer) {
8585
if (imported.name === NAMESPACE_SPECIFIER_NAME) {
86+
const maybeType = imported.isTypeImport ? 'type ' : '';
8687
yield fixer.insertTextAfter(
8788
program,
88-
`\nexport * as ${exported.text} ${getSourceAndAssertionsText(importDeclaration, sourceCode)}`,
89+
`\nexport ${maybeType}* as ${exported.text} ${getSourceAndAssertionsText(importDeclaration, sourceCode)}`,
8990
);
9091
} else {
9192
let specifierText = exported.name === imported.name
9293
? exported.text
9394
: `${imported.text} as ${exported.text}`;
9495

95-
// Add an inline type specifier if the value is a type and the export deceleration is a value deceleration
96+
// Add an inline type specifier if the value is a type and the export declaration is a value declaration
9697
if (shouldExportAsType && (!exportDeclaration || exportDeclaration.exportKind !== 'type')) {
9798
specifierText = `type ${specifierText}`;
9899
}

test/snapshots/prefer-export-from.js.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ Generated by [AVA](https://avajs.dev).
22412241
`␊
22422242
1 |␊
22432243
2 |␊
2244-
3 | export * as X from 'foo';␊
2244+
3 | export type * as X from 'foo';␊
22452245
`
22462246

22472247
> Error 1/1
@@ -2291,7 +2291,7 @@ Generated by [AVA](https://avajs.dev).
22912291
`␊
22922292
1 |␊
22932293
2 |␊
2294-
3 | export * as X from 'foo';␊
2294+
3 | export type * as X from 'foo';␊
22952295
`
22962296

22972297
> Error 1/1
12 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)