Import order rule
See original GitHub issueIs 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:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It worked, thank you very much @ljharb
Try
"groups": ["external", ["parent", "sibling"]]
?