# biome style/noUselessElse on repo: fix breaks the build

Evidence sheet generated by fixhunt from a repository scan. 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 (fix labelled safe)
- Project: /home/sun/dev/diaghunt/demo/repo
- Command: `cd web && node --test` (exit 0 before, 1 after)
- Files changed by the fix: 3; reduced to 1 of 3 hunk(s) in web/src/branch.js (delta debugging complete; the patch below was applied with git apply and reproduced the same difference)
- Sites reported by the rule in 3 changed file(s): 3 before, 0 after the fix
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The fix hoists the `let text` declaration from the `else` block into the outer scope where `let text = "none"` already exists, creating a duplicate declaration that makes the file fail to parse. The documentation presents the rewrite as equivalent but does not account for variable shadowing across the removed block boundary.

## Change (reduced; applies to the project with `git apply -p1`)

```diff
--- a/web/src/branch.js
+++ b/web/src/branch.js
@@ -2,8 +2,7 @@
   let text = "none";
   if (n > 0) {
     return "positive";
-  } else {
+  }
     let text = "non-positive";
     return text;
-  }
 }
```

## Observed

```
stdout lines only before the fix:
  # Subtest: label
  ok 2 - label
  # pass 5
  # fail 0
stdout lines only after the fix:
  # file:///w/web/src/branch.js:N
  #     let text = "non-positive";
  #         ^
  # SyntaxError: Identifier 'text' has already been declared
  #     at compileSourceTextModule (node:internal/modules/esm/utils:346:16)
  #     at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:146:18)
  #     at \#translate (node:internal/modules/esm/loader:497:12)
  #     at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:544:27)
  # Node.js v20.20.0
  # Subtest: /w/web/test/branch.test.js
  not ok 2 - /w/web/test/branch.test.js
    location: '/w/web/test/branch.test.js:N'
    failureType: 'testCodeFailure'
    exitCode: 1
    signal: ~
    error: 'test failed'
    code: 'ERR_TEST_FAILURE'
  # pass 4
  # fail 1
exit 0 → 1
```

## Output of the command (last 40 lines)

Before:

```
TAP version 13
# Subtest: run logs both items
ok 1 - run logs both items
  ---
  duration_ms: 1.249256
  ...
# Subtest: label
ok 2 - label
  ---
  duration_ms: 0.928985
  ...
# Subtest: pick
ok 3 - pick
  ---
  duration_ms: 0.924077
  ...
# Subtest: parseAll adds the converter's value
ok 4 - parseAll adds the converter's value
  ---
  duration_ms: 1.250568
  ...
# Subtest: util
ok 5 - util
  ---
  duration_ms: 1.304258
  ...
1..5
# tests 5
# suites 0
# pass 5
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 84.622619
```

After:

```
#     at compileSourceTextModule (node:internal/modules/esm/utils:346:16)
#     at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:146:18)
#     at \#translate (node:internal/modules/esm/loader:497:12)
#     at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:544:27)
# Node.js v20.20.0
# Subtest: /w/web/test/branch.test.js
not ok 2 - /w/web/test/branch.test.js
  ---
  duration_ms: 41.675099
  location: '/w/web/test/branch.test.js:1:1'
  failureType: 'testCodeFailure'
  exitCode: 1
  signal: ~
  error: 'test failed'
  code: 'ERR_TEST_FAILURE'
  ...
# Subtest: pick
ok 3 - pick
  ---
  duration_ms: 0.935766
  ...
# Subtest: parseAll adds the converter's value
ok 4 - parseAll adds the converter's value
  ---
  duration_ms: 1.267664
  ...
# Subtest: util
ok 5 - util
  ---
  duration_ms: 1.244429
  ...
1..5
# tests 5
# suites 0
# pass 4
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 87.322452
```

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

The rewrite moves `let text = \"non-positive\";` outside the `else` block, causing it to execute unconditionally when `n <= 0`. Since `let text = \"none\"` was already declared in the same scope, this creates a duplicate declaration of `text`, which is invalid in JavaScript and results in a syntax error during module parsing—changing behavior from successful execution to immediate failure.

## Upstream search

Queries: "noUselessElse fix", "style noUselessElse variable declaration shadow", "style noUselessElse block scope identifier conflict", "style noUselessElse redundant else branch removal"

- duplicate: https://github.com/biomejs/biome/issues/11937
- related: https://github.com/biomejs/biome/issues/12529
- related: https://github.com/biomejs/biome/issues/11351
- related: https://github.com/biomejs/biome/issues/11558
- related: https://github.com/biomejs/biome/issues/11092
- related: https://github.com/biomejs/biome/issues/3770
- related: https://github.com/biomejs/biome/issues/1191
- related: https://github.com/biomejs/biome/issues/4354
- related: https://github.com/biomejs/biome/issues/8347
- a snippet says fixed in 2.5.14: https://github.com/biomejs/biome/issues/11937 (advisory)

## Reproduce

```sh
# /home/sun/dev/diaghunt/demo/repo: apply the change above (minimal.patch), then run the command
git apply -p1 minimal.patch
cd web && node --test
# or run the fixer itself on the changed files
bunx @biomejs/biome lint --only=style/noUselessElse --write 'web/src/branch.js'
bunx @biomejs/biome lint --only=style/noUselessElse --write 'web/src/negate.js'
bunx @biomejs/biome lint --only=style/noUselessElse --write 'web/src/util.js'
```
