Closed Ericlm closed 1 week ago
Looking at the rule, it looks like there is a hasContentBetweenNodes
function that build groups of imports to be sorted later. That allows the rule to handle multiple import groups (not the user-defined groups, but groups defined by the presence of content around them) inside the same file.
import { } from 'b' // Group with single import statement
const val = 2
// Group with two import statements, they will be sorted
import { } from 'a' // Not required to be on top of 'b'
import { } from 'c' // Cannot be on top of 'a'
I think it would be great to ignore statements between import so that imports are always sorted in one group. And then that's up to the dev to chose where this block goes (very often at the top I think.)
I'm gonna close it as it is more something like "put imports first" :)
Describe the rule
The rule would check that all imports are at the top of the file, to ensure that:
Code example
This is the code that should be reported (from a Vue project) :
Additional comments
Validations