Skip to content

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

Open
@Janpot

Description

@Janpot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    new ruleNew rule to be included in the plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions