Skip to content

ci: add knip for unused dependencies detection#1095

Merged
fi3ework merged 8 commits intomainfrom
ci/add-knip-unused-deps-detection
Mar 25, 2026
Merged

ci: add knip for unused dependencies detection#1095
fi3ework merged 8 commits intomainfrom
ci/add-knip-unused-deps-detection

Conversation

@fi3ework
Copy link
Copy Markdown
Member

Summary

Background

The monorepo had no tooling to detect unused or misplaced dependencies, allowing dead packages to accumulate silently across workspaces.

Implementation

  • Add knip with workspace-aware configuration (knip.json) covering all packages/* and the root workspace
  • Add check-unused-deps script (knip --dependencies) and a CI step in the lint workflow
  • Remove 5 genuinely unused devDependencies identified by knip: @rstest/coverage-istanbul (root, vscode), @rstest/tsconfig (browser-ui), picocolors (browser), @rstest/browser-ui (core)
  • Move fs-extra and @types/fs-extra from root to e2e/package.json where they are actually imported
  • Add cross-env to e2e/devDependencies (used in e2e scripts but was only hoisted from root)
  • Explicitly declare prettier-plugin-packagejson in .prettierrc so knip can trace it, and reformat package.json files accordingly

User Impact

None — internal tooling and dependency hygiene improvement.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

Rsdoctor Bundle Diff Analysis

Found 12 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 2.1 KB 0
adapter-rslib 23.1 KB 0
adapter-rspack 5.9 KB 0
browser 2.0 MB 0
browser-react 3.7 KB 0
browser-ui 804.3 KB 0
coverage-istanbul 9.1 KB 0
core/rsdoctor-browser 971.5 KB 0
core/rsdoctor-loaders 869.0 B 0
core/rsdoctor-main 1.5 MB 0
vscode/rsdoctor-extension 60.2 MB 0
vscode/rsdoctor-worker 14.4 KB 0

Generated by Rsdoctor GitHub Action

fi3ework and others added 8 commits March 25, 2026 13:30
- Add knip with workspace-aware configuration for the monorepo
- Add check-unused-deps script and CI step in lint workflow
- Explicitly declare prettier-plugin-packagejson in .prettierrc
- Reformat package.json files per prettier-plugin-packagejson ordering
- Move fs-extra and @types/fs-extra from root to e2e where actually used
- Add cross-env to e2e devDependencies (used in e2e scripts)
- Remove genuinely unused devDependencies:
  - root: @rstest/coverage-istanbul
  - browser-ui: @rstest/tsconfig
  - browser: picocolors
  - core: @rstest/browser-ui
  - vscode: @rstest/coverage-istanbul

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…nt CI

The lint CI runs pnpm install --ignore-scripts (no build), so @rstest/core/dist
does not exist. Knip fails when it tries to load rstest.config.mts which imports
from @rstest/core. Ignoring the config file lets knip run without needing built
packages.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
The browser-coverage e2e fixture relies on @rstest/coverage-istanbul being
hoisted from root. Added ignoreDependencies in knip config to suppress
the false positive.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Move the dependency from root devDeps into the fixture that actually uses
it, instead of relying on hoisting.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
The e2e/reporter/fixtures-merge fixture uses the istanbul coverage
provider but was relying on the dependency being hoisted from root.
Now that we've removed it from root, we need to declare it explicitly
in e2e/reporter.

Amp-Thread-ID: https://ampcode.com/threads/T-019d22fb-58e7-72a8-9344-a5556e76ecc4
Co-authored-by: Amp <amp@ampcode.com>
- Move @types/is-url from e2e dependencies to devDependencies
- Add detailed comments for all ignoreDependencies in knip.json explaining:
  - @typescript/native-preview: used by rslib for fast DTS generation
  - @rstest/browser-manifest: virtual module resolved at build time
  - @tailwindcss/postcss: used in postcss.config.cjs
  - @rstest/browser: path-mapped imports via tsconfig
  - ovsx: CLI tool for publishing
  - @rsbuild/plugin-react: used in sample config for testing

Amp-Thread-ID: https://ampcode.com/threads/T-019d22fb-58e7-72a8-9344-a5556e76ecc4
Co-authored-by: Amp <amp@ampcode.com>
@fi3ework fi3ework force-pushed the ci/add-knip-unused-deps-detection branch from d140d3d to 3b0ed5f Compare March 25, 2026 05:32
@fi3ework fi3ework requested a review from 9aoy March 25, 2026 06:08
@fi3ework fi3ework merged commit 1a63c1e into main Mar 25, 2026
17 checks passed
@fi3ework fi3ework deleted the ci/add-knip-unused-deps-detection branch March 25, 2026 06:44
@9aoy 9aoy mentioned this pull request Mar 26, 2026
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