# biome complexity/noUselessUndefinedInitialization: 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/noUselessUndefinedInitialization (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The rule assumes the global `undefined` binding, but the program shadows `undefined` with a local variable holding 42. The fix removes the initializer, changing `x` from 42 to the real `undefined`, which is a silent wrong result in plausible code.
- Program: minimized from 6 to 5 lines

## Reproducer

```js
(function() {
  var undefined = 42;
  var x = undefined;
  console.log(x);
})();
```

## Commands

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

## Observed

```
stdout before:
42
stdout after:
undefined
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:26:23.815938839 -0400
+++ fixed.js	2026-10-22 13:26:25.862972760 -0400
@@ -1,5 +1,5 @@
 (function() {
   var undefined = 42;
-  var x = undefined;
+  var x ;
   console.log(x);
 })();
```

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

The original declaration `var undefined = 42` creates a local variable named `undefined`, shadowing the global property; thus `x` receives the value 42. After rewriting to `var x ;`, `x` is declared but never initialized, so it holds the initial value of uninitialized variables—`undefined`. Consequently `console.log(x)` outputs `undefined` instead of `42`, changing observable behavior.

## Upstream search

Queries: "noUselessUndefinedInitialization fix", "complexity noUselessUndefinedInitialization variable declaration", "Biome lint rule useless undefined initialization shadowing global", "fix removes redundant assignment to shadowed undefined variable"

- related: https://github.com/biomejs/biome/issues/11938
  same rule but different construct (loop reset vs shadowed global)
- related: https://github.com/biomejs/biome/issues/12040
  same rule but different construct (function default arg vs shadowed global)
- related: https://github.com/biomejs/biome/issues/11439
  same rule but different construct (callback overload vs shadowed global)
- related: https://github.com/biomejs/biome/issues/6003
  same rule but different construct (Svelte file vs shadowed global)
- related: https://github.com/biomejs/biome/issues/6906
  same rule but different construct (union return types vs shadowed global)
- related: https://github.com/biomejs/biome/pull/8776
  same rule but different construct (Svelte false positive vs shadowed global)
- related: https://github.com/biomejs/biome/issues/2533
  same rule but original implementation issue

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

- [github, open] 💅 `noUselessUndefinedInitialization` safe fix removes a `var` reset inside loops and redeclarations — https://github.com/biomejs/biome/issues/11938
- [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
- [tavily] 🐛 `--fix` flag ignores `--diagnostic-level` · Issue #7772 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7772
- [tavily] 💅 `noUselessUndefinedInitialization` false positive in svelte 4 file. · Issue #6003 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6003
- [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] 💅 `useSimplifiedLogicExpression` "safe" fix breaks code · Issue #11351 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11351
- [github, open] 💅 `lint/correctness/noUnusedImports` does not consider uses inside comments that precede non-declaration statements (start/end of file, etc.) — https://github.com/biomejs/biome/issues/8762
- [github, closed] 💅 useReactCompiler silently skips any file that contains an inline `export type` / `export interface` declaration — https://github.com/biomejs/biome/issues/12320
- [github, open] 💅 When using useNamingConvention, prefix and suffix functionality cannot be used in destructuring assignment renaming. — https://github.com/biomejs/biome/issues/8953
- [github, closed] 💅 lint/correctness/useExhaustiveDependencies does not consider global variables as necessary dependencies  — https://github.com/biomejs/biome/issues/8885
- [github, closed] 💅 False error (or at least a misleading one) - private class member never used — https://github.com/biomejs/biome/issues/6933
- [github, closed] 💅 `noInvalidUseBeforeDeclaration` false positive — https://github.com/biomejs/biome/issues/6719
- [tavily] fix(linter): noUselessUndefinedInitialization false positive in svelte 4. by codiini · Pull Request #8776 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/8776
- [tavily] 📝 Sorting tailwind class with a calc is broken · Issue #5496 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/5496
- [tavily] 💅 Biome not skipping excluded, generated, file in Monorepo configuration · Issue #7372 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7372
- [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] 📎 Implement `noUselessUndefinedInitialization` - `eslint/no-undef-init` · Issue #2533 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2533
- [tavily] 📝 Biome does not respect license headers when sorting imports · Issue #4210 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/4210
- [tavily] fix(lint): handle namespace declaration merging in noUnusedVariables by taberoajorge · Pull Request #9320 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/9320

</details>
