Skip to content

Disable unicorn/no-break-in-nested-loop (#279)#298

Merged
twschiller merged 1 commit into
mainfrom
disable-unicorn-no-break-in-nested-loop
Jun 22, 2026
Merged

Disable unicorn/no-break-in-nested-loop (#279)#298
twschiller merged 1 commit into
mainfrom
disable-unicorn-no-break-in-nested-loop

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Final ratchet candidate from #279.

Decision: turn off, not ratchet

unicorn/no-break-in-nested-loop flags any break/continue in a loop nested within another loop, wanting the inner block extracted into a function. It's not a clean ratchet:

  • The rule counts a switch inside a loop as a "nested loop", so ~9 of the 27 sites are idiomatic switch-case breaks — required syntax, not loop control (load-default-overrides.ts, css-hide-stylesheet.property.test.ts). Enabling would force pointless switch-into-function extractions.
  • The rule has no option to exclude switch or narrow scope, and the remaining sites are test/mock code where extraction is awkward.

Leaving it on would be all churn for no further upside, so it's set to off (consistent with the other borderline rules in #279) with a comment explaining why.

Production sites cleaned up directly

The genuinely improvable production sites were refactored rather than left behind:

File Change
subtree-watcher.ts extract dispatchAddedNode() (3 guard continues → early returns)
rule-count.ts extract traceUnionMatches() helper (2 nested continues)
schema-trust-sanitize.ts extract nearestItemscope() ancestor-walk helper
encoded-payload-redact.ts break-on-first-decode loop → .some()
disguised-ad-flag.ts break-on-first-match loop → .some()
build.ts extract findEnvValueInContent() for the dotenv line parser
selector-token-index.ts guard continue → optional chaining ?.
countdown-timer-redact.ts guard continue → inverted condition

This was the last open candidate in #279.

Checks

  • bun run check (biome + eslint + stylelint) ✅
  • npm run typecheck (both tsconfigs) ✅
  • Jest for all refactored files: 262 passed ✅

🤖 Generated with Claude Code

Final ratchet candidate from #279. Not a clean ratchet: the rule treats a
`switch` inside a loop as a "nested loop", so ~9 of the 27 sites are
idiomatic switch-case `break`s (required syntax, not loop control) it would
force into pointless function extractions, plus a batch of test/mock sites.
The rule can't be narrowed to exclude `switch` or those sites, so it's turned
off rather than left as a noisy warning.

The genuinely improvable production sites were cleaned up directly:

- subtree-watcher.ts: extract dispatchAddedNode() (guard continues -> returns)
- rule-count.ts: extract traceUnionMatches() helper
- schema-trust-sanitize.ts: extract nearestItemscope() ancestor walk
- encoded-payload-redact.ts: break-on-first-decode loop -> .some()
- disguised-ad-flag.ts: break-on-first-match loop -> .some()
- build.ts: extract findEnvValueInContent() for the dotenv line parser
- selector-token-index.ts: guard continue -> optional chaining
- countdown-timer-redact.ts: guard continue -> inverted condition

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 3:14pm

Request Review

@twschiller twschiller merged commit 99c1b3b into main Jun 22, 2026
7 checks passed
@twschiller twschiller deleted the disable-unicorn-no-break-in-nested-loop branch June 22, 2026 15:16
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