Skip to content

ElijahKotyluk/devoid

Repository files navigation

Devoid

Dead-Code Analysis for JavaScript & TypeScript

npm version npm downloads license node

Devoid is a fast static analyzer that detects:

  • Unused exports
  • Unused local identifiers (functions, variables, classes, types)
  • Unused files
  • Incorrect or unreachable re-exports
  • Usage propagation through wildcards and barrel modules
  • Import resolution via TS path aliases, directory imports, and relative paths

Devoid is powered the TypeScript Compiler API directly at runtime — no other dependencies.


Installation

Global

npm install -g devoid
# or
pnpm add -g devoid
# or
yarn global add devoid

Project

npm install -D devoid
# or
pnpm add -D devoid
# or
yarn add -D devoid

CLI Usage

devoid src/

Common Flags

devoid src/ --exports
devoid src/ --files
devoid src/ --locals
devoid src/ --json

Analysis Modes

Unused Exports

List exports that are never imported or referenced:

devoid src/ --exports

Unused Files

List files that are unreachable from the entrypoints and have no side effects:

devoid src/ --files

Unused Local Identifiers

Detect unused classes, enums, functions, and variables within files:

devoid src/ --locals
# or
devoid src/ --identifiers

Enable strict mode to include type declarations:

devoid src/ --locals --track-all-locals

Types

Detect unused exported types and local type declarations:

devoid src/ --types

Types mode:

  • Tracks type and interface usage only
  • Respects import type and export type
  • Follows barrel and wildcard type re-exports
  • Does not require the TypeScript type checker
  • Does not affect runtime export analysis

Output Options

JSON

devoid src/ --json

Summary

devoid src/ --summary-only

Verbose

Print raw graphs for debugging:

devoid src/ --verbose

Internal (Single-File) Analysis

Analyze unused identifiers within a single file only:

devoid internal src/utils/helpers.ts

Enable strict local tracking:

devoid internal src/utils/helpers.ts --track-all-locals

Misc Options

Ignore Paths

Ignore files or directories containing a substring:

devoid src/ --ignore dist --ignore generated

Color Control

devoid src/ --no-color
devoid src/ --color

License

MIT © Elijah Kotyluk

About

Dead code analysis

Resources

License

Stars

Watchers

Forks

Packages

No packages published