Skip to content

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.

class Example {
get name() {
return this.name;
}
set value(newValue: number) {
this.value = newValue;
}
}
const obj = {
get count() {
return this.count;
},
};

This rule is not configurable.

There’s no reason to disable this rule, as recursive accessor access always causes a runtime error.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.