Skip to content
← Back to rules

jest/padding-around-all Style

🛠️ An auto-fix is available for this rule.

What it does ​

This rule enforces padding around test framework functions. It combines the behavior of these rules:

  • padding-around-after-all-blocks
  • padding-around-after-each-blocks
  • padding-around-before-all-blocks
  • padding-around-before-each-blocks
  • padding-around-describe-blocks
  • padding-around-expect-groups
  • padding-around-test-blocks

Why is this bad? ​

Inconsistent formatting of code can make the code more difficult to read and follow. This rule helps ensure that hooks, test blocks, and assertion groups are visually separated from the rest of the code, making them easier to identify while looking through test files.

Examples ​

Examples of incorrect code for this rule:

js
const thing = 123;
beforeEach(() => {});
test("foo", () => {
  const value = 1;
  expect(value).toBe(1);
});

Examples of correct code for this rule:

js
const thing = 123;

beforeEach(() => {});

test("foo", () => {
  const value = 1;

  expect(value).toBe(1);
});

How to use ​

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["jest"],
  "rules": {
    "jest/padding-around-all": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jest"],
  rules: {
    "jest/padding-around-all": "error",
  },
});
bash
oxlint --deny jest/padding-around-all --jest-plugin

Version ​

This rule was added in vnext.

References ​