feat(recipes): unimported-exports (research note § 1.2)#66
Conversation
Third recipe from research note § 1 capability inventory. Surfaces exports with no detectable import — useful starting candidate list for "what's unused?" but explicitly NOT a "safe to delete" list. V1 limitations documented in the recipe .md: 1. Re-export chains NOT followed — false positives if A re-exports bar from B and consumers import bar from A. Future recipe with recursive CTE walking re_export_source closes the gap (research note § 1.2 caveat). 2. Unresolved imports ignored — imports.resolved_path IS NULL (tsconfig path aliases the resolver couldn't resolve; external packages) — those rows don't count toward "used" matching. 3. Default exports skipped — common framework entry points (Next.js page.tsx, Storybook stories, vite.config.ts). Override in project- local recipe to include them. SQL approach: - direct_uses CTE: imports.resolved_path matches export's file AND specifiers JSON contains the export's name (or "*" namespace) - Filter: not in direct_uses, is_default = 0, kind != 're-export' Action template: review-for-deletion (auto_fixable: false). Agents must verify before deletion. Verification: - Recipe loads cleanly via --recipes-json - bun run check passes (format, typecheck, all 23 golden queries) Rule 10 lockstep: both templates/agents/ AND .agents/ codemap rule + skill gain trigger row + quick-reference row + recipe-id list entry. Patch changeset: pre-v1; additive bundled recipe; no schema bump.
🦋 Changeset detectedLatest commit: 38cee5d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe PR introduces a new ChangesUnimported Exports Recipe
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Summary
Ships
unimported-exportsrecipe from research note § 1.2 — third bundled recipe from the capability inventory. XS effort, ships against existing substrate (exports,imports,imports.resolved_path,imports.specifiersJSON).What it does
Surfaces exports that have no detectable import. Useful as a starting candidate list for "what's unused?" — explicitly NOT a "safe to delete" list.
Action template:
review-for-deletion(auto_fixable: false).V1 limitations (documented in recipe
.md)Three known false-positive classes spelled out so agents don't blindly trust the output:
src/index.tsre-exportsbarfromsrc/bar.tsand consumersimport { bar } from '~/'(hitting the barrel), the recipe falsely flagsbarinsrc/bar.ts. Tracked under research note § 1.2 caveat — future recipe with recursive CTE walkingre_export_sourcecloses the gap.imports.resolved_path IS NULL(tsconfig path aliases the resolver couldn't resolve, or external packages) — those rows don't count toward "used" matching. Codemap's resolver covers most TS/JS shapes; corner case for unusual config.page.tsx, Storybook stories,vite.config.ts) skipped to reduce noise. Drop theAND e.is_default = 0clause in a project-local override to include them.Doc-governance compliance
templates/agents/AND.agents/codemap rule + skill gain a trigger-pattern row, quick-reference row, and recipe-id list update.<id>.{sql,md}file pair;.mdcarries action template via YAML frontmatter + caveats / tuning axes in the body.Test plan
bun run checkpasses — format, lint, typecheck, all 23 golden queries--recipes-jsonOut of scope
re_export_source) — separate future PR; v1 caveat documented.Summary by CodeRabbit
New Features
unimported-exportsrecipe to identify exports with no detectable direct imports, serving as an initial candidate list for investigating potentially unused exports.Documentation