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: typescript
separation-of-concernsutilscomponentsstructure
Put reusable content transforms in a shared util, not in components
Place HTML/data transformation logic in the shared utility/processing layer rather than inline in a component.
PR: hegnar-web · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | function Body({ html }) { |
| 2 | const processed = stripBlockquotes(html); // transform inline in component |
| 3 | return <div dangerouslySetInnerHTML={{ __html: processed }} />; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | // drp-utils.ts handles the transform |
| 2 | function Body({ html }) { |
| 3 | return <div dangerouslySetInnerHTML={{ __html: html }} />; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)