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'; +```