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

New rule no-sync-act: discourages sync usage of act #915

Open
Janpot opened this issue Jul 18, 2024 · 1 comment
Open

New rule no-sync-act: discourages sync usage of act #915

Janpot opened this issue Jul 18, 2024 · 1 comment
Labels
new rule New rule to be included in the plugin

Comments

@Janpot
Copy link

Janpot commented Jul 18, 2024

Name for new rule

no-sync-act

Description of the new rule

As per https://react.dev/reference/react/act#await-act-async-actfn
sync usage of act is discouraged:

We recommend using act with await and an async function. Although the sync version works in many cases, it doesn’t work in all cases and due to the way React schedules updates internally, it’s difficult to predict when you can use the sync version.

We will deprecate and remove the sync version in the future.

Testing Library feature

act

Testing Library framework(s)

React

What category of rule is this?

Warns about a potential error

Optional: other category of rule

No response

Code examples

The new rule would fail on

act(() => {
await act(() => {
act(async () => {

and pass on

await act(async () => {

Anything else?

No response

Do you want to submit a pull request to make the new rule?

No

@Janpot Janpot added new rule New rule to be included in the plugin triage Pending to be triaged by a maintainer labels Jul 18, 2024
@Belco90
Copy link
Member

Belco90 commented Jul 18, 2024

@Janpot thanks for reporting! TIL, I didn't know about such recommendation.

I would either name the rule await-async-act (for consistency with the other async-related rules), or update await-async-utils to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule New rule to be included in the plugin
Projects
None yet
Development

No branches or pull requests

2 participants