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.
That's because those paths are in different groups. You can configure the rule like this and play with how the groups are combined or separated.
If I might be honest with you I couldn't understand much the usage and how to accomplish what I want with that config.
Specifying the groups, and mixing ['sibling', 'parent'] should achieve what you want.
It worked like this:
"import/order": [
"error",
{
"newlines-between": "always",
"groups": ["external", "parent"]
}
]
Thank you very much @ljharb
I'm sorry, I just noticed it didn't work, it's still putting a new line on local imports if it's in a different folder (group).
Try "groups": ["external", ["parent", "sibling"]]?
It worked, thank you very much @ljharb