Debtmap v0.15.0 adds JavaScript and TypeScript support using tree-sitter.
Some history: debtmap originally supported multiple languages, but I removed JS/TS in v0.7.0 to focus on Rust. The multi-language implementation was half-baked and the maintenance burden wasn’t worth it. After getting the Rust analyzer right (entropy dampening, purity analysis, call graph integration), I rebuilt JS/TS support properly in v0.14.0-v0.15.0.
What It Detects#
Complexity metrics - cyclomatic, cognitive, and nesting depth. Cognitive complexity adds nesting penalties because if inside for inside if is harder to read than the same number of branches at the top level.
Async patterns - callback nesting depth, promise chain length, missing .catch() handlers. These create complexity that traditional metrics miss.
TypeScript-specific - excessive any usage (>5 per file), type assertion overuse (>3), non-null assertion overuse (!).
Functional chains - detects map/filter/reduce pipelines and flags side effects in them (console, mutations, I/O).
Entropy Dampening#
v0.15.0 adds entropy-based complexity dampening for JS/TS. This reduces false positives for repetitive code.
Consider validation functions that check multiple fields with similar logic:
function validateConfig(config: Config): string[] {
const errors: string[] = [];
if (config.width !== undefined) {
if (typeof config.width !== 'number') errors.push('width must be number');
else if (config.width < 0) errors.push('width must be positive');
else if (config.width > 10000) errors.push('width exceeds max');
}
if (config.height !== undefined) {
if (typeof config.height !== 'number') errors.push('height must be number');
else if (config.height < 0) errors.push('height must be positive');
else if (config.height > 10000) errors.push('height exceeds max');
}
return errors;
}
Raw cyclomatic complexity: 10. But this is repetitive validation with low token entropy - the same pattern repeated for different fields. Debtmap detects this and dampens the score.
The better fix is extracting validation functions, but the tool shouldn’t flag every validation function as high-priority debt.
Usage#
# Install
cargo install debtmap
# Analyze (opens interactive TUI)
debtmap analyze .
# With coverage data and git context
debtmap analyze . --lcov coverage/lcov.info --context
# Export for CI or LLM consumption
debtmap analyze . --format markdown --top 10 --lcov coverage/lcov.info --context
JS/TS files are detected automatically by extension (.js, .ts, .jsx, .tsx, .mjs, .cjs, .mts, .cts).
What It Doesn’t Do#
Debtmap identifies where debt is and how severe it is. It doesn’t:
- Replace ESLint/TSLint (style enforcement)
- Replace the TypeScript compiler (type checking)
- Generate coverage data (use Jest, Vitest, etc.)
- Tell you how to fix things (that’s for you or your AI assistant)
