-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [explicit-function-return-type] Fix allowExpressions ignoring default exports #831
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
Conversation
Thanks for the PR, @Svish! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint |
By the way, I don't know if I should also create an issue for this issue? That's what I considered to do to begin with, but since I realized it would be super easy to fix, I decided to just create a PR directly instead. But yeah... not sure what you want for project tracking purposes and such. 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, and I'm happy with this change.
It's breaking, but we're going to release 2.0 soon, so we can include this.
The code LGTM.
One change before this can be merged; could you please update the rule doc appropriately.
@bradzacher Cool! About updating the rule doc, I definitely could, but looking at it now, I'm not sure exactly what I should update. What it says there now is already correct.
The check I've added is |
… last PR by removing the parameters which are not relevant to the examples
I've added two examples of code that after this change will still be incorrect, even with As a minor cleanup of my own earlier PR, I also simplified the examples for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's perfect. I just wanted to be sure that the export default
case was included in the readme.
LGTM - thanks for doing this.
The current implementation of
allowExpressions
below causes default exports to be allowed/ignored:I really think a default export should be considered as much a declaration/definition as a variable declaration is. Maybe even more so, as it's the main export of a module.
Currently only the last one of these fail when
allowExpressions
is set totrue
:So in this PR I've added
AST_NODE_TYPES.ExportDefaultDeclaration
to the check (and tests for it), so that both those cases are correctly (in my opinion) rejected as lacking a return type.