Skip to content

feat(config): add knip for unused deps and exports detection#3

Merged
rkovalov merged 7 commits into
mainfrom
feat/check-deps
Mar 1, 2026
Merged

feat(config): add knip for unused deps and exports detection#3
rkovalov merged 7 commits into
mainfrom
feat/check-deps

Conversation

@rkovalov

@rkovalov rkovalov commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Chores

    • CI and publish workflows now detect changed files and run lint/format for those changes, and include a new dependency-check step.
    • Added a dev script and configuration for an unused-dependency/export detection tool; linting commands updated to reduce false errors and adjust pre-commit formatting.
  • Refactor

    • Converted a previously exported module constant to an internal constant (no behavioral change).

@coderabbitai

coderabbitai Bot commented Mar 1, 2026

Copy link
Copy Markdown

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds 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 knip.json and check:deps script; removes the export from STORE_KEYS in src/mock/mock.ts.

Changes

Cohort / File(s) Summary
CI Workflow Updates
.github/workflows/ci.yml, .github/workflows/publish.yml
Checkout now uses fetch-depth: 0; new "Resolve changed files" step computes CHANGED via git diff and exports to GITHUB_ENV; added "Check deps" step running pnpm check:deps; lint/format updated to run pnpm format:lint $CHANGED. Test step left unchanged.
Dependency Checking Config
knip.json
New Knip config file with schema, entry: src/**/index.ts, project: src/**/*.ts, ignoreBinaries, ignoreDependencies, and ignoreExportsUsedInFile: true.
Package Configuration
package.json
Added check:deps script and knip devDependency; updated format:lint to include --no-errors-on-unmatched; adjusted lint-staged invocation to use pnpm format:lint --write.
Source Change
src/mock/mock.ts
Removed export from STORE_KEYS, making it an internal constant instead of an exported symbol.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Knip tool configuration for detecting unused dependencies and exports, which is reflected across multiple files (knip.json, package.json scripts, and CI workflows).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/check-deps

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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".

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3a1a21 and 87a49e3.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Comment thread .github/workflows/ci.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/workflows/ci.yml (1)

33-39: ⚠️ Potential issue | 🟠 Major

Harden 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."
+          fi
Does `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.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 87a49e3 and b2134a2.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

@rkovalov rkovalov merged commit 160db82 into main Mar 1, 2026
2 checks passed
@rkovalov rkovalov deleted the feat/check-deps branch March 1, 2026 03:47
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.

1 participant