diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp --- a/clang/lib/Format/SortJavaScriptImports.cpp +++ b/clang/lib/Format/SortJavaScriptImports.cpp @@ -271,6 +271,7 @@ // import Default from 'foo'; on either previous or this. // mismatching if (Reference->Category == JsModuleReference::SIDE_EFFECT || + Reference->IsExport != PreviousReference->IsExport || !PreviousReference->Prefix.empty() || !Reference->Prefix.empty() || !PreviousReference->DefaultImport.empty() || !Reference->DefaultImport.empty() || Reference->Symbols.empty() || diff --git a/clang/unittests/Format/SortImportsTestJS.cpp b/clang/unittests/Format/SortImportsTestJS.cpp --- a/clang/unittests/Format/SortImportsTestJS.cpp +++ b/clang/unittests/Format/SortImportsTestJS.cpp @@ -355,6 +355,15 @@ "import {/* x */ X} from 'a';\n" "\n" "X + Y + Z;\n"); + + // do not merge imports and exports + verifySort("import {A} from 'foo';\n" + "export {B} from 'foo';", + "import {A} from 'foo';\n" + "export {B} from 'foo';"); + // do merge exports + verifySort("export {A, B} from 'foo';\n", "export {A} from 'foo';\n" + "export {B} from 'foo';"); } } // end namespace