testing-library / testing-library/eslint-plugin-testing-library
New rule `no-sync-act`: discourages sync usage of `act`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 168
- Avg merge
- 15h 44m
- Merged PRs (30d)
- 14
Description
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
actwithawaitand anasyncfunction. 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation files or tests are named. Locate existing act-related rules and their React rule tests, then use the issue's examples to define the warning for synchronous act usage and the accepted awaited async form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100