From 9986655740af6f53da6e39dc1a53f0bf76ea438a Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Sun, 11 Aug 2024 13:42:42 -0700 Subject: [PATCH] fix: repair more problem with default imports --- .grit/patterns/js/_convert_default_imports.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.grit/patterns/js/_convert_default_imports.md b/.grit/patterns/js/_convert_default_imports.md index 3d38cb9e..c0b2587b 100644 --- a/.grit/patterns/js/_convert_default_imports.md +++ b/.grit/patterns/js/_convert_default_imports.md @@ -23,14 +23,17 @@ pattern replace_default_import($source, $new_name) { $imports <: contains `default` => $new_name }, `import $alias, { $imports } from $source` => `import { $imports } from $source` where { + $alias <: not ., if ($alias <: $new_name) { $imports += `, $new_name`, } else { $imports += `, $new_name as $alias` } }, - `import $alias from $source` as $import where { - if ($alias <: contains $new_name) { + `import $clause from $source` as $import where { + $clause <: import_clause(default=$alias), + $alias <: not ., + if ($alias <: $new_name) { $import => `import { $new_name } from $source` } else { $import => `import { $new_name as $alias } from $source` @@ -193,3 +196,10 @@ export { namedImport as name1 } from 'here'; export { namedImport, otherImport } from 'here'; export { otherImport, namedImport as name2 } from 'here'; ``` + +## Leave non-default imports unchanged + +```ts +import { namedImport } from 'here'; +import { twoPartImport, namedImport as alias } from 'here'; +```