feat(core): govern lowercase units in architecture/reserved-directory-names - #409
Conversation
…-names isUnitDir's letter test recognises only capitalised (.svelte-entry) units, so a .ts- or .svelte.ts-entry unit's children were never governed by any unitScopes declaration — measured at 129 of 299 units (43%) on a real tree (issue #386). Add anyCaseUnitScopes, a string-map counterpart to unitScopes gated on isAnyCaseUnitDir (isUnitDir without the letter test) instead of isUnitDir, following the naming rationale architecture/reserved-name-placement records for its own capitalisedUnitPlacements/anyCaseUnitPlacements split: the bare word "unit" is ambiguous once both predicates exist. An identical glob declared in both unit maps partitions rather than collides: unitScopes's gate is a strict subset of anyCaseUnitScopes's, so unitScopes governs at capitalised units and anyCaseUnitScopes governs alone at the lowercase ones unitScopes never reaches — letting one glob express a capitalised-superset / lowercase-subset convention. scopes still beats both unit maps on a tie, unchanged. The tri-state unused-key diagnostics, examined counts (this rule records none, matching unitScopes), and the tie-break are covered by 14 new tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The reserved-directory-names bullet still said "off until one of the two is set" and omitted anyCaseUnitScopes, added by the prior commit on this branch. Reworded to name the new map and avoid hardcoding a map count that rots on the next one (AGENTS.md's anti-hardcoding principle). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 7 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe ChangesReserved directory names
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Configuration
participant reserved_directory_names
participant UnitDirectories
participant Diagnostics
Configuration->>reserved_directory_names: Provide scopes, unitScopes, and anyCaseUnitScopes
reserved_directory_names->>UnitDirectories: Classify directories and match scope declarations
UnitDirectories-->>reserved_directory_names: Return eligible units and selected declarations
reserved_directory_names->>Diagnostics: Report reserved-name violations and unused declarations
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/src/content/docs/rules/architecture/reserved-directory-names.md`:
- Line 55: Replace the numeric heading in
docs/src/content/docs/rules/architecture/reserved-directory-names.md:55 with a
nonnumeric scope-map heading describing what its keys name. Apply the equivalent
synchronized Japanese heading in
docs/src/content/docs/ja/rules/architecture/reserved-directory-names.md:56,
removing “3 つのオプション” while preserving the heading’s meaning.
In `@packages/core/src/rules/architecture/reserved-directory-names.ts`:
- Around line 99-102: Correct the unit-scope predicate description across all
affected sites: in
packages/core/src/rules/architecture/reserved-directory-names.ts lines 99-102,
remove the .svelte restriction and describe the gap as missing generic any-case
unit-map declarations; in packages/core/test/reserved-directory-names.test.ts
lines 488-490, replace “any declaration” with unitScopes or unit-map
declarations; in the English documentation lines 66-70 and Japanese
documentation lines 67-71, state that anyCaseUnitScopes matches capitalized and
lowercase units, including .ts and .svelte.ts entries; and in
.changeset/reserved-directory-names-any-case-units.md lines 5-13, describe
anyCaseUnitScopes as capitalization-agnostic rather than lowercase-only.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2761ca01-6791-4192-a158-5ef44c881596
📒 Files selected for processing (9)
.changeset/reserved-directory-names-any-case-units.mddocs/src/content/docs/guides/(setup)/configuration.mdxdocs/src/content/docs/ja/guides/(setup)/configuration.mdxdocs/src/content/docs/ja/rules/architecture/reserved-directory-names.mddocs/src/content/docs/rules/architecture/reserved-directory-names.mddocs/superpowers/specs/2026-07-29-reserved-directory-names-design.mddocs/superpowers/specs/2026-08-06-reserved-name-placement-design.mdpackages/core/src/rules/architecture/reserved-directory-names.tspackages/core/test/reserved-directory-names.test.ts
De-numerize the rule doc's "The three options" heading (en/ja) — it rots the next time a scope map is added, same reasoning as the configuration.mdx fix earlier on this branch. Correct the rule's own JSDoc: isUnitDir's letter test doesn't require a .svelte entry specifically (the .svelte/.ts split is the measured tree's correlation, not the predicate), and a lowercase unit wasn't strictly never checked by any declaration — a scopes key naming the parent directly could still reach one. Narrowed to "no generic unit-map declaration governed it". Comments and headings only, no behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…le prose De-numerize the JSDoc's "Three option maps" opener too, matching the doc heading fixed earlier on this branch — same anti-count-rot reasoning. The rule doc prose (en/ja) repeated the same two JSDoc inaccuracies fixed previously: unitScopes's letter test doesn't require a .svelte entry specifically (extension-agnostic predicate), and a lowercase unit's children weren't strictly "never checked by any declaration" — a scopes key naming the parent directly could still reach one. Narrowed to "no generic unit-map declaration governed it" in both languages. Comments and prose only, no behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fixes #386.
Summary
unitScopesidentifies units withisUnitDir, which requires the directory name to begin A–Z — so the children of lowercase units (.ts/.svelte.tsentries, 129 of 299 units = 43% on the measured tree) were never checked by any declaration, silently.architecture/reserved-name-placementalready closed this for itself withisAnyCaseUnitDir; both design docs record "the same split would close it here" without tracking it.Changes
anyCaseUnitScopes(same value grammar asunitScopes, matched via the already-exportedisAnyCaseUnitDir). The name follows the reserved-name-placement design's recorded rationale — the bare word "unit" must not name either map — applying itsanyCasevocabulary tounitScopes' existing name.moreSpecificGlob; on a byte-identical glob,scopes>unitScopes>anyCaseUnitScopes. The unit-map ordering is forced by the design's own worked convention:isUnitDir⊂isAnyCaseUnitDir, so the capitalised map is the narrower claim — the reverse order would make the design's partition pattern (one glob, capitalised superset + any-case subset) inexpressible and produce false positives. Pinned by three dedicated tests.scopes× either unit map on one glob = full collision (as before);unitScopes×anyCaseUnitScopeson one glob = a legitimate partition, not a collision (the any-case entry keeps uncontested work at lowercase units). Tri-state unused-key diagnostics extended ("never a unit" vs "never a unit of either case").unitScopesitself records none — the examined-counts design scopes the three sibling directory rules out. That gap is exactly issue Examined counts for the three glob-configured sibling directory rules #387, handled next (stacked on this branch)..ts/.svelte.tsrepro, unitScopes-alone silence pinned, capitalised unaffected, non-unit exclusion, partition tie-breaks, diagnostics); rule docs en/ja; configuration guide's map list updated with count-free wording ("Off until a scope map is set"); dated addenda on both design docs; changeset@svelte-vitals/coreminor (default behavior unchanged — new findings only for users who declare the new map).Known accepted edge
Dead-declaration bookkeeping is keyed by bare glob string: under the partition config on a tree with zero capitalised units, the fully-dead
unitScopescopy draws no "never a unit" note (the shared string is marked used by the any-case copy). Under-reports only — consistent with the rule family's recorded direction.Verification
pnpm -r typecheck/pnpm test(core 1317, cli 846, vite 209) /pnpm lint/pnpm -r buildall green; no drift-test regen needed (new option, not a new rule).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
anyCaseUnitScopesconfiguration for applying reserved-directory-name checks to units regardless of capitalization.Documentation