Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Keep raw and mapped records paired when conversion can skip entries
Carry each successfully converted payload with its source record; never correlate filtered output with the original array by index.
Bad example
| 1 | const mapped = raw.map(convert).filter(Boolean); raw.forEach((row, i) => index(row, mapped[i])); |
Explanation (EN)
Filtering destroys index correlation.
Objašnjenje (HR)
Filtriranje razdvaja povezane zapise.
Good example
| 1 | const pairs = raw.flatMap(row => { const mapped = convert(row); return mapped ? [{ raw: row, mapped }] : []; }); |
Explanation (EN)
Each payload retains its source identity.
Objašnjenje (HR)
Svaki rezultat zadržava svoj izvor.
Notes (EN)
Applies when a batch skips malformed inputs or filters output before another consumer needs both raw membership and mapped payload.
Bilješke (HR)
Primijeniti pri promjenama cachea, fallbacka i obrade skupova podataka.
Exceptions / Tradeoffs (EN)
Parallel arrays are safe only if every operation provably preserves cardinality and order.
Iznimke / Tradeoffi (HR)
An alias union is only correct when that is the chosen domain contract; precedence-based matching must instead be enforced consistently in queries.