hooks-order
July 23, 2026 ยท View on GitHub
๐ Enforce a consistent order of hook declarations.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
๐ง This rule is automatically fixable by the --fix CLI option.
Enforce a consistent declaration order for node:test hooks. The canonical order is: before, beforeEach, afterEach, after.
Examples
import {describe, before, beforeEach, afterEach, after} from 'node:test';
// โ
describe('user', () => {
afterEach(() => {});
before(() => {});
});
// โ
describe('user', () => {
before(() => {});
beforeEach(() => {});
afterEach(() => {});
after(() => {});
});