Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Await async calls; don't leave floating promises
Await promise-returning calls (including async test helpers) instead of firing and forgetting them.
Bad example
| 1 | test('renders', async () => { |
| 2 | page.render(<FollowButton personId={1} />); // returns a promise, not awaited |
| 3 | await expect.element(page.getByRole('button')).toBeVisible(); |
| 4 | }); |
Explanation (EN)
An unobserved async setup can race assertions and lose failures.
Objašnjenje (HR)
Neopažena asinkrona priprema može se utrkivati s provjerama i izgubiti pogreške.
Good example
| 1 | test('renders', async () => { |
| 2 | await page.render(<FollowButton personId={1} />); |
| 3 | await expect.element(page.getByRole('button')).toBeVisible(); |
| 4 | }); |
Explanation (EN)
Awaiting connects setup completion and rejection to the test; subsequent UI updates may still need retrying assertions.
Objašnjenje (HR)
Await povezuje završetak i pogrešku pripreme s testom. Naknadne promjene UI-ja i dalje mogu zahtijevati provjere s ponavljanjem.
Notes (EN)
Ensure every promise has an owner that awaits, returns or deliberately observes its rejection; await async test setup before dependent assertions.
Bilješke (HR)
Svaki promise mora imati vlasnika koji ga čeka, vraća ili namjerno obrađuje njegovo odbijanje. Asinkronu pripremu testa pričekaj prije ovisnih provjera.
Exceptions / Tradeoffs (EN)
Detached best-effort work may be valid with explicit failure handling and adequate runtime lifetime. void alone silences some lint rules but does not handle rejection.