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
robustnessquery-paramsdefensiveux
Make param-driven UI tolerant of unknown/missing values
When matching against query-param values, fall back gracefully for unknown or missing values (e.g. treat absent from/to as 'all') instead of breaking the UI.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | selected = items.find((i) => i.value === query.dateRange); // breaks on unknown value |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | selected = query.dateRange === item.value || (item.value === 'all' && !query.fromDate && !query.toDate); |
Explanation (EN)
Objašnjenje (HR)