Disallow assigning this to variables.
This rule applies only to .js and .ts files.
const time = 1000;
export class CC {
public doWork(): void {
console.info('work');
}
public init(): void {
setTimeout(function () {
this.doWork();
});
}
} // this cannot be assigned to a variable.
const self = this;
setTimeout(function () {
self.doWork();
}); plugin:@typescript-eslint/recommended plugin:@typescript-eslint/all
For details about how to configure Code Linter check rules, see Code Linter.