Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce specification of return types in TypeScript #314

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Jul 25, 2023

Enable the @typescript-eslint/explicit-function-return-type rule, which enforces that return types are specified for all functions. Being explicit about the return type makes it easier to see it without having to open the code in an editor, and communicating what a function ought to return prevents bugs from sneaking in (in case the return value is not being tested).


Extracted from MetaMask/contributor-docs#11 (comment).

Enabling this on core would produce 603 violations.

Enabling this on snaps would produce 571 violations.

Enable the `@typescript-eslint/explicit-function-return-type` rule,
which enforces that return types are specified for all functions. Being
explicit about the return type makes it easier to see type without
having to open the code in an editor, and communicating what a function
_ought_ to return prevents bugs from sneaking in (in case the return
value is not being tested).
@mcmire mcmire requested a review from a team as a code owner July 25, 2023 21:59
@mcmire mcmire changed the title Enforce return types in TypeScript Enforce specification of return types in TypeScript Jul 25, 2023
@Gudahtt
Copy link
Member

Gudahtt commented Jul 25, 2023

Looks great! Snapshots need updating though

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@legobeat legobeat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best new rule this year!

@mcmire mcmire merged commit 2ad7f6b into main Jul 26, 2023
14 checks passed
@mcmire mcmire deleted the explicit-function-return-type branch July 26, 2023 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants