jest/padding-around-after-all-blocks
Require a blank line before each afterAll call
fixable
An afterAll hook right under another statement is easy to miss when you're looking for a file's cleanup code. A blank line above it makes it stand out.
The rule only checks the line above the call, not the line below. Comments directly above the call count as part of it, so the blank line goes above them. An afterAll that comes first in a file or in a describe callback doesn't need a blank line.
--fix inserts the blank line.
Configure#
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"jest/padding-around-after-all-blocks" = "error" # or "warn"Examples#
example.js1 problem
import { afterAll, describe } from "@jest/globals";
describe("database", () => {
const db = connect();
aMissing padding before afterAll blockfterAll(() => db.close());
});Two afterAll calls in a row need a blank line between them too:
example.js2 problems
import { afterAll } from "@jest/globals";
const server = startServer();
aMissing padding before afterAll blockfterAll(() => server.stop());
aMissing padding before afterAll blockfterAll(() => removeTempFiles());example.jsNo problems
import { afterAll, describe } from "@jest/globals";
describe("database", () => {
const db = connect();
// Close the connection so the process can exit.
afterAll(() => db.close());
});