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).
frontend ruleP2universalStack: React
reactdata-mappingcorrectnessclean-code
Carry related data through the mapper instead of re-indexing the raw array
When mapped items need a property from the raw item, attach it during mapping rather than re-looking up the original by index, which breaks if mapping or order changes.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | {mappedData.map((item, index) => { |
| 2 | const rawItem = data[index]; // fragile index coupling |
| 3 | return hasNickname(rawItem) ? <Avatar /> : <img src={item.logo} />; |
| 4 | })} |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | {mappedData.map(({ mappedItem, rawItem }) => |
| 2 | hasNickname(rawItem) ? <Avatar /> : <img src={mappedItem.logo} /> |
| 3 | )} |
Explanation (EN)
Objašnjenje (HR)