Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Model sizing config as numbers, formatting to the string form at the edge
Type pixel dimensions numerically when appropriate; preserve responsive HTML sizes expressions.
Bad example
| 1 | imageSizes?: string; // '32px' |
Explanation (EN)
An unvalidated dimension string can mix units that a pixel-only helper does not support.
Objašnjenje (HR)
Good example
| 1 | interface IconProps { sizePx?: number; } |
| 2 | const dimension = sizePx ?? 32; |
Explanation (EN)
A single pixel-size API can use a number; this does not redefine the full HTML sizes attribute.
Objašnjenje (HR)
Notes (EN)
Use numeric dimensions for an API that actually accepts pixel counts, with unit/range validation at its formatter boundary.
Exceptions / Tradeoffs (EN)
HTML sizes is a responsive source-size expression and may contain media conditions, vw or calc. A number[] cannot represent every valid sizes contract; retain a typed string or structured responsive model when needed.