-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add ts eslint rule: explicit-function-return-type #1215
Comments
I'm not sure we are going to be able to use this rule, because it is requiring return types on all functions, not just methods. There is no option to check just method declarations. That said, if we adapted our own (not recommending) we could just check on function declarations and not on function/arrow function expressions. |
It looks like there is a compiler option: |
@jessegreenberg offered to help out on this. |
Perhaps it would be pretty easy to use this as a base, and or the visibility annotation rule we already have for javascript. |
Surprisingly nothing different had to be done for custom TS rules. I added a custom lint rule that requires a return type for method definitions excluding constructors getters and setters. There are 1584 errors, I scanned them and they seem like legit hits. I disabled it for now. Could be a lot of work now to get clean. |
How difficult is it to write an autofix step that uses the inferred type? I'm not saying to commit that blindly, but it could convert 1584 occurrences and then spot checking them could be much faster than writing all of them. |
That could be worthwhile, Ill take a look. |
Yes, this is working well! This rule now requires type information ( To run this with auto fix
|
Can we do this and then remove the dependency on parserOptions.project after we fix? |
With the great help from @jessegreenberg I was able to turn this rule on! Thanks for helping to squash false positives. There should be no spots where the fixer input |
This reverts commit dd7da69.
Three more TODOs in this issue: chipper/eslint/rules/explicit-method-return-type.js Lines 50 to 52 in 02150cc
From #1372 |
From #1114, there are currently 2963 issues with default options (which I'm unsure we will want). We certainly want this rule though, so I'll take a look.
To turn it on (not sure if these are the options either)
The text was updated successfully, but these errors were encountered: