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
Declaring a function inside a try/catch prohibited by "no-inner-declaration" #1406
Comments
You can fix this by making your const upload = async function (picture) {
return uploadImage({ profile, picture })
} However, this raises a good point. Now that ES6 has shipped everywhere, block-scoped functions are supported widely. Perhaps we can disable this rule now? Anyone have thoughts? |
It seems that indeed functions should be allowed. From the rule docs:
Regarding variables, perhaps we should allow them as well and so disable this rule and enable
|
Variables are allowed. This rule is set to only prevents function declarations.
I'd like to move to |
Thank you for the clarifications, @feross. Then, it seems to be clear that we just drop this rule and enable |
Yep. |
This will ship in standard v15. |
I find myself wanting to create a function inside a
try
/catch
block. For example:I want to declare
upload
inside thetry
so I can take advantage ofprofile
being in scope. However, this apparently violates theno-inner-declarations
rule.Can someone explain why this rule is important here? Should
no-inner-declaration
perhaps not apply totry
/catch
?The text was updated successfully, but these errors were encountered: