"import ... from '...';" and "export ... from '...';" should be treated the same
as goog.require/provide/module/forwardDeclare calls.
Details
- Reviewers
djasper
Diff Detail
Event Timeline
I am missing a decent explanation here. In contrast to C++ #includes as well as goog.require, etc. The import/export statements actually provide syntactic structure and can name multiple entities. Why would it be a good idea to always write them into a single line?
unittests/Format/FormatTestJS.cpp | ||
---|---|---|
948 | Really? |
As discussed offline, this matches existing very similar behaviour for destructured goog.require calls:
const {X, Y, Z} = goog.require('a'); // won't ever wrap import {X, Y, Z} from 'a'; // Shouldn't ever wrap
It also has the nice side effect that it prevents IWYU comments of the form:
import {X, Y, Z} from 'a'; // from //some/location
... from wrapping.
lib/Format/TokenAnnotator.cpp | ||
---|---|---|
772 | Can you actually have: export {a as from}; ? | |
775 | Not a big fan of the code duplication in this loop. How about doing: if (Style.Language == FormatStyle::LK_JavaScript && ((Line.First->is(tok::kw_export) && CurrentToken->is(Keywords.kw_from)) || isClosureImportStatement(*CurrentToken))) return LT_ImportStatement; in the lower loop? The ImportStatement variable can likely go away then. |
Can you actually have:
?