Why ESLint throws 'no-unused-vars' for TypeScript interface?
Source: I am the maintainer of the typescript-eslint
project.
The latest version of the @typescript-eslint
tooling now has full support for scope analysis.
So the steps to fix this are now:
- update your versions to at least v4.9.1 of
@typescript-eslint/parser
and@typescript-eslint/eslint-plugin
- update your ESLint version to at least v6.0.0
- update your config to use
@typescript-eslint/no-unused-vars
- Do not use the base
no-unused-vars
rule - see this FAQ article in the project.
- Do not use the base
Restart your IDE and you should now see the correct lint errors.
Use @typescript-eslint/no-unused-vars-experimental
and turn off @typescript-eslint/no-unused-vars
.
The issue is resolved in the latter version (experimental).
Sample config:
// .eslintrc{ ... "rules": { "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-unused-vars-experimental": "error" } ...}
add this to Eslint rules
"rules": { "@typescript-eslint/no-unused-vars": [ 2, { "args": "none" } ] }