ESLint complains about unused variable when variable of it is used to define Typescript parameter type
See original GitHub issueTell us about your environment
- ESLint Version: 6.8.0
- Node Version: 12.16.3
- npm Version: 6.14.5
What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser Please show your full configuration:
Configuration
{
"env": {
"es6": true,
"node": true
},
"extends": [
"google"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
4
],
"require-jsdoc": 0
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
import * as Discord from 'discord.js';
export class CommandService {
parseCommand(msg: Discord.Message) {
// if (msg instanceof Discord.Message) console.log('');
}
}
eslint "**/*.ts"
What did you expect to happen? Should have no error.
What actually happened? Please include the actual, raw output from ESLint. services/command.service.ts 1:13 error ‘Discord’ is defined but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)
Are you willing to submit a pull request to fix this bug? Don’t know how.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
ESLint warns about unused function parameter type
ESLint warns about unused function parameter type · 1. It's an issue with ESLint parsing the TS type. The rule itself is broken...
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
This rule is aimed at eliminating unused variables, functions, and function parameters. A variable foo is considered to be used if any of...
Read more >no-unused-vars - TypeScript ESLint
Disallow unused variables. ... Examples. This rule extends the base eslint/no-unused-vars rule. It adds support for TypeScript features, such as types.
Read more >'X' is declared but its value is never read in TypeScript
To solve 'is declared but its value is never read' error in TypeScript, prefix any unused parameter name with an underscore, or disable...
Read more >Improving code quality in Typescript with compiler options
This error is produced because we declared the digits variable without using it. You can get rid of this error by using the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to extend typescript-eslint rules if you are using it for typescript. for
no-unused-vars
, use this rule andno-unused-vars-experimental
.This should be fixed with #13235