-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Adjust async/await usage in createAsyncThunk for payloadCreator functions #22452
base: main
Are you sure you want to change the base?
Adjust async/await usage in createAsyncThunk for payloadCreator functions #22452
Conversation
If a promise is returned, the method is recommended to be async (avoids having to both catch errors and catch rejections): |
@mshima, thank you for your response amidst the busy preparations for the v8 release! Since your comment, I have been investigating the 'no-return-await' and 'return-await' issues, among others. The conversation is indeed complex with various intertwined opinions... One thing I found is that 'no-return-await' was removed from JavaScript Standard Style around 2019 due to concerns over 1) stack traces and 2) overlooked async function calls. At this juncture, it might be beneficial to consider adding new rules to "no-return-await": "off",
"@typescript-eslint/return-await": ["error", "always"] |
I’m ok with awaited return value. Always having async at |
4523c15
to
149c7cd
Compare
Thank you @mshima for your comment. I agree with your point on I have made the necessary corrections, which, expressed in eslint terms, would look like the following rules: "no-return-await": "off",
"@typescript-eslint/return-await": ["error", "always"],
"@typescript-eslint/promise-function-async": "error" (Note: I have not committed Please review the changes made. I have followed the Submission Guidelines and executed |
I want to know @qmonmert opinion. I think we had similar code in the past. |
Probably it’s an ejs file, so the rule can be conditional on react. |
Personally I am against |
I need time to watch the video and try to understand the examples, don't understand French 😄. |
Resolves #19133
The payloadCreator in createAsyncThunk has been adjusted according to the following policy. If there are any issues, please let me know and I will promptly make corrections!
async () => {... await axios…}
for the sake of consistency, to reduce the risk of errors during future code modifications, and to align with the common practice seen in createAsyncThunk.!paginationInfiniteScroll
condition is redundant:After making these adjustments, I generated the
react-default
sample and confirmed the following:"require-await": "error"
to.eslintrc.json
and confirmed that no errors are raised when runningnpm run lint
.npm run e2e:cypress
before and after making these changes.Please make sure the below checklist is followed for Pull Requests.
When you are still working on the PR, consider converting it to Draft (below reviewers) and adding
skip-ci
label, you can still see CI build result at your branch.