-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
enhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
I've seen the following pattern in code several times now, and it leads to some confusion:
function doSomething(): void {
// Returns nothing
}
const result = await myPromise.then(() => {
return doSomething();
});
The bottom statement suggests that a value is being returned from doSomething()
, while in reality its type is void
.
It would be great to have a rule that enforces removing this misleading return
keyword:
const result = await myPromise.then(() => {
doSomething();
});
This code style removes the suggestion that result
will be anything other than void
/ undefined
.
I think this rule is a good fit for @typescript-eslint/eslint-plugin
because it must know about the return type of the called function.
sindresorhus and glen-84
Metadata
Metadata
Assignees
Labels
enhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin