# no-this-alias

Disallow aliasing the receiver into a binding

Binding `this` introduces a second name for the current receiver even though lexical lambdas retain that receiver directly.
Instead, you SHOULD use `this` directly or replace a receiver-capturing function with a lexical lambda.

- Category: style
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
class Service {
    run(): void {
        const self = this;
        self.flush();
    }

    flush(): void {}
}
```

## Accepted

```ds title="main.ds"
class Service {
    run(): void {
        this.flush();
    }

    flush(): void {}
}
```

## Prior art

- [typescript-eslint · no-this-alias](https://typescript-eslint.io/rules/no-this-alias)

[language/linter/src/rules/style/no_this_alias.rs:6](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/no_this_alias.rs#L6)
