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
typescriptreactevent-handlerstypes
Annotate event handler parameter and return types
Give event handlers explicit event types and a void return annotation for clarity and safety.
PR: hegnar-components · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetsx
| 1 | const handleChange = (event) => { setValue(event.target.value); }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetsx
| 1 | const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>): void => { |
| 2 | setValue(event.target.value); |
| 3 | }; |
Explanation (EN)
Objašnjenje (HR)