eslint-plugin-jest-formatting

raw JSON →
3.1.0 verified Sat Apr 25 auth: no javascript

ESLint plugin providing formatting rules for Jest test suites, version 3.1.0 (supports ESLint 8.x). It enforces consistent padding (blank lines) around test blocks like describe, test, after-all, etc. Most rules are auto-fixable. Differentiators: focused solely on formatting (not linting logic), with recommended and strict config presets. Release cadence is sporadic; last major was v3.0.0 with breaking changes. Active maintenance status.

error Definition for rule 'jest-formatting/padding-around-describe-blocks' was not found.
cause Plugin not installed or not in ESLint plugins config.
fix
Run 'npm install eslint-plugin-jest-formatting --save-dev' and add 'jest-formatting' to plugins in .eslintrc.
error ESLint couldn't find the config "plugin:jest-formatting/recommended".
cause Missing 'plugin:' prefix in extends.
fix
Use 'extends: ["plugin:jest-formatting/recommended"]' instead of 'extends: ["jest-formatting/recommended"]'.
breaking Breaking change in v3.0.0: Padding is no longer enforced between statements and awaited statements of the same kind.
fix Review tests that relied on padding between consecutive awaits or sync statements; adjust expectations accordingly.
breaking Breaking change in v3.0.0: Removed deprecated rules (padding-before-*).
fix Migrate to the new padding-around-* rules (e.g., padding-around-test-blocks instead of padding-before-test-blocks).
breaking Breaking change in v2.0.0: Minimum Node version raised to ^10.12.0 || >=12.0.0.
fix Update Node to a supported version (10.12+ or 12+).
deprecated Old rule names like 'padding-before-test-blocks' are deprecated in v1.1.1+.
fix Use new rule names: 'padding-around-test-blocks' etc.
npm install eslint-plugin-jest-formatting
yarn add eslint-plugin-jest-formatting
pnpm add eslint-plugin-jest-formatting

Configures ESLint to enforce padding around describe and test blocks in Jest files.

// .eslintrc.json
{
  "plugins": ["jest-formatting"],
  "rules": {
    "jest-formatting/padding-around-describe-blocks": 2,
    "jest-formatting/padding-around-test-blocks": 2
  }
}

// test file example
describe('suite', () => {
  beforeEach(() => {
    jest.clearAllMocks();
  });

  it('test', () => {
    expect(true).toBe(true);
  });
});