Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of noUnusedParameters in @typescript-eslint

I'm trying to improve developers' experience of a React+TS project. I find noUnusedLocals and noUnusedParameters quite useful for the project but these rules complicate development and, especially, debug process more often than never. That's why I try to disable them on the compiler level but keep them in linter.

Apparently TypeScript Eslint plugin provides @typescript-eslint/no-unused-vars as an alternative to noUnusedLocals.

But I'm struggling to find a proper alternative to noUnusedParameters. Which could be helpful to catch unused class properties and methods. Is there any way to catch unused parameters in linter or at least to decrease its severity on compiler level?

like image 461
sneas Avatar asked Oct 19 '25 01:10

sneas


1 Answers

Looking at each of the areas of unused code, this table summarizes how each tool can or can't detect it statically:

Area TypeScript typescript-eslint
Unused parameters "noUnusedParameters plugin:@typescript-eslint/no-unused-vars
Unused private properties "noUnusedLocals" (not available yet - see below)
Unused # properties "noUnusedLocals" no-unused-private-class-members
Unused variables "noUnusedLocals" plugin:@typescript-eslint/no-unused-vars

There are a couple open relevant typescript-eslint issues:

  • #4571 Rule proposal: no-unused-private-class-members: tracks creating an extension rule -plugin:@typescript-eslint/no-unused-private-class-members- to catch unused private properties (and explains why this is unintuitively tricky)
  • #8218 Docs: Mention no-unused-private-class-members in no-unused-vars: tracks mentioning this situation more in docs
like image 156
Josh Avatar answered Oct 20 '25 15:10

Josh