question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recommended import grouping and order?

See original GitHub issue

Is there a recommended import grouping and order for es6 modules?

python has some specifications in PEP as well as some logical extensions: https://code.google.com/p/soc/wiki/PythonStyleGuide#Imports_grouping_and_order

given that es6 imports are reversed, ie instead of:

from <module> import <function> (python) its import <function> from <module>

sorting by module isn’t as intuitive

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:7
  • Comments:5

github_iconTop GitHub Comments

44reactions
benknightcommented, Jun 16, 2016

I agree with @mhahn, perhaps because I’ve also spent a lot of time writing Python according to PEP8 standards.

Import ordering matters because:

  1. Code consistency. Broken windows theory.
  2. Easier to to visually scan and see dups.

It’s the same argument for any code style guideline, so simply saying it “doesn’t matter” isn’t really valid. Why does whitespace matter? Why do single versus double quotes matter?

29reactions
ljharbcommented, Jun 16, 2016

There’s already an eslint rule in our config that prevents dupes, so there’s no need for a human to ever worry about that anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the correct way to sort Python `import x` and `from x ...
Imports should be grouped in the following order: standard library imports; related third party imports; local application/library specific ...
Read more >
Rule: ordered-imports - Palantir Open Source
Requires that import statements be alphabetized and grouped. Enforce a consistent ordering for ES6 imports: Named imports must be alphabetized (i.e. “import {A, ......
Read more >
Sorting your imports correctly in React - DEV Community ‍ ‍
Sorting your imports in a JS file has a lot of benefits. First at all makes it easier to see what you imported...
Read more >
Golang imports sorting/grouping hell and painless tool to solve it
For a long time of being working as Golang Dev I saw that a lot of my coleagues don't pay attention on right...
Read more >
Sort TypeScript import groups from standard to local - vxlabs
Of course you are already making use of tslint's ordered-imports rule, which means your within group ordering is consistent. However, on that ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found