UNPKG

devghost

Version:

πŸ‘» Find dead code, dead imports, and dead dependencies before they haunt your project

170 lines (128 loc) β€’ 5.59 kB
# πŸ‘» **DevGhost** – The Exorcist for Your Codebase <div align="center"> <img src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExbmZ5Z2Z5Z2Z5Z2Z5Z2Z5Z2Z5Z2Z5Z2Z5Z2Z5Z2Z5Z2Z5/xT9IgG50Fb7Mi0prBC/giphy.gif" alt="Ghost Busters" width="200" /> <p> <a href="https://www.npmjs.com/package/devghost"><img src="https://img.shields.io/npm/v/devghost?color=blue&logo=npm" alt="npm version" /></a> <a href="https://www.npmjs.com/package/devghost"><img src="https://img.shields.io/npm/dm/devghost?color=green&logo=npm" alt="npm downloads" /></a> <a href="https://github.com/Haileyesus-22/devghost/actions"><img src="https://img.shields.io/github/actions/workflow/status/Haileyesus-22/devghost/ci.yml?branch=main&logo=github" alt="CI status" /></a> <a href="https://github.com/Haileyesus-22/devghost"><img src="https://img.shields.io/github/stars/Haileyesus-22/devghost?style=social" alt="GitHub stars" /></a> <a href="https://github.com/Haileyesus-22/devghost/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/devghost" alt="license" /></a> <a href="https://marketplace.visualstudio.com/items?itemName=haileyesus.devghost-vscode"><img src="https://img.shields.io/badge/VSCode-v0.1.6-blue?logo=visual-studio-code" alt="VSCode Extension" /></a> </p> </div> > **Is your project haunted by dead code?** - πŸ“„ Export to PDF - βœ… **VSCode Extension v0.1.6** – Fix Entire Workspace command - βœ… **74% Test Coverage** – 68 tests, all passing --- ## ✨ Core Features - πŸ“Š **HTML Reports** – Generate beautiful, shareable visual reports with `--report html` - πŸ” **Smart Detection** – deep static analysis via the TypeScript Compiler API - 🧹 **Auto‑Fix** – `--fix` removes unused imports, `--fix‑deps` removes dead dependencies - 🎯 **Interactive Mode** – review each issue one‑by‑one - πŸ“¦ **Dependency Cleanup** – safely uninstall unused npm packages - πŸ’Ύ **Impact Analysis** – see how many KB/LOC you'll save - πŸš€ **CI/CD Ready** – `--ci` exits with code 1 on any issue - 🎨 **Beautiful Output** – colour‑coded, easy‑to‑read reports - 🧩 **Unused Types** – interfaces, type aliases, enums, classes - πŸ”’ **Unused Variables** – dead `const/let` and function parameters - ⚑ **Fast** – analyses large projects in seconds --- ## οΏ½ Why DevGhost? Most tools just **list** dead code. DevGhost **exorcises** it. - **πŸ›‘οΈ Safety First**: The interactive mode lets you approve every single deletion. - **🧹 True Cleanup**: We don't just find unused files; we remove unused *imports*, *variables*, and *types* inside your files. - **🧠 Deep Analysis**: Uses the TypeScript Compiler API for precision, not just regex. npm install -g devghost ``` ### Install as Dev Dependency ```bash npm install -D devghost ``` --- ## πŸ“– Usage ```bash # πŸ‘» Basic scan (default) devghost # οΏ½ Generate HTML report (NEW in v0.4!) devghost --report html # πŸ“„ Custom output path devghost --report html --output ./reports/analysis.html # οΏ½πŸ›‘οΈ Interactive mode (approve every change) devghost --interactive # 🧹 Auto-fix unused imports devghost --fix # βš™οΈ Auto-fix unused functions devghost --fix-functions # πŸ“¦ Auto-fix unused dependencies devghost --fix-deps # πŸš€ CI mode (exit with error if issues found) devghost --ci ``` ### HTML Report Features 🎨 The new HTML report provides: - **πŸ“Š Visual Dashboard** – Stats cards and interactive Chart.js charts - **πŸ” Smart Explorer** – File-grouped issues with search & category filters - **πŸŒ“ Theme Toggle** – Beautiful dark/light mode - **πŸ“‹ Copy Commands** – One-click to get auto-fix CLI commands - **⏱️ Time Estimates** – See manual review time vs. auto-fix time - **πŸ“„ Export to PDF** – Print or save reports for documentation - **πŸ“± Fully Responsive** – Works great on mobile, tablet, and desktop ### Sample output ``` πŸ‘» DevGhost - Dead Code Detective ======================================== βœ“ Scanned 234 files ❌ 3 unused imports ❌ 2 unused exports ❌ 2 orphaned files ❌ 1 dead dependency πŸ’Ύ Potential savings: 15 KB, 465 lines, 45 MB deps ``` --- ## πŸ› οΈ Configuration Create a `devghost.config.json` to tailor the hunt: ```json { "ignore": ["**/*.test.ts", "**/legacy/**"], "entry": ["src/index.ts"], "includeDev": false } ``` ### Ignore comments ```typescript // devghost-ignore-next-line import { willUseLater } from './future'; // devghost-ignore-file ``` --- ## πŸ”§ Troubleshooting ### "No entry points found" **Solution**: Specify entry points in `devghost.config.json`: ```json { "entry": ["src/index.ts", "src/cli.ts"] } ``` ### False positives with dynamic imports **Solution**: Use ignore comments for intentional code: ```typescript // devghost-ignore-next-line import('./dynamic-feature'); ``` ### Slow on large projects **Solution**: Add more specific ignore patterns: ```json { "ignore": ["**/node_modules/**", "**/dist/**", "**/*.test.ts"] } ``` We love community ghosts! To contribute: 1. Fork the repo 2. Create a feature branch (`git checkout -b feature/awesome‑feature`) 3. Commit your changes (`git commit -m "Add awesome feature"`) 4. Push and open a Pull Request --- ## πŸ“„ License MIT Β© Haileyesus --- <div align="center"> Made with ❀️ (and β˜•) by [Haileyesus](https://github.com/Haileyesus-22) *Don't let dead code haunt you.* </div>