vitest/hoisted-apis-on-top
@vitest/eslint-plugin
Suggestion
eslint.config.js
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/hoisted-apis-on-top": "error",
},
},
];if (condition) {
vi.mock('some-module', () => {})
}if (condition) {
vi.unmock('some-module', () => {})
}if (condition) {
vi.hoisted(() => {})
}vi.mock('some-module', () => {})
describe('suite', () => {
it('test', async () => {
const sm = await import('some-module')
// ...
})
})vi.unmock(() => {})
if (condition) {
// ...
}vi.hoisted(() => {})
if (condition) {
// ...
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vitest/hoisted-apis-on-top
@vitest/eslint-plugin
import vitest from "@vitest/eslint-plugin";
export default [
{
plugins: { vitest },
rules: {
"vitest/hoisted-apis-on-top": "error",
},
},
];vitest/hoisted-apis-on-top
vitest plugin · correctness
{
"plugins": [
"vitest"
],
"rules": {
"vitest/hoisted-apis-on-top": "error"
}
}Biome does not have this rule.