# biome style/noNegationElse 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: 1; reduced to 1 of 1 hunk(s) in web/src/negate.js (delta debugging complete; the patch below was applied with git apply and reproduced the same difference)
- Sites reported by the rule in 1 changed file(s): 1 before, 0 after the fix
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The fix rewrites `if (!ok) return a; else return b;` to `if (ok) return b else return a`, which is invalid JavaScript syntax because an `else` clause cannot directly follow a single-statement `if` without braces. The original code parses and runs correctly, but the fixed code throws a SyntaxError at parse time, breaking the build.

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

```diff
--- a/web/src/negate.js
+++ b/web/src/negate.js
@@ -1,4 +1,3 @@
 export function pick(ok, a, b) {
-  if (!ok) return a
-  else return b
+  if (ok) return b else return a
 }
```

## Observed

```
stdout lines only before the fix:
  # Subtest: pick
  ok 3 - pick
  # pass 5
  # fail 0
stdout lines only after the fix:
  # file:///w/web/src/negate.js:N
  #   if (ok) return b else return a
  #                    ^^^^
  # SyntaxError: Unexpected token 'else'
  #     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/negate.test.js
  not ok 3 - /w/web/test/negate.test.js
    location: '/w/web/test/negate.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:

```
  ...
# file:///w/web/src/negate.js:2
#   if (ok) return b else return a
#                    ^^^^
# SyntaxError: Unexpected token 'else'
#     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/negate.test.js
not ok 3 - /w/web/test/negate.test.js
  ---
  duration_ms: 30.428574
  location: '/w/web/test/negate.test.js:1:1'
  failureType: 'testCodeFailure'
  exitCode: 1
  signal: ~
  error: 'test failed'
  code: 'ERR_TEST_FAILURE'
  ...
# Subtest: parseAll adds the converter's value
ok 4 - parseAll adds the converter's value
  ---
  duration_ms: 1.294294
  ...
# Subtest: util
ok 5 - util
  ---
  duration_ms: 1.280512
  ...
1..5
# tests 5
# suites 0
# pass 4
# fail 1
# cancelled 0
# skipped 0
# todo 0
# duration_ms 87.710965
```

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

The rewrite changes control flow syntax incorrectly: `if (ok) return b else return a` lacks braces around the then-branch, causing JavaScript to parse `return b else return a` as invalid syntax due to unexpected `else`, breaking execution entirely whereas the original used valid guarded returns with explicit else block structure preserving semantics when syntactically correct. This is not a semantic preservation but a syntactic error introduction.

## Upstream search

Queries: "noNegationElse fix", "style/noNegationElse conditional expression", "style/noNegationElse ternary operator rewrite", "style/noNegationElse if-else to ternary"

- related: https://github.com/biomejs/biome/issues/11351
- related: https://github.com/biomejs/biome/issues/11558
- related: https://github.com/biomejs/biome/issues/8347
- related: https://github.com/biomejs/biome/issues/9629
- related: https://github.com/biomejs/biome/issues/7518
- related: https://github.com/biomejs/biome/issues/691

## 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/noNegationElse --write 'web/src/negate.js'
```
