-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
enhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
I have the following code:
function foo(count: number) {}
// …
foo(count: lookup);
Where lookup
is number | undefined
.
In this code path, I know for sure that lookup
will be a number, so I have done the following:
foo(count: lookup as number);
But a better solution would have been to use the non-null assertion operator:
foo(count: lookup!);
I would like a rule that enforces this.
It should be noted in the rule docs that this conflicts with the no-non-null-assertion
rule.
Alternatively, the no-non-null-assertion
could be renamed to non-null-assertion
and handle both ways. That might be even better.
szmarczak, j-f1, adidahiya, denkristoffer, niklashigi and 3 more
Metadata
Metadata
Assignees
Labels
enhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin