Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Prefer managed font loading over vendoring generated font bundles
When the existing framework can self-host the required third-party fonts, prefer its supported font loader over committing downloaded variants and maintaining equivalent generated font-face CSS by hand.
Bad example
| 1 | export const fontCss = ` |
| 2 | @font-face { |
| 3 | font-family: "Inter"; |
| 4 | src: url("/fonts/inter-regular.woff2") format("woff2"); |
| 5 | font-weight: 400; |
| 6 | } |
| 7 | `; |
Explanation (EN)
This requires keeping downloaded font files and hand-maintained declarations in source control even when the configured framework loader already owns that work.
Objašnjenje (HR)
Ovaj pristup zahtijeva preuzete font datoteke i ručno održavane deklaracije u Gitu iako konfigurirani framework već ima loader za taj posao.
Good example
| 1 | import { Inter } from 'next/font/google'; |
| 2 |
|
| 3 | export const inter = Inter({ |
| 4 | subsets: ['latin'], |
| 5 | display: 'swap', |
| 6 | }); |
Explanation (EN)
The supported loader supplies self-hosted build assets and font CSS. Apply its className or variable in the appropriate application entry and verify existing consumers still select the intended family.
Objašnjenje (HR)
Podržani loader priprema font datoteke i CSS za posluživanje iz aplikacije. Primijeni njegov className ili variable na odgovarajućem ulazu i provjeri biraju li postojeći potrošači pravu obitelj fonta.
Notes (EN)
Apply before adding a collection of downloaded remote-font binaries and generated declarations to a framework application. Verify loader support for the installed framework, router entry, required variants and existing CSS consumers. Keep generated build assets out of source control when reproducible through the established pipeline. Choose preloads based on actual use rather than preloading every available variant.
Bilješke (HR)
Primijeni prije dodavanja skupa preuzetih font datoteka i generiranih deklaracija u framework aplikaciju. Provjeri podršku instaliranog frameworka, ulaz routera, potrebne varijante i postojeće CSS potrošače. Generirane build datoteke ostavi izvan Gita kada ih postojeći proces pouzdano stvara. Preload biraj prema stvarnoj uporabi, bez učitavanja svih dostupnih varijanti unaprijed.
Exceptions / Tradeoffs (EN)
Custom licensed fonts, unavailable variants, reproducible offline builds or an established local asset pipeline may justify versioned source font files. Local font loading is supported too. Do not remove needed font files solely because they are binary, assume every font has a variable version, or require a router migration without verifying that it is necessary.
Iznimke / Tradeoffi (HR)
Vlastiti licencirani fontovi, nedostupne varijante, ponovljivi offline buildovi ili postojeći lokalni proces mogu opravdati verzionirane izvorne fontove. Podržano je i učitavanje lokalnih fontova. Ne uklanjaj potrebne datoteke samo zato što su binarne, ne pretpostavljaj da svaki font ima varijabilnu verziju i ne zahtijevaj migraciju routera bez provjere.