Repository navigation
fix(core): CORRECT001 stop flagging itemless {#each} and fix backwards rationale - #137
Conversation
…s rationale
The official {#each} docs document the itemless form ({#each { length: 8 }, i})
as a first-class "render N times" pattern (the chess-board example). CORRECT001
flagged it as unkeyed, but there is no item identity to key on there — the only
possible key is the index itself, which is a no-op. Skip each blocks with no
item context.
Also corrected the rule's rationale, which claimed unkeyed each "destroys and
recreates DOM nodes" on reorder; the docs describe the opposite mechanism —
nodes are reused and their data rewritten in place, which is exactly why
element state/focus sticks to positions instead of items.
Fixes #135
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughCORRECT001's each-block collection now skips itemless ChangesCORRECT001 itemless each fix
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes #135 — two problems in CORRECT001 (keyed each), found while auditing existing rules against the official Svelte docs.
{#each ...}docs document the itemless form ({#each { length: 8 }, i}) as a first-class "render N times" pattern (the chess-board example). CORRECT001 flagged it as unkeyed, but there is no item identity to key on — the only possible key is the index itself, which is a no-op.collectEachBlocksnow skips each blocks with no item context (node.context == null), verified against the real parser.Test plan
component-parse.test.ts: itemless each is ignored, and stays ignored even if given a (meaningless) index key.pnpm build && pnpm typecheck && pnpm test && pnpm lint: all pass (core 349, cli 345, vite 84, mcp 13).pnpm --filter docs check: 0 errors.@svelte-vitals/core+svelte-vitals(behavioral change to a shipped rule).🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
{#each}blocks so they are no longer treated as keyed items in error checks.Documentation
{#each}patterns are ignored and why keys matter for DOM updates and state retention.Tests
{#each}cases to confirm they are ignored correctly.