Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort import and require independently #10

Closed
sindresorhus opened this issue Apr 15, 2016 · 2 comments
Closed

Sort import and require independently #10

sindresorhus opened this issue Apr 15, 2016 · 2 comments

Comments

@sindresorhus
Copy link

sindresorhus commented Apr 15, 2016

I sometimes have to use both import and require as require is less strict. Like achieving lazy requiring or requiring without a cache (for testing). I think they should be sorted independently as import should be at the top, which makes it hard to mix them.

Example: https://github.com/sindresorhus/atom-editorconfig/blob/0a32ee50684aa390d787ee5099cb11c31c94eedd/index.js#L4

@jamestalmage
Copy link

It's possible to mix, but imports are hoisted - so they will be evaluated first regardless.

That's a good reason to make this a rule though. If your import has side effects - the hoisting behavior can be confusing if you try to require something a line above an import that causes side effects.

Enforcing the rule puts them.in the order they would be evaluated anyways

@sindresorhus
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants