Skip to content

accessorPairGroups

Reports getter and setter accessors for the same property that are not adjacent.

✅ This rule is included in the ts stylistic and stylisticStrict presets.

Grouping getters and setters together improves code readability. When a property has both a getter and a setter, defining them adjacent to each other makes it easier to understand how the property is accessed and modified.

AEcla5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Examp53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEg5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0val11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt < sp ansty="le--0:#C792EA;--1:#8844">AEretu5<3 sp ansty="le--0:#7FDBCA;--1:#096E">72thA72_val5<3;d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5<3}d ivclassNa="meec-li">nt< sp ansty="le--0:#82AAFF;--1:#3B61">B0otherMeth11<()sp ansty="le--0:#D6DEEB;--1:#403F">53 <{}d ivclassNa="meec-li">nt< sp ansty="le--0:#C792EA;--1:#8844">AEs5<3 sp ansty="le--0:#82AAFF;--1:#3B61">B0val1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53newVal7<2:sp ansty="le--0:#D6DEEB;--1:#403F">5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0numb1<1)sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72thA72_val5<3 sp ansty="le--0:#C792EA;--1:#8844">A53 newValu53< sp ansty="le--0:#D6DEEB;--1:#403F">5<3}d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEconsB0objeAE =< {d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">AEgeB0val11<()sp ansty="le--0:#C792EA;--1:#8844">AE< {d ivclassNa="meec-li">AE < sp ansty="le--0:#C792EA;--1:#8844">AEretur72thA72_valAAE< sp ansty="le--0:#C792EA;--1:#8844">AE<},d ivclassNa="meec-li">AE< sp ansty="le--0:#C792EA;--1:#8844">AEother<: sp ansty="le--0:#F78C6C;--1:#AA09">82<42sp ansty="le--0:#C792EA;--1:#8844">AAE< sp ansty="le--0:#C792EA;--1:#8844">AEseB0val1<1(sp ansty="le--0:#D7DBE0;--1:#403F">53newVal7<2:sp ansty="le--0:#C792EA;--1:#8844">AB0numb1<1)sp ansty="le--0:#C792EA;--1:#8844">AE< {d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72thA72_valAE <= sp ansty="le--0:#D6DEEB;--1:#403F">53newValAAE< sp ansty="le--0:#C792EA;--1:#8844">AE<},d ivclassNa="meec-li">A5<3;d ivclassNa="meco"><};d>
44AEc31111Exa3F<53 {divclass="Nameec-">de44A361B0v11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">dent< spans="tyle--0:#C792EA;--1:#88">44AEre36E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72_v33F<53 spans="tyle--0:#D6DEEB;--1:#40">3de44A361B0v1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53newV6361B0nu1<111) spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">dent< spans="tyle--0:#7FDBCA;--1:#09">6E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72_v34<4AE= spans="tyle--0:#D6DEEB;--1:#40">3F53 newVa3F<53 spans="tyle--0:#D6DEEB;--1:#40">3de61B0otherMe11<11() spans="tyle--0:#D6DEEB;--1:#40">3F5<3 { }divclass="Nameec-">3<{}><}di vdivclass="Nameexpressive-">44AEco61B0ob44AE< = {divclass="Nameec-">4444AE61B0v11<11() spans="tyle--0:#C792EA;--1:#88">4444AE< spans="tyle--0:#C792EA;--1:#88">44AEret6E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72_v4<4AE ;divclass="Nameec-">44444444AE61B0v1<111( spans="tyle--0:#D7DBE0;--1:#40">3F53newV64<4AE spans="tyle--0:#C5E478;--1:#3B">61B0nu1<111) spans="tyle--0:#C792EA;--1:#88">44dent< spans="tyle--0:#7FDBCA;--1:#09">6E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72_v44A3F53newV4<4AE ;divclass="Nameec-">44444444AEoth09<8242 spans="tyle--0:#C792EA;--1:#88">4<4AE ,divclass="Nameec-">4<4AE} spans="tyle--0:#D6DEEB;--1:#40">3<,}>

This rule is not configurable.

If you prefer a different organization style for class members, such as grouping by visibility or functionality, you might choose to disable this rule.