E.g. sort import {b, a} from 'x'; into import {a, b} from 'x';.
Details
Diff Detail
Event Timeline
In general, this is lacking test cases for imports that are wrapped over multiple lines to start with. Should probably add those both for the old and for the new behavior.
lib/Format/Format.cpp | ||
---|---|---|
1229–1230 | I think it's not even worth storing this variable now. | |
lib/Format/SortJavaScriptImports.cpp | ||
46 | Maybe add a comment on why you are ignoring 'Range' for comparison. | |
195 | nit: no braces | |
259 | I think it's safe to pass the symbols as const reference here. |
Done regarding the tests. We do have an unrelated issue with formatting import {x as foo}, will send a fix later.
Done regarding the tests. We do have an unrelated issue with formatting import {x as foo}, will send a fix later.
lib/Format/SortJavaScriptImports.cpp | ||
---|---|---|
274 | It's an implementation detail that the iterator of a SmallVector is a JsImportedSymbol*. Use auto. Also, I find this more readable: for (auto I = Symbols.begin(), E = Symbols.end(); I != E; ++I) { if (I != Symbols.begin()) Buffer += ","; Buffer += getSourceText(I->Range); } |
I think it's not even worth storing this variable now.