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).
Omit config options already implied by other options
Drop explicit options that an API already defaults on when a related option is set; redundant config adds noise and can drift from the docs.
Bad example
| 1 | observer.observe(node, { |
| 2 | attributes: true, // redundant: implied by attributeFilter/attributeOldValue |
| 3 | attributeFilter: ['style'], |
| 4 | attributeOldValue: true, |
| 5 | }); |
Explanation (EN)
attributes: true is the default whenever attributeFilter or attributeOldValue is set, so specifying it explicitly is redundant and gives a false impression that it is doing something.
Objašnjenje (HR)
attributes: true je zadano kad god je postavljen attributeFilter ili attributeOldValue, pa je njegovo eksplicitno navođenje suvišno i stvara dojam da nešto radi.
Good example
| 1 | observer.observe(node, { |
| 2 | attributeFilter: ['style'], |
| 3 | attributeOldValue: true, |
| 4 | }); |
Explanation (EN)
Setting only the options that change behavior keeps the config minimal and makes the intent clear; rely on documented defaults instead of restating them.
Objašnjenje (HR)
Postavljanje samo onih opcija koje mijenjaju ponašanje drži konfiguraciju minimalnom i čini namjeru jasnom; oslanjaj se na dokumentirane zadane vrijednosti umjesto da ih ponavljaš.
Exceptions / Tradeoffs (EN)
Keep an option explicit if it materially aids readability for a non-obvious default, but verify the default first.
Iznimke / Tradeoffi (HR)
Zadrži opciju eksplicitnom ako bitno pomaže čitljivosti za neočiti default, ali prvo provjeri koji je default.