Skip to content
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

Some eslint fixes #428

Merged
merged 25 commits into from
Aug 30, 2022
Merged

Some eslint fixes #428

merged 25 commits into from
Aug 30, 2022

Conversation

typeofweb
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Aug 29, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-storefront ✅ Ready (Inspect) Visit Preview Aug 30, 2022 at 9:51AM (UTC)
saleor-app-checkout ✅ Ready (Inspect) Visit Preview Aug 30, 2022 at 9:51AM (UTC)
saleor-checkout ✅ Ready (Inspect) Visit Preview Aug 30, 2022 at 9:51AM (UTC)
saleor-checkout-ui-kit ✅ Ready (Inspect) Visit Preview Aug 30, 2022 at 9:51AM (UTC)

Copy link
Member

@witoszekdev witoszekdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the stuff are just commends - except the one about require-await - this really has bitten me in the past, so I would prefer to keep using this rule

setSelectedSavedAddress(address);
updateAddressMutation({
const _errors = await updateAddressMutation({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to assign response to a _errors?

Can'we just do this?

Suggested change
const _errors = await updateAddressMutation({
await updateAddressMutation({

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want us to come back to these places and actually handle errors… :D I'll add some @todo comments.

apps/saleor-app-checkout/package.json Show resolved Hide resolved
packages/checkout-storefront/.eslintrc.js Show resolved Hide resolved
Comment on lines +49 to +50
// we sometimes use async functions that don't await anything
"@typescript-eslint/require-await": "off",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offf... I really don't like this. We've specifically added this rule due to issues in API routes in Next.js - sometimes forgetting await caused unexpected issues on production that were not visible in development.

I know that this can be annoying (you need to add either void or await) but IMHO this is a worthy tradeoff. Since API routes are main use case, we could enable it only for them? 🤔

Copy link
Contributor Author

@typeofweb typeofweb Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're talking about another rule – no-misused-promises or no-floating-promises maybe?

require-await is about ensuring you only add async to functions that actually use await and remove async when functions don't use await. Which, in my opinion, is pointless – we often want async functions which don't use await – we just want to make sure they return a Promise. I don't see any value in this rule apart from maybe very minor (negligible) performance hit for using async where sync function would be enough.

Copy link
Contributor Author

@typeofweb typeofweb Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll also enable "@typescript-eslint/return-await": ["error", "in-try-catch"], because we want to force return await inside of try…catch blocks and forbid it elsewhere.

turbo.json Outdated Show resolved Hide resolved
turbo.json Show resolved Hide resolved
packages/eslint-config-checkout/index.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants