> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-this-alias

[Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14)
## Configuration

| Preset                              | Configured Value |
| ----------------------------------- | ---------------- |
| ✅ ts.configs.recommended            | `"error"`        |
| ✅ ts.configs.recommendedTypeChecked | `"error"`        |
| ✅ ts.configs.strict                 | `"error"`        |
| ✅ ts.configs.strictTypeChecked      | `"error"`        |


```ts title=rslint.config.ts
import { defineConfig, ts } from '@rslint/core';

export default defineConfig([
  ts.configs.recommended,
  {
    rules: {
      '@typescript-eslint/no-this-alias': 'error',
    },
  },
]);
```

## Rule Details

Disallow aliasing `this`.

Assigning `this` to a variable (commonly named `self` or `that`) is a legacy pattern that predates arrow functions. Arrow functions automatically capture the surrounding `this`, making `this` aliasing unnecessary.

Examples of **incorrect** code for this rule:

```typescript
const self = this;
let that = this;
const foo = this;
```

Examples of **correct** code for this rule:

```typescript
const { foo } = this; // destructuring is allowed by default
setTimeout(() => {
  this.doSomething(); // use arrow function instead of aliasing
});
```

## Original Documentation

- [typescript-eslint: no-this-alias](https://typescript-eslint.io/rules/no-this-alias)
- [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-this-alias.ts)
