devghost
Version:
π» Find dead code, dead imports, and dead dependencies before they haunt your project
170 lines (128 loc) β’ 5.59 kB
Markdown
# π» **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>