Skip to content

refactor: effect/imperative-loops out of tests and examples (2 of 2) - #613

Merged
thomasfosterau merged 3 commits into
trunkfrom
lint-imperative-loops-tests
Nov 12, 2026
Merged

thomasfosterau merged 3 commits into
trunkfrom
lint-imperative-loops-tests

Conversation

@thomasfosterau

Copy link
Copy Markdown
Owner

Summary

Part of #533. Second half of the effect/imperative-loops work; the first half, the non-test src/ files, landed as #611. This PR converts the remaining 98 sites in src/*.test.ts (73), examples/ (22) and test/entry-points.test.ts (3), touching only those files, and deletes the rule's warn line in vite.config.ts, so the rule now runs at the preset's error.

Site count (vp lint, whole repo): effect/imperative-loops 98 -> 0, and 0 lint errors. No other rule gained a site in the touched files.

Conversions:

  • Most side-effecting loops became Arr.forEach, with continue turned into return.
  • Early exits became Arr.findFirst / Arr.some / Arr.takeWhile: the example handlers' duplicate-title and duplicate-name checks, the conformance fixtures' reject-on-first-bad-key walks and sort comparator, and mediaTypeParameters.
  • The example handlers' multi-pass sort is an Arr.reduce in the blog example and an Arr.forEach over the same array in the github and northwind examples, as before.
  • Index loops became Arr.forEach over the segments or instants.
  • One async test loop became Promise.all(... .map(async ...)).
  • vite.config.ts had no count comments citing this rule.

Verification

Run on the branch rebased onto origin/trunk (which includes #611), with GOMAXPROCS=2 GOMEMLIMIT=3GiB and --concurrency-limit 1.

  • pnpm install --frozen-lockfile: pass
  • vp run build: pass
  • vp check: pass
  • vp run check: pass
  • vp run -r test:unit: pass (4006 passed in the root suite; examples 73, 50 and 56 passed)
  • vp run docgen: pass
  • vp run test:coverage (4006 passed), then vp exec fallow audit --base origin/trunk: verdict warn, not fail. It reports one introduced complexity finding (a CRAP score of 56.3 on the conformance test fixture whose loops became findFirst closures) and two duplication groups among the example handlers' sort helpers. These are test and example code only, and the sort loops were already cloned between examples before this change.

Changeset

None. This is an internal refactor of tests and examples with no change to published behaviour.

  • A changeset under .changeset/ for every change to published behaviour (n/a)

Notes


Generated by Claude Code

…rative-loops, 2 of 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
Delete the warn line: the rule has no sites left in the repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
…ammar fixture

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
@thomasfosterau
thomasfosterau merged commit 4a3bce1 into trunk Nov 12, 2026
@thomasfosterau
thomasfosterau force-pushed the lint-imperative-loops-tests branch from b914052 to c38c968 Compare November 12, 2026 06:15
@thomasfosterau
thomasfosterau deleted the lint-imperative-loops-tests branch November 12, 2026 06:15
@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c38c968

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

2 participants