# 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 fix removes the explicit `= undefined` initializer from a `var` declaration inside a block, but `var` is function-scoped and hoisted. The original code re-initialized the function-scoped `a` to `undefined` when the block executed, overwriting the earlier assignment `a = 'assigned'`. After the fix, the declaration becomes `var a` with no initializer, which does not re-assign `a` at runtime, so the outer assignment persists and the program prints `assigned` instead of `undefined`. The documentation presents the rewrite as equivalent, but for function-scoped `var` the initializer has observable runtime effect, making the fix unsafe for this construct.
- Program: minimized from 15 to 8 lines

## Reproducer

```js
function commaTest() {
  a = 'assigned';
  if (true) {
    var a = undefined, c = 2; // Rule triggers again
  }
  console.log('After redeclaration:', a, typeof c);
}
commaTest();
```

## Commands

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

## Observed

```
stdout before:
After redeclaration: undefined number
stdout after:
After redeclaration: assigned number
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:26:16.933824825 -0400
+++ fixed.js	2026-10-22 13:26:19.126861152 -0400
@@ -1,7 +1,7 @@
 function commaTest() {
   a = 'assigned';
   if (true) {
-    var a = undefined, c = 2; // Rule triggers again
+    var a , c = 2; // Rule triggers again
   }
   console.log('After redeclaration:', a, typeof c);
 }
```

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

The original declaration `var a = undefined` initializes variable `a` to `undefined`, overriding its prior value `'assigned'` due to hoisting within the same scope. Removing `= undefined` leaves `a` uninitialized initially but still redeclared via `var`, so it retains the outer assignment’s value `'assigned'`. Thus `console.log` outputs different values for `a`. This change alters observable behavior, violating semantic preservation.

## Upstream search

Queries: "noUselessUndefinedInitialization fix", "complexity noUselessUndefinedInitialization variable declaration", "var initialization redundant undefined assignment", "block-scoped variable shadowing outer scope"

- duplicate: https://github.com/biomejs/biome/issues/11938
  same rule removing = undefined from a var redeclaration inside a block, which resets the outer variable
- related: https://github.com/biomejs/biome/issues/6003
  same rule but in Svelte files, not plain JS var redeclaration
- related: https://github.com/biomejs/biome/issues/6906
  same rule but about function return types, not var redeclaration
- related: https://github.com/biomejs/biome/pull/8776
  same rule fix for Svelte false positive, not var redeclaration
- related: https://github.com/biomejs/biome/issues/2533
  original implementation issue for the same rule, not this specific defect

<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>
