π Disallow recursive access to this within getters and setters.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
This rule prevents recursive access to this within getter and setter methods in objects and classes, avoiding infinite recursion and stack overflow errors.
// β
const foo = {
get bar() {
return this.bar;
}
};
// β
const foo = {
get bar() {
return this.baz;
}
};// β
class Foo {
get bar() {
return this.bar;
}
}
// β
class Foo {
get bar() {
return this.baz;
}
}// β
const foo = {
set bar(value) {
this.bar = value;
}
};
// β
const foo = {
set bar(value) {
this._bar = value;
}
};// β
class Foo {
set bar(value) {
this.bar = value;
}
}
// β
class Foo {
set bar(value) {
this._bar = value;
}
}