Skip to content

Ratchet unicorn/no-declarations-before-early-exit to error#284

Merged
twschiller merged 1 commit into
mainfrom
ratchet-unicorn-no-decls-before-exit
Jun 22, 2026
Merged

Ratchet unicorn/no-declarations-before-early-exit to error#284
twschiller merged 1 commit into
mainfrom
ratchet-unicorn-no-decls-before-exit

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Fifth ratchet from #279.

Seven sites, handled three ways:

Declaration moved past the guard (also skips the work on the bail path):

  • hidden-text-strip.tsconst height now computed only after the width check passes
  • scripts/load-default-overrides.tsprefixedIssue built only on the non-union path (the union branch continues)
  • hidden-fee-annotate.property.test.tsconst text moved below the phrase-collision guard

Dead-code removal (cleaner than a disable):

  • yielding-text-walk.ts (×2) — the flagged const is a synchronous collectTextNodes* call (: Text[]) sitting between two identical if (signal?.aborted) return checks. Nothing awaits between them, so the second check could never observe a different value — removed it. Aborts during the later async chunked processing are still caught in runFinalize.

Move past a guard:

  • checkout-checkbox-defense-source.ts — the CLEARED_ATTR marker (plus its comment + no-restricted-syntax disable) moved below the descriptor opt-out guard; it's first used after it.

Unavoidable disable (1):

  • Popup.tsx — the declaration is a React hook (useTabDebugTrace), which must run unconditionally before any early return. Moving it would violate react-hooks/rules-of-hooks. Inline-disabled with a rationale.

eslint.config.js: removed from the warn list → reverts to unicorn/recommended default (error).

Verification

  • bun run typecheck clean
  • bun run check exit 0 (rule now errors; 0 violations)
  • bun run test — 2059/2059 pass (covers the yielding-text-walk abort paths)

Refs #279

Fifth ratchet from #279. Most sites move a declaration below the guard
that doesn't use it; two are dead-code removals and one needs a disable:

- hidden-text-strip.ts, load-default-overrides.ts,
  hidden-fee-annotate.property.test.ts: move the declaration past the
  early-exit (also avoids computing it on the bail path).
- yielding-text-walk.ts (×2): the flagged declaration is a synchronous
  `collectTextNodes*` call sitting between two identical `signal?.aborted`
  checks. Since nothing awaits between them, the second check was dead —
  removed it (per-chunk aborts are still caught in runFinalize).
- checkout-checkbox-defense-source.ts: move the CLEARED_ATTR marker (and
  its comment/disable) below the descriptor opt-out guard.
- Popup.tsx: the declaration is a React hook that must run before any
  early return; inline-disabled with a rules-of-hooks rationale.

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 11:46am

Request Review

@twschiller twschiller merged commit 69123e0 into main Jun 22, 2026
7 checks passed
@twschiller twschiller deleted the ratchet-unicorn-no-decls-before-exit branch June 22, 2026 11:48
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