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 ruleP2stack specificStack: react
namingreadabilityreactevent-handlers
Name handlers and variables after intent, not the triggering mechanism
Name a function for the behaviour it performs (e.g. submit, toggle, scroll-to) rather than the DOM event that triggers it, but keep onClick when it truly is just a click handler in that component.
PR: hegnar-forum-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | <button onClick={onVoteClick}>Vote</button> |
| 2 | // 'displayReply' / 'replyGroup' when it's just a reply |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | <button onClick={submitVote}>Vote</button> |
| 2 | // names express what happens, e.g. scrollToReply, submitVote |
Explanation (EN)
Objašnjenje (HR)