Skip to content

Reorder imports#11359

Merged
gaearon merged 2 commits intofacebook:masterfrom
gaearon:sort-reqs
Oct 25, 2017
Merged

Reorder imports#11359
gaearon merged 2 commits intofacebook:masterfrom
gaearon:sort-reqs

Conversation

@gaearon
Copy link
Collaborator

@gaearon gaearon commented Oct 25, 2017

I want to group package-level imports separately from imports reaching into other packages. I think this provides a better mental picture of what’s being shared between renderers. We were also sort of doing this with fbjs anyway before, now we just have more packages.

I think this is especially useful in DOM client code where there’s a mix of local DOM-specific ../events and global events/ references. Same with local ../shared and global shared/.

In the past we used the “separate import” convention for lowercase modules like isCustomElement but I don’t see much sense in this grouping. It doesn’t convey a real semantic difference.

Finally, I don’t care too strongly about this. Not enough to enforce it via lint yet. But after ES modules are done, and we don‘t have weird requires in __DEV__ blocks I’d be happy to automatically enforce it with an autofix lint rule that would run right before Prettier.

I verified FB and open source bundles still work.

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaearon gaearon merged commit 087c48b into facebook:master Oct 25, 2017
@gaearon gaearon deleted the sort-reqs branch October 25, 2017 18:09
Ethan-Arrowood pushed a commit to Ethan-Arrowood/react that referenced this pull request Dec 8, 2017
* Reorder imports

* Record sizes
NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
* Reorder imports

* Record sizes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants