close

padding-around-after-each-blocks

Added in v0.9.2

Configuration

rslint.config.ts
import { defineConfig, jestPlugin } from '@rslint/core';

export default defineConfig([
  jestPlugin.configs.recommended,
  {
    rules: {
      'jest/padding-around-after-each-blocks': 'error',
    },
  },
]);

Rule Details

Require a blank line before and after afterEach statements. No trailing blank line is required when the hook is the last statement in its scope.

Incorrect

const database = createDatabase();
afterEach(() => database.reset());
test('loads a user', loadUser);

Correct

const database = createDatabase();

afterEach(() => database.reset());

test('loads a user', loadUser);

Autofix

The rule inserts missing blank lines before and after afterEach statements.

Original Documentation