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).
Use the Codebase's Established Alias When Importing a Shared Wrapper
If the rest of the codebase imports a fetch wrapper under a conventional alias, follow that convention in new code too.
Bad example
| 1 | import fetchRelative from 'utils/static/fetchRelative'; |
| 2 |
|
| 3 | export const getUsers = async () => { |
| 4 | const response = await fetchRelative('/api/users'); |
| 5 | return response.json(); |
| 6 | }; |
Explanation (EN)
Imports the shared fetch wrapper under its literal export name, which reads differently from every other call site in the codebase that aliases it to `fetch`, adding needless inconsistency.
Objašnjenje (HR)
Importa zajednički fetch wrapper pod njegovim doslovnim exportanim imenom, što se čita drugačije nego na svim ostalim mjestima u kodu gdje je aliasiran u `fetch`, dodajući nepotrebnu nekonzistentnost.
Good example
| 1 | import fetch from 'utils/static/fetchRelative'; |
| 2 |
|
| 3 | export const getUsers = async () => { |
| 4 | const response = await fetch('/api/users'); |
| 5 | return response.json(); |
| 6 | }; |
Explanation (EN)
Aliases the import to `fetch` to match the convention used throughout the rest of the codebase, so call sites read the same everywhere and new contributors don't need to learn a second name for the same thing.
Objašnjenje (HR)
Aliasira import u `fetch` kako bi odgovarao konvenciji koja se koristi kroz ostatak koda, tako da pozivi svugdje izgledaju isto i novi suradnici ne moraju učiti drugo ime za istu stvar.