prefer-hooks-on-top
Configuration
rslint.config.ts
Rule Details
Suggest placing Jest lifecycle hooks before any test cases in the same scope.
Hooks (beforeAll, beforeEach, afterEach, afterAll) can appear anywhere in a
describe callback, but Jest always runs them in a fixed order regardless of where
they are written. Mixing hooks with test / it calls makes that execution order
harder to follow, so this rule reports hooks registered after the first test case
in the same scope.
Examples of incorrect code for this rule:
Examples of correct code for this rule: