# consistent-this

Rule `eslint/consistent-this`. Enforce consistent naming when capturing the current execution context

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 1.4M weekly downloads of presets that enable it
- Trend: +9.0% last quarter
- Rank: #1564 by reach, #1479 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `consistent-this` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/consistent-this) |

## Code examples

### Incorrect: the rule reports this

```js
let that = 42;

let self = this;

that = 42;

self = this;
```

```js
let that;
function f() {
    that = this;
}
```

### Correct: the rule accepts this

```js
let that = this;

const self = 42;

let foo;

that = this;

foo.bar = this;
```

```js
let that;
that = this;
```

```js
let foo = 42, that;
that = this;
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "consistent-this": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [React Native](https://lintradar.dev/presets/react-native.md) | ESLint | `@react-native/eslint-config` | 79 | 1.2M | +5.8% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [eslint/no-invalid-this](https://lintradar.dev/rules/eslint/no-invalid-this.md): Disallow use of `this` in contexts where the value of `this` is `undefined`
- [eslint/max-depth](https://lintradar.dev/rules/eslint/max-depth.md): Enforce a maximum depth that blocks can be nested
- [eslint/max-lines](https://lintradar.dev/rules/eslint/max-lines.md): Enforce a maximum number of lines per file
- [eslint/sort-vars](https://lintradar.dev/rules/eslint/sort-vars.md): Require variables within the same declaration block to be sorted
- [eslint/no-inline-comments](https://lintradar.dev/rules/eslint/no-inline-comments.md): Disallow inline comments after code
- [eslint/max-params](https://lintradar.dev/rules/eslint/max-params.md): Enforce a maximum number of parameters in function definitions

---

Web page: https://lintradar.dev/rules/eslint/consistent-this. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
