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

Fix problems reported by eslint #179

Merged
merged 10 commits into from
Jan 23, 2024
Merged

Fix problems reported by eslint #179

merged 10 commits into from
Jan 23, 2024

Conversation

ioay
Copy link
Contributor

@ioay ioay commented Jan 16, 2024

Fix problems reported by eslint but disabled in dapp/.eslintrc.

Closes: #99

@ioay ioay self-assigned this Jan 16, 2024
@@ -63,13 +62,18 @@ const statusStyles = (props: StyleFunctionProps) => {
info: statusInfo,
}

return styleMap[status] || {}
return styleMap[status as string] || {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking comment

The more I look at it the more I realize that this isn't how we should handle the different styles for the Alert component. 🤔 At that time, I used a solution from the threshold dashboard. But now I realize that we should handle it by passing colorScheme. Just as it was done in the Chakra UI.

However, let's leave it as it is but please add a TODO comment here or create a new issue that we should update this and start using a colorScheme instead of status props.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 27 to 31
const handleClick = () => {
requestAccount().catch((error) => {
throw error
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We duplicate this logic several times. Could we prepare a wrapper for these functions with a comment why we need this? Something very general to help us work with it.

function wrapAsyncFunction(func: Promise<void>) {
  return () => {
    func.catch((error) => {
      throw error
    })
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this is a good idea. But I would also consider disabling this rule,not sure about the consequnces, but it doesn't seem to be a very common pattern in React 🤔.

For example, if you don't mind that passing a () => Promise to a () => void parameter or JSX attribute can lead to a floating unhandled Promise:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's add this wrapper instead of disabling this rule.

Copy link
Contributor

@kkosiorowska kkosiorowska Jan 23, 2024

Choose a reason for hiding this comment

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

@r-czajkowski To be honest, in the first turn, I felt that we should turn off this rule. I haven't seen such a pattern either. But then I found this issue. And I started to wonder if we shouldn't adapt our project to the new rule after all. It is still easy to do it at this phase.

But I also have some doubts about the consequences. Therefore, I have mixed feelings.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can leave the wrapper for now and revisit if it becomes really pain.

@r-czajkowski r-czajkowski merged commit 77c911f into main Jan 23, 2024
11 checks passed
@r-czajkowski r-czajkowski deleted the eslint_rules_fix branch January 23, 2024 13:53
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.

Upgrade eslint-config in dApp module
3 participants