Skip to main content

no-void-return-type

💼 This rule is enabled in the ✅ recommended config.

Disallows void return types on non-exported functions.

🔧 This rule is automatically fixable by the --fix CLI option.

💭 This rule requires type information.

Rule Details​

Most of the time, programmers do not bother typing void after the functions that they write, since this return type is implied by default. Adding the void annotation to every function would clutter the code.

With that said, some codebases use the explicit-module-boundary-types ESLint rule, which requires that you annotate the type for every exported function. So in this case, typing the void is required for some functions.

However, from time to time, programmers will refactor exported functions to non-exported functions. After doing this, the largely-superfluous void annotation will remain in the code, causing clutter.

To solve the problem, use this lint rule to automatically remove void return types on non-exported functions.

// Bad
function foo(): void {}

// Good
function foo() {}

Options​

This rule is not configurable.

Resources​