← 返回
未分类 中文

Dead Code Finder

Find and remove dead code in JavaScript/TypeScript projects. Detects unused exports, unreferenced files, orphaned components, unused dependencies, and dead f...
在 JavaScript/TypeScript 项目中查找并移除死代码,检测未使用的导出、未引用文件、孤立组件、未使用依赖及死函数。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 411
下载
💾 1
安装
1
版本
#latest

概述

Dead Code Finder

Detect and report dead code in JavaScript/TypeScript projects.

Quick Start

# 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

What It Detects

1. Unused Exports

Exported functions, classes, constants, types, and interfaces never imported anywhere.

  • Named exports (export function foo, export const bar)
  • Re-exports (export { x } from './y')
  • Type exports (export type, export interface)
  • Barrel file analysis (index.ts re-exports)

2. Unreferenced Files

Files never imported by any other file in the project.

  • Skips entry points (configurable)
  • Skips test files, config files, and scripts by default
  • Handles path aliases (tsconfig paths)

3. Unused Dependencies

npm packages in package.json never imported in code.

  • Checks dependencies and devDependencies
  • Recognizes CLI tools as potentially used
  • Handles scoped packages and subpath imports

Configuration

Default 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"

Interpreting Results

=== 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

Workflow

  1. Run scan on the project
  2. Review report — some findings may be false positives (dynamic imports, reflection)
  3. Verify each finding before removing
  4. Remove confirmed dead code
  5. Run tests to confirm nothing broke

Limitations

  • Dynamic imports with variable paths may cause false positives
  • Code consumed by external packages (libraries) shows as unused
  • CSS/SCSS imports not tracked
  • export * partially supported

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 04:22 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 195 📥 67,819
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 73 📥 182,186
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 679 📥 328,541