Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint complains about unused variable when variable of it is used to define Typescript parameter type #13263

Closed
justin13888 opened this issue May 5, 2020 · 5 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon

Comments

@justin13888
Copy link

Tell 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.

@justin13888 justin13888 added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels May 5, 2020
@anikethsaha
Copy link
Member

You need to extend typescript-eslint rules if you are using it for typescript.
for no-unused-vars, use this rule and no-unused-vars-experimental.

@justin13888
Copy link
Author

Thanks. Really hope they implement the work around soon.

@anikethsaha
Copy link
Member

Really hope they implement the work around soon.

eslint supports typescript through typescript-eslint project. So I guess it is expected behavior.

@justin13888
Copy link
Author

The code you mentioned isn't automatically generated when using eslint --init. So others may easily face this issue as well in the future.

@mdjermanovic
Copy link
Member

The code you mentioned isn't automatically generated when using eslint --init. So others may easily face this issue as well in the future.

This should be fixed with #13235

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 3, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon
Projects
None yet
Development

No branches or pull requests

3 participants