Skip to content

afterEachPaddingLines

Enforces padding around afterEach blocks.

✅ This rule is included in the vitest stylisticStrict presets.

Blank lines around afterEach() hooks make per-test cleanup easier to spot when reading a suite. They also keep teardown steps visually distinct from setup, assertions, and neighboring hooks.

import { afterEach, describe } from "vitest";
const cleanup = {
reset() {},
};
afterEach(() => {
cleanup.reset();
});
describe("cache", () => {
// ...
});
import { afterEach, describe } from "vitest";
describe("worker", () => {
const cache = {
clear() {},
};
const mocks = {
restore() {},
};
afterEach(() => {
cache.clear();
});
afterEach(() => {
mocks.restore();
});
});

This rule is not configurable.

If your team prefers keeping afterEach() hooks tightly attached to the statements they clean up, the extra vertical space from this rule may not help. That can be reasonable in very small files where the teardown flow is already obvious.

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