Rules Hub
Code Ruleset
← 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 ruleP2stack specificStack: react
reacthooksconsistencystyle
Keep a consistent hook declaration order in components
Order hooks consistently by dependencies and local convention; destructuring shape is not a correctness rule.
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)
Inconsistent local ordering can make related hook inputs and results harder to locate.
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)
Notes (EN)
Keep hook calls unconditional and in a readable dependency order, following the existing project convention where it does not obscure data flow.
Exceptions / Tradeoffs (EN)
Do not reorder a hook before a value it needs. Grouping by destructuring shape is a local style preference, not a React requirement.