-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionfeatureThis change adds a new feature to ESLintThis change adds a new feature to ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Description
Environment
What parser are you using?
@typescript-eslint/parser
What did you do?
{
"extends": [
"eslint:all",
"plugin:@typescript-eslint/all"
],
"rules": {
}
}
const foo = (two: string): void => {
"use strict";
// eslint-disable-next-line @typescript-eslint/init-declarations
let one: string | undefined;
if (one === two) {
// Noop
}
}
foo("");
What did you expect to happen?
In this code snippet, let one;
is read but never assigned. I would expect some rule to flag it – the most appropriate one seems like it would be prefer-const
.
What actually happened?
prefer-const
does not complain about this code. (Maybe because const one;
is not allowed syntax?)
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Additional comments
Here is a typescript-eslint version of the playground.
If prefer-const is not the right rule to flag this error, then what is?
kirkwaiblinger
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionfeatureThis change adds a new feature to ESLintThis change adds a new feature to ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Type
Projects
Status
Complete