Skip to content

Commit

Permalink
fix(parseStaticImport): omit empty import names (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
patzick authored Feb 23, 2024
1 parent 5d5ce86 commit 83699b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function parseStaticImport(
const _match = namedImport.match(/^\s*(\S*) as (\S*)\s*$/);
const source = _match?.[1] || namedImport.trim();
const importName = _match?.[2] || source;
if (!TYPE_RE.test(source)) {
if (source && !TYPE_RE.test(source)) {
namedImports[source] = importName;
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const staticTests: Record<
member3: "alias3",
},
},
'import { memberFormattedWithPrettier, } from "module-name";': {
specifier: "module-name",
namedImports: {
memberFormattedWithPrettier: "memberFormattedWithPrettier",
},
},
'import { member1, /* member0point5, */ member2 as alias2, member3 as alias3 } from "module-name";':
{
specifier: "module-name",
Expand Down

0 comments on commit 83699b6

Please sign in to comment.