-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [return-await] allows function without return #8651
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
Comments
This rule allows/disallows returned promises to be awaited. It doesn't say anything about non-returned promises. Why would you want this code to be flagged, anyway? |
Josh is correct - this rule doesn't enforce a promise is returned only that a returned promise is or isn't awaited. Closing as working as intended. Feel free to continue discussing though and we can reopen if required. |
Fair enough that I misinterpreted what this rule was supposed to do, but I keep reading and re-reading the documentation, and I'm not convinced it actually says what this rule does. What is says it does:
What it actually does:
Wordier but more complete version:
The reason I thought I wanted it to actually return the awaited value is to enable better stack traces, but I acknowledge I don't quite get the exact circumstances under which it's necessary to return the awaited expression to attain that benefit. It would be nice if the documentation made the stack trace behavior for the different options of this rule crystal clear, as it's difficult to really make an intelligent decision about this rule's options without this knowledge. For what it's worth, my codebase currently uses |
The wording in the docs is a bit cumbersome - happy to accept a PR if you think you can improve the docs. |
@bradzacher, my previous comment is a pretty good preview of how I think the docs could be improved. I'm happy to work on a pull request, but I would appreciate some feedback on the two different wording options I offered as well as some help with my question about stack trace behavior |
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.4.2&fileType=.tsx&code=PTAEDkHtQUwJzpOpIGNUFc4GdQDMlQAXACwEtsAaWADwAcZUiYATUAQwDtYEkAuALAAoGPSREO2AJ6dU%2BDLKJlI3InCkAVdQEEA5uzKcAFAEpQAb2GgOAdwMSACogC2FGADo4MbJAA2ANxhTAG5QEFBsEkgMXzYAIxgObnhEZC42PDIaYmgvIixudjsyRxc3T28-QKMAIn92XwwYGpNhAF8gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQHYHsBaaRAF1ml0IEMB3agS1PSnwDM3IAacbGRAI6wGJGvSYtI7Tj2xQAAqQCeABxQBjaAxWlCKeA1ykA9CSEjEYxswyRE0aPmjdeORao1ade5AaOmyCio6axYAbVc%2Be0dnWTkoanh6JVRIgF1eAF8QTKA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
Expected an error
Actual Result
No error, no autofix to
return await
Additional Info
I do get an error and fix if I put only
return Promise.resolve("value")
.The text was updated successfully, but these errors were encountered: