Skip to content

Introduction

Unreach is a powerful CLI tool that uses advanced static analysis to find truly unused code in your codebase. Unlike simple file-based tools, Unreach follows actual import/export chains to ensure 100% accuracy in detecting unused code.

What is Unreach?

Unreach is a command-line tool that deeply analyzes your codebase to identify:

  • Unused packages - npm packages that are installed but never imported
  • Unused imports - Import statements that import symbols never used
  • Unused exports - Exported symbols that are never imported elsewhere
  • Unused functions - Functions that are defined but never called
  • Unused variables - Variables that are declared but never referenced
  • Unused types - TypeScript types, interfaces, and enums that are never used
  • Unused files - Files that are never imported or referenced
  • Unused configs - Unused configuration keys in package.json and tsconfig.json
  • Unused scripts - npm scripts that are never executed
  • Unused CSS classes - CSS classes defined but never used in JSX/TSX
  • Unused assets - Image and font files that are never imported

Why Unreach?

Traditional tools often miss unused code because they only check file existence or simple patterns. Unreach goes deeper:

Real Dependency Tracking

Unreach follows actual import/export chains, not just file existence. This ensures accurate detection of truly unused code by understanding how your code is actually connected.

TypeScript Support

Full support for TypeScript, including:

  • Type-only imports/exports
  • Type definitions
  • Interface declarations
  • Generic types
  • Enums

Comprehensive Analysis

Unreach analyzes your entire codebase structure, including:

  • JavaScript and TypeScript files
  • JSX/TSX React components
  • Configuration files
  • Package dependencies
  • CSS classes
  • Asset files

How It Works

Unreach uses advanced static analysis to:

  1. Parse your codebase - Uses TypeScript's parser to build an Abstract Syntax Tree (AST) of all files
  2. Build dependency graph - Creates a graph of all imports, exports, and function calls
  3. Track reachability - Starting from entry points, marks all reachable code
  4. Identify unused code - Reports everything that isn't reachable from entry points

This approach ensures 100% accuracy - if code is truly unused, Unreach will find it.

Key Features

  • Real dependency tracking - Follows actual import/export chains
  • TypeScript support - Full support for TypeScript features
  • Dynamic import support - Tracks dynamic imports (import()) and conditional imports
  • JSX/TSX support - Analyzes React components and JSX element usage
  • Entry point detection - Automatically detects entry points from package.json and tsconfig.json
  • Test file detection - Automatically excludes test files from analysis
  • Multiple export formats - Export results in JSON, CSV, TSV, Markdown, or HTML
  • Configuration files - Support for unreach.config.js and unreach.config.ts
  • Watch mode - Continuously monitors files and re-scans on changes
  • Interactive mode - Menu-driven interface for configuring scans

Quick Start

Get started with Unreach in seconds:

bash
# Run with npx (no global install)
npx unreach@latest scan

# Or install globally
npm install -g unreach
# Then run
unreach scan

Next Steps


"Unreach: Find what you can delete without breaking your project."

Released under the MIT License.