# biome complexity/noUselessThisAlias: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: biome 2.5.15
- Rule: complexity/noUselessThisAlias (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The rule removed the variable declaration `var _this = this` and replaced the read of `_this` with `this`, but the read occurs before the declaration in the original code. In the original, `typeof _this` evaluates to 'undefined' due to hoisting; after the fix, `typeof this` evaluates to the bound `this` value ('object'), changing the program's output. The documentation only mentions arrow functions, yet the fix was applied to a regular function where `this` is not lexically inherited, making the rewrite unsound for this construct.
- Program: minimized from 10 to 8 lines

## Reproducer

```js
function test() {
  console.log(typeof _this);
  var _this = this;
}
try {
  console.log(test.call({value: 'ok'}));
} catch (e) {
}
```

## Commands

```sh
node prog.js
bunx @biomejs/biome lint --only=complexity/noUselessThisAlias --write prog.js
node prog.js
```

## Observed

```
stdout before:
undefined
undefined
stdout after:
object
undefined
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:25:51.361401561 -0400
+++ fixed.js	2026-10-22 13:25:53.421435635 -0400
@@ -1,6 +1,5 @@
 function test() {
-  console.log(typeof _this);
-  var _this = this;
+  console.log(typeof this);
 }
 try {
   console.log(test.call({value: 'ok'}));
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original code logs typeof _this before declaring var _this; due to hoisting, _this exists but is uninitialized (undefined), so typeof yields "undefined". After fixing, typeof this refers to the function’s this value directly. When called via .call({value:'ok'}), this becomes the passed object, so typeof returns "object". The second log remains undefined because test returns nothing. Thus the change alters behavior by moving the reference before the declaration, changing what _this denotes.

## Upstream search

Queries: "noUselessThisAlias fix", "complexity noUselessThisAlias alias usage", "typeof undefined variable reference", "test call context binding"

- related: https://github.com/biomejs/biome/issues/1633
  same rule (noUselessThisAlias) but different defect (extra semicolon vs behavior change from hoisting)

<details><summary>All hits</summary>

- [github, open] 💅 noDuplicateTestHooks: false positive on a local function named `before` called twice in a test — https://github.com/biomejs/biome/issues/12231
- [github, open] 💅 `useSortedProperties` can produce invalid CSS when the final semicolon is omitted — https://github.com/biomejs/biome/issues/12417
- [github, open] 💅 `useSortedProperties` moves Sass variable declarations below their uses — https://github.com/biomejs/biome/issues/12414
- [github, open] 💅 `useSortedProperties` can change behavior when reordering nested CSS rules — https://github.com/biomejs/biome/issues/12413
- [github, open] 💅 `noUnnecessaryConditions`: false positive on an overloaded call with `undefined` as the default argument (Vue `inject`) — https://github.com/biomejs/biome/issues/12040
- [github, open] 💅 `noSkippedTests` conditionally skip fix suggestion — https://github.com/biomejs/biome/issues/9295
- [github, open] 💅 Actually used private method considered unused — https://github.com/biomejs/biome/issues/8185
- [github, open] 💅 cannot detect that the StrictMode component of React is being exported. — https://github.com/biomejs/biome/issues/10609
- [github, open] 💅 noUnnecessaryConditions callback overload false positive — https://github.com/biomejs/biome/issues/11439
- [github, open] 💅 lint/a11y/useAnchorContent: the PascalCase component allowance is applied only to self-closing elements — https://github.com/biomejs/biome/issues/11872
- [tavily] 💅 The fix of noUselessThisAlias adds an extra semicolon when removing the alias definition · Issue #1633 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1633
- [tavily] 💅 `useSimplifiedLogicExpression` "safe" fix breaks code · Issue #11351 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11351
- [tavily] 💅 noUselessTernary double space in quick fix · Issue #11092 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11092
- [tavily] 💅 lint/nursery/noUselessUndefined fix is unsafe for functions with union return types · Issue #6906 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6906
- [tavily] 💅 `noThisInStatic` safe fix is still not safe in more complex scenarios · Issue #10278 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10278
- [tavily] 💅 noUselessEscapeInString escapes wrongly by default as safe fix in css · Issue #8274 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8274
- [tavily] 💅 `noThisInStatic` safe fix is not safe · Issue #10011 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10011
- [tavily] 💅 noUnusedImports - fix breaks code · Issue #3383 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3383
- [github, closed] 💅 noDuplicateTestHooks should consider `context` blocks (Cypress and Mocha code) as well as `describe` — https://github.com/biomejs/biome/issues/3602
- [github, closed] incorrect detection of unused imports — https://github.com/biomejs/biome/issues/4449
- [tavily] 💅 False positive `lint/nursery/noUnknownPseudoElement` with `::view-transition-new(<pt-name-selector>)` · Issue #5998 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5998
- [tavily] 💅 Biome not skipping excluded, generated, file in Monorepo configuration · Issue #7372 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7372
- [tavily] One does not simply enable just one lint rule · Issue #1768 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1768
- [tavily] 💅 `lint/complexity/noForEach` should not throw on `Effect.forEach` (or be configurable) · Issue #3351 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3351
- [github, closed] 💅 useOptionalChain causes crashes when applied to global variables — https://github.com/biomejs/biome/issues/7517
- [github, closed] noImportCycles doesn't ignore types — https://github.com/biomejs/biome/issues/6799
- [tavily] 💅noDelete suggest assigning undefined instead of delete for process.env vars · Issue #4093 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4093
- [github, closed] 📎 Embedded language formatting — https://github.com/biomejs/biome/issues/3334
- [github, closed] ☂️ Prettier code challenge hub — https://github.com/biomejs/biome/issues/720

</details>
