📝 Enforce hoisted APIs to be on top of the file.
all config.
💡 This rule is manually fixable by editor suggestions.
This rule disallows using APIs which are hoisted by vitest in positions where they look like runtime code.
Examples of incorrect code for this rule:
if (condition) {
vi.mock('some-module', () => {})
}if (condition) {
vi.unmock('some-module', () => {})
}if (condition) {
vi.hoisted(() => {})
}describe('suite', () => {
it('test', async () => {
vi.mock('some-module', () => {})
const sm = await import('some-module')
// ...
})
})Examples of correct code for this rule:
vi.mock('some-module', () => {})
describe('suite', () => {
it('test', async () => {
const sm = await import('some-module')
// ...
})
})vi.unmock(() => {})
if (condition) {
// ...
}vi.hoisted(() => {})
if (condition) {
// ...
}