Skip to content

expectGroupPaddingLines

Enforces padding around expect groups.

✅ This rule is included in the vitest stylisticStrict presets.

Keeping related expect() calls together and separating them from setup or other statements makes assertions easier to scan. This rule enforces blank lines around assertion groups while still allowing consecutive expect() or expectTypeOf() calls to stay grouped.

import { expect, test } from "vitest";
test("value", () => {
let count = 123;
expect(count).toEqual(123);
expect(123).toEqual(count);
count = 456;
expect(count).toEqual(456);
});
import { expectTypeOf, test } from "vitest";
test("types", () => {
const value = 123;
expectTypeOf(value).toBeNumber();
expectTypeOf(value).toBeNumber();
const text = "abc";
// Comment
expectTypeOf(text).toBeString();
expectTypeOf(text).toBeString();
});

This rule is not configurable.

If your team prefers mixing setup, logging, and assertions without extra whitespace, this rule may feel too rigid. That can be reasonable in very short tests where assertion boundaries are already obvious.

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