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 set ARIA attributes to their default value
Omit ARIA attributes whose value matches the ARIA default; they add noise without changing behavior.
Bad example
| 1 | <div role="presentation" aria-atomic="false" className={styles.toggle}> |
| 2 | {children} |
| 3 | </div> |
Explanation (EN)
aria-atomic is already false by default, so spelling it out changes nothing and just adds visual noise. If it was added to make a test pass, the test only asserts the attribute exists, not any real behavior.
Objašnjenje (HR)
aria-atomic je vec po defaultu false, pa njegovo eksplicitno navodjenje ne mijenja nista i samo dodaje vizualni sum. Ako je dodan da prodje neki test, test samo provjerava postojanje atributa, a ne stvarno ponasanje.
Good example
| 1 | <div role="presentation" className={styles.toggle}> |
| 2 | {children} |
| 3 | </div> |
Explanation (EN)
Only set ARIA attributes when you need a value different from the default. This keeps markup meaningful and avoids tests that assert no real behavior.
Objašnjenje (HR)
ARIA atribute postavljaj samo kad ti treba vrijednost razlicita od defaulta. Tako markup ostaje smislen i izbjegavas testove koji ne provjeravaju stvarno ponasanje.
Notes (EN)
Check the ARIA spec / MDN for the default value before adding an attribute. If you genuinely need to assert accessibility behavior, assert the rendered semantics, not the mere presence of a default-valued attribute.
Bilješke (HR)
Prije dodavanja atributa provjeri defaultnu vrijednost u ARIA spec / MDN. Ako stvarno trebas testirati pristupacnost, provjeravaj renderiranu semantiku, a ne puko postojanje atributa s defaultnom vrijednoscu.