Rules Hub
Coding Rules Library
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)
A floating promise means errors go unhandled and ordering is non-deterministic; the render may not have settled before the next step.
Objašnjenje (HR)
Floating promise znaci da greske ostaju neobradene i redoslijed je nedeterministican; render se mozda nije dovrsio prije sljedeceg koraka.
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 makes timing deterministic and lets the linter (and your error handling) catch rejections.
Objašnjenje (HR)
Cekanje cini redoslijed deterministicnim i omogucuje linteru (i tvojoj obradi gresaka) da uhvati odbijanja.
Notes (EN)
A linter that flags no-floating-promises (e.g. via oxlint/typescript-eslint) catches these automatically.
Bilješke (HR)
Linter koji prijavljuje no-floating-promises (npr. preko oxlint/typescript-eslint) hvata ovo automatski.