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
data-processingsimplicityperformance
Deduplicate a collection before mapping, not after
Remove duplicates on the raw list before transforming it; deduping post-map often forces you to carry extra fields just to identify duplicates.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const mapped = webcasts.map((w) => w.asPresentation()); |
| 2 | return this.removeDuplicates(mapped); // needs 'published' to dedupe |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const unique = this.removeDuplicates(webcasts); |
| 2 | return unique.map((w) => w.asPresentation()); |
Explanation (EN)
Objašnjenje (HR)