no-this-alias
JavaScript / TypeScriptstyleno fixdefault: offjs/typescript-eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”Reports const self = this, let self = this and self = this: a variable that holds this. Destructuring this (const { x } = this) is not reported.
Why it matters
Section titled “Why it matters”The alias is a leftover of code that needed this inside a function that has its own this. An arrow function takes the this of the surrounding code without it, and the alias lets a reader take self for something other than this.
To fix, use an arrow function, or bind.
Example
Section titled “Example”...function local(require: (id: string) => void) { require("d"); }const self = this, { x } = this;y = this;...function f(): void;...Configuration
Section titled “Configuration”js: lint: rules: no-this-alias: warn # off (default), warn, errorEnabled by the presets: js/typescript-eslint-recommended, js/biome-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-this-alias in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| typescript-eslint | no-this-alias |
partial | the options (allowDestructuring, allowedNames) keep their defaults |