afterEachPaddingLines
Enforces padding around
afterEachblocks.
✅ 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.
Examples
Section titled “Examples”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(); });});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(); });});Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 around the world by
the Flint team and contributors.