Skip to content

Enforce specification of return types in TypeScript#314

Merged
mcmire merged 2 commits intomainfrom
explicit-function-return-type
Jul 26, 2023
Merged

Enforce specification of return types in TypeScript#314
mcmire merged 2 commits intomainfrom
explicit-function-return-type

Conversation

@mcmire
Copy link
Copy Markdown
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
Copy Markdown
Member

Gudahtt commented Jul 25, 2023

Looks great! Snapshots need updating though

Copy link
Copy Markdown
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
Copy Markdown
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
@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