Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Encode Sets explicitly at JSON-only boundaries
Convert Set to an agreed JSON representation at JSON-only boundaries; do not assume React Server Function serialization has the same limitations.
Bad example
| 1 | const payload = JSON.stringify({ fields: new Set(["title"]) }); |
Explanation (EN)
Plain JSON encodes the Set object without its entries.
Objašnjenje (HR)
Good example
| 1 | const fields = new Set(["title"]); |
| 2 | const payload = JSON.stringify({ fields: [...fields] }); |
Explanation (EN)
The JSON schema explicitly represents membership as an array.
Objašnjenje (HR)
Notes (EN)
Identify the actual wire serializer before converting Set values. Plain JSON.stringify does not encode Set entries, while React Server Functions support Sets containing serializable values.
Exceptions / Tradeoffs (EN)
Keep Set where both ends support it. A custom JSON replacer and matching decoder can also preserve it.