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.

Import order rule

See original GitHub issue

Is there a rule that won’t allow local imports to be mixed with library imports? It would require an empty line between them, for example:

wrong:

import foo from 'foo'
import bar from 'bar'
import biz from './biz'
import boz from './taz/boz'

wrong:

import biz from './biz'
import foo from 'foo'
import bar from 'bar'
import boz from './taz/boz'

correct:

import foo from 'foo'
import bar from 'bar'

import biz from './biz'
import boz from './taz/boz'

I want to group libraries import on top and local imports bellow with a space between them.

I tried setting the rule to always for newlines-between but it’s adding a line between biz and boz as well.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
theprobugmakercommented, Jan 7, 2021

It worked, thank you very much @ljharb

1reaction
ljharbcommented, Jan 6, 2021

Try "groups": ["external", ["parent", "sibling"]]?

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-import/order.md at main - GitHub
import/order. This rule is automatically fixable by the --fix CLI option. Enforce a convention in the order of require() / import statements.
Read more >
sort-imports - ESLint - Pluggable JavaScript Linter
This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by...
Read more >
How to quickly configure ESLint for import sorting
In order to hook up this to ESLint we have to add a rule in the ESLint config file: "rules": { // ..other...
Read more >
Rule: ordered-imports - Palantir Open Source
Rule: ordered-imports · Named imports must be alphabetized (i.e. “import {A, B, C} from “foo”;”) · Import sources must be alphabetized within groups,...
Read more >
How to quickly configure ESLint for import ... - Relatable Code
With ESLint there are two options to flag errors or warnings when the imports are set in an incorrect order: sort-imports and with...
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