prefer-hooks-in-order
Configuration
rslint.config.ts
Rule Details
Prefer Jest lifecycle hooks in the same order Jest runs them.
Hooks can be written in any order, but Jest always executes them as:
beforeAllbeforeEachafterEachafterAll
This rule reports when a hook appears after a hook from a later stage in that sequence within the same consecutive group of hook calls. Matching source order to runtime order makes suite setup easier to read.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Also See
prefer-hooks-on-top— require hooks before test cases in the same scope