Skip to content

Commit

Permalink
Enforce specification of return types in TypeScript (#314)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mcmire committed Jul 26, 2023
1 parent 860d5ec commit 2ad7f6b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/typescript/rules-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/default-param-last": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/naming-convention": [
"error",
{
Expand Down
1 change: 1 addition & 0 deletions packages/typescript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = {
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': [
'error',
Expand Down

0 comments on commit 2ad7f6b

Please sign in to comment.