@studnicky/lexical-this-only
Disallows capturing this into a local variable (const self = this) or via assignment expression. Use arrow functions to preserve lexical this instead.
Fixable: No · Options: No · Suggested severity: error
✗ Incorrect
ts
const self = this;
setTimeout(function() { self.run(); }, 100);ts
const that = this;
doAsync(() => { that.complete(); });✓ Correct
ts
// Arrow function preserves lexical this
setTimeout(() => { this.run(); }, 100);ts
// Arrow callback — no alias needed
doAsync(() => { this.complete(); });