forked from OSchip/llvm-project
clang-format: [JS] do not merge side-effect imports.
The if condition was testing the current element, but forgot to check the previous element (doh), so it would fail depending on sort order of the imports. Differential Revision: https://reviews.llvm.org/D101020
This commit is contained in:
parent
79cb3ba08f
commit
fbc6f42dbe
|
@ -271,6 +271,7 @@ private:
|
|||
// import Default from 'foo'; on either previous or this.
|
||||
// mismatching
|
||||
if (Reference->Category == JsModuleReference::SIDE_EFFECT ||
|
||||
PreviousReference->Category == JsModuleReference::SIDE_EFFECT ||
|
||||
Reference->IsExport != PreviousReference->IsExport ||
|
||||
!PreviousReference->Prefix.empty() || !Reference->Prefix.empty() ||
|
||||
!PreviousReference->DefaultImport.empty() ||
|
||||
|
|
|
@ -364,6 +364,13 @@ TEST_F(SortImportsTestJS, MergeImports) {
|
|||
// do merge exports
|
||||
verifySort("export {A, B} from 'foo';\n", "export {A} from 'foo';\n"
|
||||
"export {B} from 'foo';");
|
||||
|
||||
// do not merge side effect imports with named ones
|
||||
verifySort("import './a';\n"
|
||||
"\n"
|
||||
"import {bar} from './a';\n",
|
||||
"import {bar} from './a';\n"
|
||||
"import './a';\n");
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
|
Loading…
Reference in New Issue