Rule proposal: no-void-return-type
#7250
Labels
enhancement: new plugin rule
New rule request for eslint-plugin
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
wontfix
This will not be worked on
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
The
void
type in TypeScript shouldn’t exist, because it represents something that doesn’t exist in JavaScript. microsoft/TypeScript#42709 explains it in more depth.There is are the
@typescript-eslint/no-invalid-void-type
and@typescript-eslint/no-meaningless-void-operator
rules. I would like to propose the@typescript-eslint/no-void-return-type
rule to disallow returningvoid
,Promise<void>
, andPromiseLike<void>
.Fail Cases
Pass Cases
Additional Info
TypeScript 5.1 loosened the rules for
void
/undefined
, making it viable to stop usingvoid
.This rule could be auto-fixable by replacing a return type of
void
withundefined
, or adding an explicit return type if none of the branches return an explicit value.It would also just report any usage of
void
.The text was updated successfully, but these errors were encountered: