accessorThisRecursion
Reports recursive access to this within getters and setters.
✅ This rule is included in the ts logical presets.
Accessing this.propertyName inside a getter or setter for propertyName triggers that same accessor again, causing infinite recursion and a stack overflow error at runtime.
Examples
Section titled “Examples”class Example { get name() { return this.name; }
set value(newValue: number) { this.value = newValue; }}
const obj = { get count() { return this.count; },};class Example { private _name: string = ""; private _value: number = 0;
get name() { return this._name; }
set value(newValue: number) { this._value = newValue; }}
const obj = { _count: 0, get count() { return this._count; },};Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”There’s no reason to disable this rule, as recursive accessor access always causes a runtime error.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
unicorn/no-accessor-recursion - Oxlint:
unicorn/no-accessor-recursion
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.