Skip to content

feat(ci): knip#3078

Draft
gabrielmfern wants to merge 4 commits intocanaryfrom
claude/setup-knip-MoKHK
Draft

feat(ci): knip#3078
gabrielmfern wants to merge 4 commits intocanaryfrom
claude/setup-knip-MoKHK

Conversation

@gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Mar 18, 2026

Description

This PR adds knip to the repository for detecting and managing unused files, dependencies, and exports across the monorepo.

Changes

  • Added knip.json configuration file with:
    • Workspace-specific entry points for the monorepo structure
    • Ignore patterns for generated code, templates, and test utilities
    • Settings to ignore interface and type exports in files
    • Dependency ignore list for internal packages
    • Exclusion of duplicate detection
  • Added knip script to package.json for easy CLI access
  • Added knip (v5.75.2) as a dev dependency

Configuration Highlights

The knip configuration is tailored for this monorepo with:

  • Entry points defined for root scripts, demo emails, benchmarks, and playground
  • Ignored paths for examples, public assets, templates, and test utilities
  • Internal packages (@react-email/preview-server, react-email) marked as ignored dependencies to avoid false positives

Test Plan

N/A - Configuration addition. Run pnpm knip to verify the setup works correctly.

https://claude.ai/code/session_01GfiVQQmYrTHoxDzPc4whk7


Summary by cubic

Adds knip to detect unused files, exports, and dependencies across the monorepo, wires it into CI, and cleans up issues it flagged (dead files, unused deps, and stray exports).

  • New Features

    • Replace internal ignores with workspace entries for templates/tests/e2e/dynamic assets; keep ignore only for examples/** and apps/web/public/**.
    • Ignore type/interface exports; disable duplicate checks; ignore deps @react-email/preview-server and react-email.
    • Add CI job in the lint workflow to run pnpm knip.
    • Add knip script and dev dependency knip@5.75.2.
  • Refactors

    • Removed 12 dead files (unused WebGL material, preview-server icons/toolbar, benchmark utils, Tailwind compat util).
    • Pruned unused deps across packages; added missing jsdom to apps/web; simplified playground deps.
    • Internalized unused exports (e.g., getImportedComponent, TooltipRoot, PreviewContext, MeshImageMaterial, helper functions); dropped an unused default export in a test fixture.
    • Added @lintignore JSDoc to select public API exports in packages/tailwind.
    • Cleaned up unused catalog entries in pnpm-workspace.yaml.

Written for commit f20eae2. Summary will update on new commits.

Adds knip configuration modeled after resend/resend's setup:
- Workspace-aware entry points for apps/demo emails, benchmarks, playground
- Ignores dynamically loaded files (web components, illustrations, templates, test fixtures)
- Ignores examples/ (not part of the pnpm workspace)
- ignoreDependencies for CLI-only packages (@react-email/preview-server, react-email)
- Excludes duplicates check

https://claude.ai/code/session_01GfiVQQmYrTHoxDzPc4whk7
@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

⚠️ No Changeset found

Latest commit: f20eae2

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

@vercel
Copy link
Contributor

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Mar 18, 2026 2:52pm
react-email-demo Error Error Mar 18, 2026 2:52pm

Request Review

@gabrielmfern gabrielmfern changed the title chore(root): Add knip for unused code detection feat(ci): knip Mar 18, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Confidence score: 4/5

  • This PR looks safe to merge overall, with a limited risk profile because the noted issue is in tooling configuration rather than runtime behavior.
  • In knip.json, using ignore can mask findings in those paths while still keeping them in Knip’s graph, which may let dead code slip past detection when only examples/tests reference it.
  • The impact is mainly code-health and maintenance visibility (moderate severity), not an immediate functional regression for users.
  • Pay close attention to knip.json - adjust ignore behavior so unused-code reporting isn’t unintentionally suppressed.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="knip.json">

<violation number="1" location="knip.json:8">
P2: Using `ignore` here will hide findings in those paths without removing them from Knip's graph, so example/test-only usages can keep dead code from being reported.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Using `ignore` removes files from knip's graph entirely, which can mask
dead code — if a test fixture or template is the only consumer of an
export, that export stays alive and won't be reported as unused.

Replace ignore entries for workspace-internal files (test fixtures,
templates, seed data, e2e apps, dynamically-loaded components) with
workspace-specific entry patterns, reserving `ignore` only for truly
out-of-scope paths (examples/ and static public assets).

As a side-effect, @vitejs/plugin-react is no longer reported as an
unused devDependency because the e2e/vite workspace entry now resolves
its usage in vite.config.ts.

https://claude.ai/code/session_01GfiVQQmYrTHoxDzPc4whk7
**Deleted dead files (12):**
- apps/web/src/webgl/materials/MeshBannerMaterial.ts
- benchmarks/preview-server/src/utils/{run-server-and-fetch-preview-page,sleep}.ts
- packages/preview-server/src/components/icons/{icon-bug,icon-email,icon-image,icon-link,icon-phone,icon-stamp}.tsx
- packages/preview-server/src/components/toolbar/{checking-results,results-table}.tsx
- packages/tailwind/src/utils/compatibility/unescape-class.ts

**Removed unused dependencies across packages:**
- Root: @actions/http-client, @octokit/core, nypm, rollup, vite
- apps/demo: react-dom, next (devDep)
- apps/docs: zod
- apps/web: @babel/preset-typescript, @types/babel__core, webpack
- benchmarks/preview-server: tsconfig
- packages/code-block, code-inline: @react-email/render (devDep)
- packages/create-email: react (devDep)
- packages/preview-server: @babel/core, @radix-ui/colors,
  @radix-ui/react-dropdown-menu, @types/babel__core, @types/fs-extra,
  @types/mime-types, @types/normalize-path, @types/webpack, sharp
- packages/react-email: @types/babel__core, tsx
- packages/render: @edge-runtime/vm

**Added missing dependency:**
- apps/web: jsdom (required by vitest environment config)

**Fixed playground dependencies:**
- Replace unused @react-email/render + react-dom with @react-email/components

**Removed unused exports:**
- Made internal: getImportedComponent, TooltipRoot, PreviewContext,
  writtenMemberExpressionTo, mapResult, isEmailTemplate,
  ResendStatus, TooltipProps, MeshImageMaterial, GooglePlayPolicyUpdate*
- Removed unused default export from stripe-welcome-email test fixture

**Added @lintignore to public API exports:**
- packages/tailwind: inlineStyles, pixelBasedPreset, TailwindSetup

**Updated knip.json:**
- Add workspace ignoreDependencies for e2e/template unlisted deps
- Add packages/tsconfig workspace to ignore next peer dep
- Suppress optionalPeerDependencies section (tailwind's optional peers
  are intentionally referenced in e2e tests)

**Removed unused catalog entries from pnpm-workspace.yaml:**
- @react-email/components, @scaleway/sdk, @types/babel__core

https://claude.ai/code/session_01GfiVQQmYrTHoxDzPc4whk7
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

Open in StackBlitz

@react-email/code-block

npm i https://pkg.pr.new/resend/react-email/@react-email/code-block@3078

@react-email/code-inline

npm i https://pkg.pr.new/resend/react-email/@react-email/code-inline@3078

create-email

npm i https://pkg.pr.new/resend/react-email/create-email@3078

@react-email/preview-server

npm i https://pkg.pr.new/resend/react-email/@react-email/preview-server@3078

react-email

npm i https://pkg.pr.new/resend/react-email@3078

@react-email/render

npm i https://pkg.pr.new/resend/react-email/@react-email/render@3078

@react-email/tailwind

npm i https://pkg.pr.new/resend/react-email/@react-email/tailwind@3078

commit: a0e14c4

@gabrielmfern gabrielmfern marked this pull request as draft March 18, 2026 15:30
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