npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@idirdev/deadcode

v1.0.0

Published

Find unused exports and dead code in JavaScript projects.

Downloads

23

Readme

deadcode

[EN] Static analysis tool that finds unused exports and dead functions across your JavaScript and TypeScript codebase. [FR] Outil d'analyse statique qui trouve les exports inutilisés et les fonctions mortes dans votre base de code JavaScript et TypeScript.


Features / Fonctionnalités

[EN]

  • Scans all .js, .ts, .jsx and .tsx files recursively
  • Detects named exports that are never imported anywhere in the project
  • Ignores default and module.exports to avoid false positives
  • Configurable ignore patterns (node_modules, dist, build excluded by default)
  • Custom extension filter via --extensions
  • JSON output mode for integration with CI or other tools
  • Exits with code 1 when dead code is found (fail CI pipelines)
  • No AST parser dependency — lightweight regex-based scanning

[FR]

  • Parcourt récursivement tous les fichiers .js, .ts, .jsx et .tsx
  • Détecte les exports nommés qui ne sont jamais importés dans le projet
  • Ignore default et module.exports pour éviter les faux positifs
  • Patterns d'ignorance configurables (node_modules, dist, build exclus par défaut)
  • Filtre d'extension personnalisé via --extensions
  • Mode de sortie JSON pour l'intégration CI ou d'autres outils
  • Quitte avec le code 1 lorsque du code mort est trouvé (fait échouer les pipelines CI)
  • Aucune dépendance à un parseur AST — scan léger basé sur les expressions régulières

Installation

npm install -g @idirdev/deadcode

CLI Usage / Utilisation CLI

# Scan current directory / Scanner le répertoire courant
deadcode

# Scan a specific project / Scanner un projet spécifique
deadcode ./src

# Only scan TypeScript files / Scanner uniquement les fichiers TypeScript
deadcode ./src --extensions .ts,.tsx

# Ignore additional directories / Ignorer des répertoires supplémentaires
deadcode . --ignore node_modules,dist,coverage,__tests__

# JSON output / Sortie JSON
deadcode ./src --format json

# Use in CI (exits 1 if dead code found) / Utiliser en CI (quitte 1 si code mort trouvé)
deadcode ./src && echo "Clean!"

Example Output / Exemple de sortie

Dead Code Report

src/utils/format.js:14  function  formatCurrency
src/utils/format.js:31  function  parseDuration
src/api/helpers.ts:8    export    buildQueryString
src/components/Modal.jsx:22  export  ModalFooter

4 unused export(s)
# No dead code / Aucun code mort
No dead code found!

API (Programmatic) / API (Programmation)

const { findDeadCode, collectFiles } = require('@idirdev/deadcode');

// Find all unused named exports / Trouver tous les exports nommés inutilisés
const results = findDeadCode('./src', {
  extensions: ['.js', '.ts', '.jsx', '.tsx'],
  ignore: ['node_modules', 'dist', 'build', '__tests__'],
});

// Each result: { name, file, line, type }
results.forEach(r => {
  console.log(`${r.file}:${r.line}  ${r.type}  ${r.name}`);
});

if (results.length > 0) {
  console.log(results.length + ' unused export(s) found');
  process.exit(1);
}

// Collect files only / Collecter uniquement les fichiers
const files = collectFiles('./src', ['.ts', '.tsx'], ['node_modules', 'dist']);
console.log('Files scanned:', files.length);

License

MIT — idirdev