Enforces padding around beforeEach blocks.
✅ This rule is included in the vitest preset.
Blank lines around beforeEach() hooks make per-test setup stand out from assertions and suite declarations.
They also help readers distinguish recurring setup work from the test cases that consume it.
AEimpo53 { beforeEach, describe <} sp ansty="le--0:#C792EA;--1:#8844">AEfr} sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dvite1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp><3;d ivclassNa="meec-li">d3;d>AEconsB0staAE =< {d ivclassNa="meec-li">nt< sp ansty="le--0:#82AAFF;--1:#3B61">B0res sp>11<()sp ansty="le--0:#C792EA;--1:#8844">AE {()sp> {d><},d ivclassNa="meec-li">A5},d><3;d ivclassNa="meec-li">B0beforeEa5<3(sp ansty="le--0:#D9F5DD;--1:#1111">113(sp><()sp ansty="le--0:#D6DEEB;--1:#403F">5()sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>3;d>< {d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53sta sp>AB0res53( {d><);d ivclassNa="meec-li">53});d><);d ivclassNa="meec-li">B0descri5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dsta1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#D9F5DD;--1:#1111">11, sp><()sp ansty="le--0:#D6DEEB;--1:#403F">5()sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>);d>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#919F9F;--1:#5D63">76// . sp> {d><..d ivclassNa="meec-li">53}<);d ivclassNa="meco"> { state.reset();});describe("state", () => { // ...}"><);d>);d>);d>AEimpo53 { beforeEach, describe <} sp ansty="le--0:#C792EA;--1:#8844">AEfr} sp>5<3 sp ansty="le--0:#D9F5DD;--1:#1111">13 sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dvite1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">51"sp><3;d ivclassNa="meec-li">d3;d>B0descri5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4Dwork1"sp>1<1"sp ansty="le--0:#D6DEEB;--1:#403F">531"sp><, sp ansty="le--0:#D9F5DD;--1:#1111">11, sp><()sp ansty="le--0:#D6DEEB;--1:#403F">5()sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEcons sp>B0cacAE = {d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#82AAFF;--1:#3B61">B0cle sp>11<()sp ansty="le--0:#C792EA;--1:#8844">AE {()sp> {d><},d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">A sp>5},d><3;d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEcons sp>B0mocAE =3;d>< {d ivclassNa="meec-li">nt < sp ansty="le--0:#82AAFF;--1:#3B61">B0resto sp>11<()sp ansty="le--0:#C792EA;--1:#8844">AE {()sp> {d><},d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">A sp>5},d><3;d ivclassNa="meec-li">nt< sp ansty="le--0:#82AAFF;--1:#3B61">B0beforeEa sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">113(sp><()sp ansty="le--0:#D6DEEB;--1:#403F">5()sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>3;d>< {d ivclassNa="meec-li">53 < sp ansty="le--0:#D6DEEB;--1:#403F">53cac sp>AB0cle53( {d><);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53} sp>);d><);d ivclassNa="meec-li">nt< sp ansty="le--0:#82AAFF;--1:#3B61">B0beforeEa sp>5<3(sp ansty="le--0:#D9F5DD;--1:#1111">113(sp><()sp ansty="le--0:#D6DEEB;--1:#403F">5()sp><3 sp ansty="le--0:#C792EA;--1:#8844">AE3 sp><=>sp ansty="le--0:#D6DEEB;--1:#403F">53=>sp>);d>< {d ivclassNa="meec-li">53 < sp ansty="le--0:#D6DEEB;--1:#403F">53moc sp>AB0resto53( {d><);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">53} sp>);d><);d ivclassNa="meec-li">53});d><);d ivclassNa="meco"> { const cache = { clear() {}, }; const mocks = { restore() {}, }; beforeEach(() => { cache.clear(); }); beforeEach(() => { mocks.restore(); });}"><);d>);d>);d> 44AEim3F53 { beforeEach, describ44AE31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dvi111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">c44AEco61B0s44AE< = {divclass="Nameec-">de61B0r11<11() spans="tyle--0:#C792EA;--1:#88">44AE11()> = >< {} ,divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}> {}>c61B0before311<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F53s53 >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0r4AE.>3F553 ><3() ;divclass="Nameec-">3F53()><3}) ;divclass="Nameec-">c3})>61B0desc31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Ds111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53, spans="tyle--0:#D9F5DD;--1:#11">1153, ><11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">de6376//53 >< .. .divclass="Nameec-">3F5 ..><3}) ;divclass="Name"> { state.reset();});describe("state", () => { // ..."><})>})>3})><;di vdivclass="Nameexpressive-">44AEim3F53 { beforeEach, describ44AE31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dvi111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3111">c61B0desc31<111" spans="tyle--0:#ECC48D;--1:#98">4E4Dwo111">1<111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53, spans="tyle--0:#D9F5DD;--1:#11">1153, ><11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">de44AEco61B0c44AE53 >< = {divclass="Nameec-">dent< spans="tyle--0:#82AAFF;--1:#3B">61B0c >11<11() spans="tyle--0:#C792EA;--1:#88">44AE11()> = >< {} ,divclass="Nameec-">444<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}> {}>de44AEco61B0m44AE< = {divclass="Nameec-">dent< spans="tyle--0:#82AAFF;--1:#3B">61B0res >11<11() spans="tyle--0:#C792EA;--1:#88">44AE11()> = >< {} ,divclass="Nameec-">444<4AE} spans="tyle--0:#D6DEEB;--1:#40">34AE}> {}>cde61B0before311<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">3F53< spans="tyle--0:#D6DEEB;--1:#40">3F53c >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0c4AE.>3F553 ><3() ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F553 >3()><3}) ;divclass="Nameec-">c3})>de61B0before311<11() spans="tyle--0:#D6DEEB;--1:#40">311()>44 spans="tyle--0:#D6DEEB;--1:#40">3F><53 {divclass="Nameec-">3F53< spans="tyle--0:#D6DEEB;--1:#40">3F53m >4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0res4AE.>3F553 ><3() ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">3F553 >3()><3}) ;divclass="Nameec-">3F53})><3}) ;divclass="Name"> { const cache = { clear() {}, }; const mocks = { restore() {}, }; beforeEach(() => { cache.clear(); }); beforeEach(() => { mocks.restore(); });"><})>})>3})>;di>
This rule is not configurable.
If you prefer beforeEach() hooks to stay visually attached to the code they prepare, this rule may add more vertical space than your team wants.
That can be a reasonable choice in short test files with minimal setup.