Skip to content

Commit deda324

Browse files
committed
fix(prefer-export-from): type-import removed when using namespace import
1 parent 44e2394 commit deda324

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

rules/prefer-export-from.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ function getFixFunction({
8383
/** @param {import('eslint').Rule.RuleFixer} fixer */
8484
return function * (fixer) {
8585
if (imported.name === NAMESPACE_SPECIFIER_NAME) {
86+
const maybeType = shouldExportAsType ? '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

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

Lines changed: 3 additions & 3 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
@@ -2266,7 +2266,7 @@ Generated by [AVA](https://avajs.dev).
22662266
`␊
22672267
1 |␊
22682268
2 |␊
2269-
3 | export * as X from 'foo';␊
2269+
3 | export type * as X from 'foo';␊
22702270
`
22712271

22722272
> 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
10 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)