Menu

1 / 2

I Built an AI-Powered Dead Code Detector for VS Code (and It Goes Way Beyond Unused Imports)

DEV Community·Naimul Karim·6 months ago
#kavfRDhl
#vscode#typescript#ai#code#dead
Reading 0:00
15s threshold

We've all been there. You're reading through a codebase and you spot it — a feature flag that's been set to false for two years, a function exported from a module that nothing ever imports, a block of logic sitting underneath a return statement that will never, ever run.

ESLint catches unused variables. TypeScript catches type mismatches. But dead business logic ? That's a different beast — and that's what I built this extension to hunt.

What Is "Dead Code" Really?

Most linters think dead code = unused variable. But in production codebases the real offenders are:

1. Unreachable Logic

Code that can never execute — not because of a syntax issue, but because of your business logic:

function calculateDiscount ( price : number , userType : string ): number { if ( userType === " admin " ) { return price * 0 ; } return price * 0.9 ;

// 💀 Never reached — the return above always fires const bonus = price * 0.05 ; console .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.