Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP2universalStack: typescript
clean-codereadabilityshorthand
Use object property shorthand when names match
Write `{ x }` instead of `{ x: x }` when the variable name equals the property name.
PR: startsiden/hegnar-quartr-ws#5Created: Jun 17, 2026
Bad example
Old codets
| 1 | const response: Result = { |
| 2 | pastAudio: pastAudio, |
| 3 | liveAudio: liveAudio, |
| 4 | futureAudio: futureAudio, |
| 5 | }; |
Explanation (EN)
Repeating each name on both sides is redundant and makes the object harder to scan.
Objašnjenje (HR)
Ponavljanje svakog imena s obje strane je suvišno i otežava pregled objekta.
Good example
New codets
| 1 | const response: Result = { |
| 2 | pastAudio, |
| 3 | liveAudio, |
| 4 | futureAudio, |
| 5 | }; |
Explanation (EN)
Shorthand conveys the same mapping with less to read and no chance of a copy-paste mismatch between key and value.
Objašnjenje (HR)
Skraćeni zapis prenosi isto mapiranje uz manje teksta i bez šanse za copy-paste neslaganje ključa i vrijednosti.