Detect and report dead code in JavaScript/TypeScript projects.
# Full scan — unused exports, files, and dependencies
python3 scripts/find_dead_code.py /path/to/project
# Exports only
python3 scripts/find_dead_code.py /path/to/project --mode exports
# Unused files only
python3 scripts/find_dead_code.py /path/to/project --mode files
# Unused dependencies only
python3 scripts/find_dead_code.py /path/to/project --mode deps
# JSON output for programmatic use
python3 scripts/find_dead_code.py /path/to/project --json
Exported functions, classes, constants, types, and interfaces never imported anywhere.
export function foo, export const bar)export { x } from './y')export type, export interface)Files never imported by any other file in the project.
npm packages in package.json never imported in code.
dependencies and devDependenciesDefault entry points: src/index.{ts,tsx,js,jsx}, src/main., src/app., pages//, app//.
Default ignores: node_modules, dist, build, .next, coverage, __tests__, .test., .spec., .config., *.d.ts.
Override via flags:
--entry "src/main.ts,src/worker.ts"
--ignore "generated,vendor"
=== Dead Code Report ===
UNUSED EXPORTS (12 found):
src/utils/helpers.ts: formatDate, parseQuery, slugify
src/components/Button.tsx: ButtonProps (type)
src/api/client.ts: createClient
UNREFERENCED FILES (3 found):
src/legacy/oldAuth.ts
src/utils/deprecated.ts
src/components/unused/Card.tsx
UNUSED DEPENDENCIES (2 found):
moment
lodash.merge
export * partially supported共 1 个版本