https://github.com/sulthonzh/deadcode-hunter
Find unused exports and dead code paths in JS/TS projects. Zero deps.
https://github.com/sulthonzh/deadcode-hunter
dead-code javascript static-analysis typescript unused-exports
Last synced: 22 days ago
JSON representation
Find unused exports and dead code paths in JS/TS projects. Zero deps.
- Host: GitHub
- URL: https://github.com/sulthonzh/deadcode-hunter
- Owner: sulthonzh
- Created: 2026-06-12T20:49:14.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-06-16T05:19:50.000Z (about 1 month ago)
- Last Synced: 2026-06-16T07:43:32.785Z (about 1 month ago)
- Topics: dead-code, javascript, static-analysis, typescript, unused-exports
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# deadcode-hunter ๐งน
Find unused exports and dead code paths in your JS/TS projects. Zero dependencies.
Because shipping code nobody imports is like writing a letter nobody reads โ it's there, it takes up space, and it confuses anyone who opens the file.
## What it does
Scans your source tree, extracts every `export` and every `import`, then tells you which exported symbols are never imported anywhere. Supports:
- Named exports (`export const/function/class/interface/type`)
- Default exports
- Export lists (`export { a, b }`)
- Named imports, default imports, star imports
- CommonJS `require()` with destructuring
- Dynamic `import()`
- Re-exports (`export * from '...'`)
## Install
```bash
npm install -g deadcode-hunter
# or
npx deadcode-hunter ./src
```
## Usage
```bash
# Basic scan
deadcode-hunter ./src
# JSON output (for tooling)
deadcode-hunter ./src --json
# Specify entry points (always considered "used")
deadcode-hunter ./src --entry index.ts,cli.ts
# Custom extensions and ignore patterns
deadcode-hunter ./src --ext .js,.ts --ignore dist,generated
```
## Programmatic API
```js
const { analyze, formatResults } = require('deadcode-hunter');
const results = analyze('./src', {
extensions: ['.js', '.ts'],
entryPoints: ['index.ts'],
ignore: [/node_modules/, /dist/],
});
console.log(formatResults(results));
// or use results.unusedExports directly
```
## Output example
```
Found 3 unused export(s):
src/utils.js
โ formatDate (line 12, named)
โ parseConfig (line 45, named)
src/api.js
โ default (line 1, default)
Stats: 28 exports, 25 used, 3 unused (89% usage)
Files scanned: 14
```
## CI Integration
Exit code is `1` if any unused exports are found, `0` if clean. Perfect for CI pipelines:
```yaml
- name: Check for dead code
run: npx deadcode-hunter ./src
```
## Why?
Tree-shaking helps at bundle time, but dead code still hurts during development:
- More code to read and understand
- More code to maintain and test
- Confusing API surface ("is anyone using this?")
Deadcode Hunter catches it at the source level, before it even gets to your bundler.
## License
MIT