Skip to content

Ratchet unicorn/prefer-minimal-ternary to error#290

Merged
twschiller merged 1 commit into
mainfrom
ratchet-unicorn-minimal-ternary
Jun 22, 2026
Merged

Ratchet unicorn/prefer-minimal-ternary to error#290
twschiller merged 1 commit into
mainfrom
ratchet-unicorn-minimal-ternary

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

From #279. Two of the three sites factor the common part out of the ternary; the third keeps it with a scoped disable.

Changes

  • log.tscond ? console.warn : cond2 ? console.error : console.logconsole[cond ? "warn" : cond2 ? "error" : "log"] (the varying part is the method name).
  • page-world-hook.tsawait (target ? register() : unregister())await (target ? register : unregister)() (factor out the call).
  • confirmshame-sanitize.tsscoped disable. Factoring (element instanceof HTMLInputElement ? rewriteInput : rewriteButtonLike)(element) widens the argument back to Element and loses the narrowing rewriteInput requires (typecheck error), while an if/else would trip unicorn/prefer-ternary. The ternary stays, with a rationale comment + inline disable.
  • eslint.config.js — removed from the warn list → reverts to unicorn/recommended default (error).

Verification

  • bun run check exit 0 (rule errors; 0 violations; no-unused-disable clean)
  • bun run typecheck clean
  • bun run test — 2059/2059 pass

Refs #279

From #279. Two of three sites factor the common part out of the ternary;
the third can't and carries a scoped disable:

- log.ts: `cond ? console.warn : cond2 ? console.error : console.log` →
  `console[cond ? "warn" : cond2 ? "error" : "log"]`.
- page-world-hook.ts: `target ? register() : unregister()` →
  `(target ? register : unregister)()`.
- confirmshame-sanitize.ts: keeps the ternary with a scoped disable —
  factoring `(cond ? f : g)(element)` widens the arg past the `instanceof`
  narrowing `rewriteInput` needs, and an `if`/`else` would trip
  `prefer-ternary`.

Rule reverts to its unicorn/recommended default (error).

Refs #279

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 22, 2026 12:53pm

Request Review

@twschiller twschiller merged commit 291326e into main Jun 22, 2026
7 checks passed
@twschiller twschiller deleted the ratchet-unicorn-minimal-ternary branch June 22, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant