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?
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:
plugin:@typescript-eslint/no-unused-private-class-members
- to catch unused private
properties (and explains why this is unintuitively tricky)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With