ActionsWorkflows
Unused Dependencies Cleanup (depcheck)
Detects and removes unused dependencies in each workspace and opens an automated PR.
This workflow scans each workspace for unused dependencies using depcheck and opens a PR to remove them.
Why
- Keep package.json lean and secure.
- Reduce install times and noise from automated upgrades.
- Surface potential misconfigurations (e.g., missing or indirectly used deps).
How it works
- Detect all workspaces with a
package.jsoninapps/*andpackages/*. - Run
depcheck --jsonper workspace, respecting optional ignore files. - Generate a Markdown report and upload it as an artifact.
- If unused deps are found, rewrite the affected
package.jsonfiles, update the lockfile, and create a PR. - Create/update a tracking issue with the summary.
Configure ignores (border cases)
- Global defaults are embedded in the workflow to ignore common toolchain-only packages.
- For workspace-specific exceptions, create a
.depcheckrc.workspacefile in that workspace:
{
"ignores": ["your-dependency-name", "another-dep"]
}You can also include skipMissing and ignorePatterns if needed.
Workflow location
- File:
.github/workflows/unused-deps.yml - Triggers:
- Manual dispatch
- Pushes to main/master that change
package.jsonorpnpm-lock.yaml
Notes
- depcheck flags may include false positives for dynamically loaded or config-only packages; review the PR carefully.
- The PR is created with
peter-evans/create-pull-requestso repository actions must allow PR creation. - In monorepos, running per workspace avoids cross-package interference.