Ratchet unicorn/no-declarations-before-early-exit to error#284
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.ts—const heightnow computed only after the width check passesscripts/load-default-overrides.ts—prefixedIssuebuilt only on the non-union path (the union branchcontinues)hidden-fee-annotate.property.test.ts—const textmoved below the phrase-collision guardDead-code removal (cleaner than a disable):
yielding-text-walk.ts(×2) — the flaggedconstis a synchronouscollectTextNodes*call (: Text[]) sitting between two identicalif (signal?.aborted) returnchecks. 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 inrunFinalize.Move past a guard:
checkout-checkbox-defense-source.ts— theCLEARED_ATTRmarker (plus its comment +no-restricted-syntaxdisable) 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 violatereact-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 typecheckcleanbun run checkexit 0 (rule now errors; 0 violations)bun run test— 2059/2059 pass (covers the yielding-text-walk abort paths)Refs #279