Skip to content

afterAllPaddingLines

Enforces padding around afterAll blocks.

✅ This rule is included in the vitest stylisticStrict presets.

Blank lines around afterAll() blocks make teardown code easier to spot when scanning a test file. They also keep long-lived cleanup logic visually separated from neighboring test setup and suite definitions.

import { afterAll, describe } from "vitest";
const server = {
close() {},
};
afterAll(() => {
server.close();
});
describe("server", () => {});
import { afterAll, describe } from "vitest";
describe("worker", () => {
const cache = {
clear() {},
};
const queue = {
stop() {},
};
afterAll(() => {
cache.clear();
});
afterAll(() => {
queue.stop();
});
});

This rule is not configurable.

If your team intentionally keeps afterAll() hooks tightly grouped with surrounding setup or suite declarations, the extra blank lines from this rule might add more vertical space than value. That can be reasonable in very small test files where the teardown flow is already obvious.

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