Skip to content

Features

Unreach provides comprehensive analysis of your codebase to find truly unused code. Here's what it can detect:

Unused Packages

Finds npm packages in dependencies, devDependencies, and peerDependencies that are never imported in your code.

bash
unreach scan
# Output:
# Unused packages: 3
#   - lodash (1.2.3)
#   - moment (2.29.4)
#   - axios (0.21.1)

Unused Imports

Identifies import statements that import symbols which are never used in the file.

bash
unreach scan
# Output:
# Unused imports: 5
#   - ./utils.ts [src/components/Button.tsx]
#   - ./types.ts [src/components/Button.tsx]

Unused Exports

Finds exported symbols (functions, classes, variables, types) that are never imported by other files.

bash
unreach scan
# Output:
# Unused exports: 8
#   - helperFunction [src/utils/helpers.ts]:15
#   - OldComponent [src/components/Old.tsx]:3

Unused Functions

Discovers functions that are defined but never called, either directly or through exports.

bash
unreach scan
# Output:
# Unused functions: 12
#   - calculateTotal [src/utils/math.ts]:42
#   - formatDate [src/utils/date.ts]:18

Unused Variables

Identifies variables that are declared but never referenced.

bash
unreach scan
# Output:
# Unused variables: 4
#   - unusedVar [src/utils/helpers.ts]:9
#   - tempData [src/components/App.tsx]:23

Unused Files

Finds files that are never imported or referenced by any other file.

bash
unreach scan
# Output:
# Unused files: 2
#   - src/utils/old-helper.ts
#   - src/components/Deprecated.tsx

Unused Configs

Detects unused configuration keys in package.json and tsconfig.json.

bash
unreach scan
# Output:
# Unused configs: 3
#   - homepage [package.json]
#   - compilerOptions.baseUrl [tsconfig.json]
#   - compilerOptions.experimentalDecorators [tsconfig.json]

Unused Scripts

Finds npm scripts in package.json that are never executed.

bash
unreach scan
# Output:
# Unused scripts: 2
#   - old-build
#   - deprecated-test

Unused Types

Finds TypeScript types, interfaces, and enums that are never used.

bash
unreach scan
# Output:
# Unused types: 5
#   - OldInterface [src/types/old.ts]:10
#   - DeprecatedType [src/types/deprecated.ts]:5

Unused CSS Classes

Identifies CSS classes defined in stylesheets but never used in JSX/TSX files.

bash
unreach scan
# Output:
# Unused CSS classes: 3
#   - .old-button [src/styles/buttons.css]:15
#   - .deprecated-card [src/styles/cards.css]:22

Unused Assets

Finds image and font files that are never imported in your code.

bash
unreach scan
# Output:
# Unused assets: 2
#   - src/assets/old-logo.png
#   - src/assets/unused-font.woff

Key Features

Real Dependency Tracking

Unreach follows actual import/export chains, not just file existence. This ensures accurate detection of truly unused code.

TypeScript Support

Full support for TypeScript, including:

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

Dynamic Import Support

Tracks dynamic imports (import()) and conditional imports, ensuring accurate reachability analysis.

JSX/TSX Support

Analyzes React components and JSX element usage, including:

  • Component imports/exports
  • JSX element references
  • CSS class usage in className attributes

Progress Indicator

Visual progress bar when analyzing large codebases, so you know how long the analysis will take.

Multiple Export Formats

Export results in various formats:

  • JSON - Machine-readable format for automation
  • CSV - Spreadsheet-compatible format
  • TSV - Tab-separated values
  • Markdown (md) - Human-readable markdown format
  • HTML - Beautiful HTML report with styling

Entry Point Detection

Automatically detects entry points or use custom ones. Supports:

  • package.json main field
  • package.json bin field
  • tsconfig.json files array
  • Common entry point patterns
  • Custom entry points via CLI

Test File Detection

Automatically excludes test files from analysis using common patterns:

  • **/*.test.ts, **/*.test.tsx
  • **/*.spec.ts, **/*.spec.tsx
  • **/__tests__/**
  • Configurable via configuration file

Error Recovery

Continues analysis even when individual files have parse errors, ensuring maximum coverage.

Incremental Analysis

Caches analysis results for faster subsequent scans. Only re-analyzes changed files.

File Size Limits

Automatically skips parsing files that exceed size limits (default: 10MB) to prevent performance issues.

Watch Mode

Continuously monitors files and automatically re-scans on changes with rate limiting to prevent excessive scans.

Interactive Mode

Menu-driven interface for configuring scans without remembering command-line flags.

Dependency Visualization

Generate interactive HTML dependency graphs to visualize your codebase structure.

Benchmark Mode

Track and display performance metrics including parse time, analysis time, and memory usage.

Configuration Files

Support for unreach.config.js and unreach.config.ts to customize analysis behavior.

Package Manager Detection

Automatically detects your package manager (npm, yarn, pnpm, bun) and shows correct install commands. Detection is based on:

  1. Lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock)
  2. Environment variables
  3. Defaults to npm if none detected

Released under the MIT License.