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).
Don't add unused test-only attributes to production markup
Only add data-testid/ids that have a confirmed consumer; remove speculative test hooks.
Bad example
| 1 | myFeed: { |
| 2 | id: 'myFeed', |
| 3 | name: 'MyFeed', |
| 4 | url: 'profile/feed', |
| 5 | testid: 'popup-myfeed', // nothing reads this testid |
| 6 | }, |
Explanation (EN)
Adding a testid that no test or tool consumes is dead configuration. It implies a contract that doesn't exist and invites copy-paste of the same unused hook elsewhere.
Objašnjenje (HR)
Dodavanje testid-a koji nijedan test ni alat ne koristi je mrtva konfiguracija. Sugerira ugovor koji ne postoji i potice kopiranje istog neiskoristenog atributa drugdje.
Good example
| 1 | myFeed: { |
| 2 | id: 'myFeed', |
| 3 | name: 'MyFeed', |
| 4 | url: 'profile/feed', |
| 5 | }, |
| 6 | // add `testid` only once a test or external tool actually selects this item |
Explanation (EN)
Omitting the hook until something consumes it keeps the config honest; you add the attribute alongside the test or tool that needs it.
Objašnjenje (HR)
Izostavljanje atributa dok ga nesto ne koristi cuva konfiguraciju postenom; atribut dodajes zajedno s testom ili alatom koji ga treba.
Exceptions / Tradeoffs (EN)
Keep the attribute when there is a real external consumer (analytics, e2e suite, embedding host) that selects on it; document that consumer if it isn't obvious from the codebase.
Iznimke / Tradeoffi (HR)
Zadrzi atribut kada postoji stvarni vanjski potrosac (analitika, e2e paket, host koji ugradjuje) koji ga koristi za odabir; dokumentiraj tog potrosaca ako nije ocit iz baze koda.