feat(config): add knip for unused deps and exports detection#3
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds Knip dependency checks and change-aware CI steps: checkout with full history, compute/export CHANGED via git diff, run pnpm check:deps, and pass CHANGED into lint/format. Adds Changes
Sequence Diagram(s)sequenceDiagram
autonumber
rect rgba(173,216,230,0.5)
participant GH as "GitHub Actions"
participant Git as "Git (checkout/diff)"
participant Runner as "Runner / Shell"
participant Knip as "Knip (pnpm check:deps)"
participant Lint as "Linter/Formatter"
end
GH->>Git: checkout code (fetch-depth: 0)
GH->>Runner: run "Resolve changed files" (git diff) -> compute CHANGED
Runner-->>GH: export CHANGED to GITHUB_ENV
GH->>Knip: run pnpm check:deps
Knip-->>GH: dependency report
GH->>Lint: run pnpm format:lint $CHANGED
Lint-->>GH: lint/format results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 33-42: Replace the brittle space-delimited CHANGED export with a
NUL-delimited git diff that excludes deletions (use --diff-filter=ACMR) and
ensure downstream commands consume the NUL-separated list (e.g., via xargs -0 or
by writing a safe shell array) so the "Resolve changed files" step reliably
handles filenames with spaces and omits deleted files referenced by "pnpm
format:lint $CHANGED" and "pnpm test:related $CHANGED".
There was a problem hiding this comment.
♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)
33-39:⚠️ Potential issue | 🟠 MajorHarden changed-file propagation to avoid flaky path handling.
Line 36 builds a space-delimited list and Line 39 expands it unquoted; filenames with spaces will split, and deleted files can leak into downstream commands.
Suggested robust patch
- name: Resolve changed files run: | - set -eo pipefail # fail fast: exit on error (-e) and propagate pipe failures (-o pipefail) - echo "CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | tr '\n' ' ')" >> $GITHUB_ENV + set -euo pipefail + git diff --name-only --diff-filter=ACMR -z origin/${{ github.base_ref }}...HEAD > .changed-files - name: Lint and Format - run: pnpm format:lint $CHANGED + run: | + if [ -s .changed-files ]; then + xargs -0 pnpm format:lint < .changed-files + else + echo "No changed files for lint/format." + fiDoes `git diff --name-only` include deleted files by default, and is `-z` + `xargs -0` the recommended safe pattern for filenames with spaces in shell/GitHub Actions?🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 33 - 39, The current flow writes a space-delimited CHANGED and expands it unquoted which breaks on filenames with spaces and can leak deleted paths; change the "Resolve changed files" step to use git diff --name-only -z (null-delimited) and restrict to non-deleted files (e.g., --diff-filter=ACM) when building the list, persist the null-delimited output safely, and update the "Lint and Format" step to invoke pnpm format:lint via a null-safe invocation (use xargs -0 or read the NUL-separated list into an array) instead of expanding $CHANGED unquoted so filenames with spaces or deleted entries are handled robustly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In @.github/workflows/ci.yml:
- Around line 33-39: The current flow writes a space-delimited CHANGED and
expands it unquoted which breaks on filenames with spaces and can leak deleted
paths; change the "Resolve changed files" step to use git diff --name-only -z
(null-delimited) and restrict to non-deleted files (e.g., --diff-filter=ACM)
when building the list, persist the null-delimited output safely, and update the
"Lint and Format" step to invoke pnpm format:lint via a null-safe invocation
(use xargs -0 or read the NUL-separated list into an array) instead of expanding
$CHANGED unquoted so filenames with spaces or deleted entries are handled
robustly.
Summary by CodeRabbit
Chores
Refactor