npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sweepp

v2.0.1

Published

Zero-config fast CLI to sweep unused JS/TS imports & detect unused code (heuristic) with monorepo support.

Readme


Setup

The minimum supported version of Node.js is v18. Check your Node.js version with node --version.

  1. Install sweepp:
```sh
npm install -g sweepp
# or
npm install --save-dev sweepp
```

Install via Homebrew (macOS/Linux)

Install via Homebrew tap:

brew tap piyushdhoka/sweep
brew install sweepp

Upgrade:

brew update
brew upgrade sweepp
  1. (Optional) Configure path aliases or monorepo settings in your tsconfig.json/jsconfig.json for best results.

Upgrading

Check the installed version with:

sweepp --version

If it's not the latest version, run:

npm update -g sweepp

Usage

CLI mode

List unused imports and code:

sweepp list .

Clean unused imports:

sweepp clean

Detect unused code:

sweepp unuse

You can use options with list/clean/unuse:

sweepp list . --ext ts,tsx,js --ignore dist,build

Options

  • --ext <list>: Comma-separated file extensions (default: ts,tsx,js,jsx)
  • --ignore <list>: Comma-separated ignore patterns (default: node_modules)
  • --check-local: Check if local imports exist in project (supports path aliases)

Short commands

You can use these aliases:

  • swp
  • list
  • clean
  • unuse
  • version

Example Output

Unused Imports Report

File           Count  Unused Imports
─────────────────────────────────────────────
src\math.ts    3      useState, useEffect, readFileSync
src\App.tsx    2      Component, useRef
─────────────────────────────────────────────
Summary: 2 file(s) with 5 unused import(s)

How it works

sweepp analyzes your codebase using Babel AST parsing to find unused imports and code. It supports monorepos and path aliases, and ignores system folders and .d.ts files for accurate results.

Troubleshooting

No unused imports or code detected

  • Make sure you have supported file types in your project
  • Check your ignore patterns
  • Ensure your codebase is staged and accessible

Output includes system folders

  • Use the --ignore option to add more folders if needed

Performance issues

  • sweepp is optimized for speed, but very large codebases may take longer
  • Use the --ext option to limit file types

Maintainers

Contributing

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

  • Zero config: run instantly
  • List unused import specifiers (TS/JS/JSX/TSX)
  • Safe clean mode removes them
  • Detect unused code (functions, classes, variables, types, interfaces) with preview
  • Fast AST parsing (Babel; SWC planned)
  • Keeps side-effect imports (import 'polyfill';)
  • Path alias support (@/components, src/...)
  • Optionally check if local imports exist in project
  • Monorepo support (pnpm workspaces, npm/yarn workspaces, Turborepo)
  • Ignores system folders and .d.ts files

Install

npm

npm install -g sweepp
# or
npm install --save-dev sweepp

Homebrew (macOS/Linux)

brew tap piyushdhoka/sweep
brew install sweepp

Usage

Short commands

sweepp
swp
list
clean
unuse
version

You can use options with list/clean/unuse:

sweepp list . --ext ts,tsx,js --ignore dist,build
swp list . --ext ts,tsx,js --ignore dist,build

Options

  • --ext <list>: Comma-separated file extensions (default: ts,tsx,js,jsx)
  • --ignore <list>: Comma-separated ignore patterns (default: node_modules)
  • --check-local: Check if local imports exist in project (supports path aliases from tsconfig.json/jsconfig.json)

Example Output

Unused Imports Report

File           Count  Unused Imports
─────────────────────────────────────────────
src\math.ts    3      useState, useEffect, readFileSync
src\App.tsx    2      Component, useRef
─────────────────────────────────────────────
Summary: 2 file(s) with 5 unused import(s)

Path Alias & Monorepo Support

sweepp auto-detects path aliases from tsconfig.json/jsconfig.json and monorepo setups (pnpm, npm/yarn workspaces, Turborepo).

Exit Codes

  • 0: success
  • 1: error

Programmatic Use

import { analyzeAndClean } from 'sweepp/dist/analyzer';
const result = await analyzeAndClean('src/file.ts', true);
console.log(result.removed);
- Dynamic usage may evade detection
- Side-effect imports are preserved
- Heuristic unused code detection: Next.js pages/app route exports treated as used
- `.d.ts` files are ignored

✔ src/utils/math.ts removed: unusedAdd, unusedSub
✔ src/components/App.tsx removed: UnusedComponent

Clean Summary
Files changed: 2
Total specifiers removed: 3

Path Alias Support

sweepp automatically reads tsconfig.json or jsconfig.json to resolve path aliases when using --check-local:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"],
      "@components/*": ["src/components/*"]
    }
  }
}

## Monorepo Support

**Supported monorepo types:**
- **Turborepo** - Detected via `turbo.json` (uses underlying workspace config)

**Example pnpm-workspace.yaml:**
packages:
  - 'packages/*'
  - 'apps/*'

Example package.json workspaces:

{
  "workspaces": [
    "packages/*",
    "apps/*"
  ]
}

When sweepp runs in a monorepo, it will:

  • Automatically detect all workspace packages
  • Resolve workspace imports like @myorg/utils to actual file paths
  • Support workspace:* protocol in dependencies
  • Show monorepo info in output (e.g., "Detected pnpm monorepo with 5 package(s)")

Example output:

Detected pnpm monorepo with 3 package(s)

Unused Imports Report
...

Exit Codes

  • 0 – success
  • 1 – unexpected internal error

Programmatic Use

import { analyzeAndClean } from 'sweepp/dist/analyzer';
// Dry-run (true) lists removals without writing.
const result = await analyzeAndClean('src/file.ts', true);
console.log(result.removed);

Notes & Limitations

  • Dynamic access patterns may evade detection
  • Type-only imports counted if referenced
  • Side-effect imports preserved
  • Heuristic unused code detection: Next.js pages/ & app/ route exports treated as used; namespace imports mark all exports used
  • Re-export chains & default export usage not fully analyzed yet; review before manual removal
  • Babel parser first; SWC migration planned

Roadmap

  • SWC for performance
  • Improve unused code graph (default exports, re-exports, dynamic usage)
  • Config file support
  • VS Code extension
  • Git diff only mode
  • Parallel processing
  • Cache / incremental mode

License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details