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 ruleP2project specificStack: react
reacthooksconsistencystyle
Keep a consistent hook declaration order in components
Order hooks consistently (destructured hooks, then state, then non-destructured hooks, then refs) so components read uniformly.
PR: vinify-frontend · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | const i18n = useTranslations(); // non-destructured first |
| 2 | const [index, setIndex] = useState(0); // state |
| 3 | const { width } = useColumnResize(); // destructured last |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const { width } = useColumnResize(); // destructured hooks |
| 2 | const [index, setIndex] = useState(0); // state |
| 3 | const i18n = useTranslations(); // non-destructured hooks |
Explanation (EN)
Objašnjenje (HR)