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: JavaScript/TypeScript
apirequestsdata-shaping
Don't send undefined values in request bodies; omit the key
Conditionally include a field in a request body only when it has a value, rather than sending undefined; build the payload from defined values.
PR: vinify-frontend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const body = { name, parentId: selectedLocation.id ?? undefined }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const body = { name, ...(selectedLocation.id && { parentId: selectedLocation.id }) }; |
Explanation (EN)
Objašnjenje (HR)