# biome style/noNegationElse: fixed output does not parse

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: style/noNegationElse (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-breaks-syntax
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The fix incorrectly rewrites an if-else statement without braces by negating the condition and swapping branches, but produces invalid syntax 'if (foo) result += 'B' else result += 'A'' which is a syntax error. The rule documentation presents this rewrite as safe and equivalent, but the transformation fails to account for the required braces when an else clause exists, causing the fixed file to no longer parse.
- Program: minimized from 11 to 7 lines

## Reproducer

```js
let result = ''
(() => {
  if (!foo)
    result += 'A'
  else
    result += 'B'
})()
```

## Commands

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

## Observed

```
/home/sun/dev/diaghunt/runs/2026-10-17T20-56-43-558Z-ibkb-biome-style_noNegationElse/r2-p001/min/r2-p001-reuse/fixed.js:4
    result += 'B' else 
                  ^^^^

SyntaxError: Unexpected token 'else'
    at checkSyntax (node:internal/main/check_syntax:84:5)

Node.js v26.8.1
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:34:35.857173301 -0400
+++ fixed.js	2026-10-22 13:34:38.034209998 -0400
@@ -1,7 +1,6 @@
 let result = ''
 (() => {
-  if (!foo)
+  if (foo)
+    result += 'B' else 
     result += 'A'
-  else
-    result += 'B'
 })()
```

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

The rewrite inverts the condition but incorrectly swaps branches without preserving logical equivalence; it also introduces invalid syntax due to missing braces around the else clause, causing a parse error before execution can occur, so behavior differs both syntactically and semantically from the original.

## Upstream search

Queries: "noNegationElse fix", "style noNegationElse if negation", "biome style/noNegationElse conditional expression", "rule style/noNegationElse else clause syntax"

- related: https://github.com/biomejs/biome/issues/9629
  same rule noNegationElse but different construct ternary with comments
- related: https://github.com/biomejs/biome/issues/7518
  same rule noNegationElse but generic fix-breaks-syntax without construct details
- related: https://github.com/biomejs/biome/issues/691
  same rule noNegationElse mentioned in config but no defect details

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

- [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] Extension chokes on large files — https://github.com/biomejs/biome/issues/3860
- [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] 💅 `useSimplifiedLogicExpression` "safe" fix breaks code — https://github.com/biomejs/biome/issues/11351
- [github, closed] 💅 `useExplicitLengthCheck` false positive and broken fix — https://github.com/biomejs/biome/issues/11558
- [github, closed] 💅 Corrupted CLI safe fix for `useConsistentArrowReturn` — https://github.com/biomejs/biome/issues/8347
- [github, closed] 💅 `useExplicitLengthCheck` false positive — https://github.com/biomejs/biome/issues/11352
- [github, closed] 💅 lint/nursery/noUselessUndefined fix is unsafe for functions with union return types — https://github.com/biomejs/biome/issues/6906
- [github, closed] 💅 `correctness/noUnusedVariables` shows class as unused, when `namespace` with the same name is present — https://github.com/biomejs/biome/issues/4928
- [github, closed] 💅 useImportExtensions doesn't respect tsconfig paths from referenced project configs — https://github.com/biomejs/biome/issues/7644
- [tavily] 🐛 `noNegationElse` improperly handles comments in ternaries · Issue #9629 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9629
- [tavily] 📝 biome format --fix breaks the file · Issue #7518 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7518
- [tavily] 💅 Incorrectly suggest to discard redundant terms (useSimplifiedLogicExpression) · Issue #8577 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8577
- [tavily] 💅 `useNamingConvention`: selectors `classProperty` and `classMember` don't apply to parameter properties · Issue #6695 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6695
- [tavily] 💅 `lint/style/useReadonlyClassProperties` doesn't recognize `obj.prop = this.x++;` · Issue #7310 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7310
- [tavily] 🐛 Unexpected override behavior · Issue #691 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/691

</details>
