Skip to content

beforeAllPaddingLines

Enforces padding around beforeAll blocks.

✅ This rule is included in the vitest stylisticStrict presets.

Blank lines around beforeAll() hooks make one-time suite setup easier to notice. They also separate expensive or shared initialization from nearby suite declarations and other setup code.

import { beforeAll, describe } from "vitest";
const database = {
connect() {},
};
beforeAll(() => {
database.connect();
});
describe("database", () => {
// ...
});
import { beforeAll, describe } from "vitest";
describe("queue", () => {
const cache = {
warm() {},
};
const worker = {
start() {},
};
beforeAll(() => {
cache.warm();
});
beforeAll(() => {
worker.start();
});
});

This rule is not configurable.

If your suites are very small and beforeAll() hooks are always immediately adjacent to the state they initialize, the extra spacing may not improve readability. That tradeoff can be reasonable when your team prefers denser test files.

Made with ❤️‍🔥 around the world by the Flint team and contributors.