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

@fe-fast/code-sweeper

v1.0.1

Published

A lightweight JavaScript/TypeScript code cleaning tool

Readme

🧹 Code Sweeper

Lightweight JavaScript/TypeScript code cleanup tool

npm version License: MIT TypeScript

Code Sweeper is a tool focused on automatically cleaning redundant code in projects, filling the code cleanup gaps that ESLint and Prettier cannot cover.

✨ Features

  • 🔍 Smart Analysis: AST-based static analysis for precise identification of unused code
  • 🧹 One-click Cleanup: Remove unused imports, variables, and functions
  • 🐛 Debug Cleanup: Automatically remove console.log and debugger statements
  • ⚙️ Flexible Configuration: Support custom cleanup rules and file filtering
  • 🚀 Multi-framework Support: Compatible with Vue, React, and TypeScript projects
  • 📊 Detailed Reports: Provide before-and-after cleanup analysis
  • 🔌 Build Tool Integration: Support for Webpack, Vite, and Rollup plugins

🚀 Quick Start

Installation

# Global installation
npm install -g code-sweeper

# Or install in project
npm install --save-dev code-sweeper

Basic Usage (CLI)

# Analyze code issues
code-sweeper analyze

# Clean code (preview mode)
code-sweeper clean --dry-run

# Execute cleanup
code-sweeper clean

# Initialize configuration file
code-sweeper config --init

🔌 Build Tool Integration

For seamless integration into your build process, Code Sweeper provides official plugins for major build tools.

Installation

npm install @fe-fast/code-sweeper --save-dev
# or
pnpm add -D @fe-fast/code-sweeper
# or
yarn add -D @fe-fast/code-sweeper

Webpack

// webpack.config.js
const { CodeSweeperWebpackPlugin } = require('@fe-fast/code-sweeper/webpack');

module.exports = {
  // ... other configs
  plugins: [
    new CodeSweeperWebpackPlugin({
      // options
      rules: {
        removeConsoleLog: process.env.NODE_ENV === 'production',
      },
    }),
  ],
};

Vite

// vite.config.ts
import { defineConfig } from 'vite';
import codeSweeperPlugin from '@fe-fast/code-sweeper/vite';

export default defineConfig({
  plugins: [
    codeSweeperPlugin({
      rules: {
        removeConsoleLog: process.env.NODE_ENV === 'production',
      },
    }),
  ],
});

Rollup

// rollup.config.js
import codeSweeperPlugin from '@fe-fast/code-sweeper/rollup';

export default {
  // ... other configs
  plugins: [
    codeSweeperPlugin({
      rules: {
        removeConsoleLog: process.env.NODE_ENV === 'production',
      },
    }),
  ],
};

Plugin Options

All plugins support the following options:

interface PluginOptions {
  include?: string[];
  exclude?: string[];
  dryRun?: boolean;
  skipConfirmation?: boolean;
  rules?: {
    removeUnusedImports?: boolean;
    removeUnusedVariables?: boolean;
    removeConsoleLog?: boolean;
    removeDebugger?: boolean;
    formatCode?: boolean;
    renameToCamelCase?: boolean;
  };
}

For more examples, check out the examples directory.

📋 Command Reference

analyze - Code Analysis

Analyze code issues in the project without making any modifications.

code-sweeper analyze [options]

Options:
  -p, --path <path>     Target directory path (default: current directory)
  -c, --config <file>   Configuration file path
  --json               Output results in JSON format

clean - Code Cleanup

Execute code cleanup operations.

code-sweeper clean [options]

Options:
  -p, --path <path>     Target directory path (default: current directory)
  -c, --config <file>   Configuration file path
  --dry-run            Preview mode, don't actually modify files
  --imports            Only clean unused imports
  --variables          Only clean unused variables
  --console            Only remove console statements
  --debugger           Only remove debugger statements
  -y, --yes            Skip confirmation prompts

config - Configuration Management

Manage cleanup rule configurations.

code-sweeper config [options]

Options:
  --init               Initialize configuration file
  --show               Show current configuration

⚙️ Configuration File

Create a .code-sweeper.json file in your project root:

{
  "rules": {
    "removeUnusedImports": true,
    "removeUnusedVariables": true,
    "removeConsoleLog": true,
    "removeDebugger": true,
    "formatCode": false,
    "renameToCamelCase": false
  },
  "include": [
    "src/**/*.{js,ts,jsx,tsx}",
    "components/**/*.{js,ts,jsx,tsx}"
  ],
  "exclude": [
    "node_modules/**",
    "dist/**",
    "build/**",
    "*.min.js"
  ],
  "parser": {
    "typescript": true,
    "jsx": true,
    "decorators": true,
    "classProperties": true
  }
}

📊 Usage Examples

Analysis Result Example

$ code-sweeper analyze

🔍 Code Sweeper - Analyzing your code...
📁 Target path: /Users/project/src

📊 Code Analysis Report
══════════════════════════════════════════════════

📈 Summary:
   • Total files scanned: 45
   • Files with issues: 12
   • Total issues found: 28

🔍 Issue Breakdown:
   • Unused imports: 15
   • Unused variables: 8
   • Console statements: 3
   • Debugger statements: 2

💡 Recommendations:
   • Run code-sweeper clean to fix these issues
   • Use --dry-run flag to preview changes first

Cleanup Result Example

$ code-sweeper clean

🧹 Code Sweeper - Cleaning your code...

✅ Cleaning completed!

📊 Summary:
   • Files modified: 8
   • Issues fixed: 23
   • Lines removed: 45
   • Estimated size reduction: ~2.1KB

🛠️ Development

# Clone the project
git clone https://github.com/william-xue/code-sweeper.git
cd code-sweeper

# Install dependencies
npm install

# Build project
npm run build

# Run tests
npm test

# Local development
npm run dev

🤝 Contributing

Welcome to submit Issues and Pull Requests!

  1. Fork this project
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

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

🙏 Acknowledgments


Make code cleaner, make development more efficient! 🚀