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: JavaScript/TypeScript, React
namingreadabilitystatehandlers
Name state as a noun and handlers/actions as verbs
A boolean state should read like a description (isDiscardModalOpened), while a function should read like an action (openDiscardModal); mismatched naming misleads readers.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const [openDiscardModal, setOpenDiscardModal] = useState(false); |
| 2 | const nextStep = () => setStep(s => s + 1); // looks like a value, not a fn |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const [isDiscardModalOpened, setIsDiscardModalOpened] = useState(false); |
| 2 | const onNextStep = () => setStep(s => s + 1); |
Explanation (EN)
Objašnjenje (HR)