accessorPairGroups
Reports getter and setter accessors for the same property that are not adjacent.
✅ This rule is included in the ts stylistic 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.
Examples
Section titled “Examples”class Example { get value() { return this._value; } otherMethod() {} set value(newValue: number) { this._value = newValue; }}const object = { get value() { return this._value; }, other: 42, set value(newValue: number) { this._value = newValue; },};class Example { get value() { return this._value; } set value(newValue: number) { this._value = newValue; } otherMethod() {}}const object = { get value() { return this._value; }, set value(newValue: number) { this._value = newValue; }, other: 42,};Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you prefer a different organization style for class members, such as grouping by visibility or functionality, you might choose to disable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useaccessorPairGroups - ESLint:
grouped-accessor-pairs - Oxlint:
eslint/grouped-accessor-pairs
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.