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: typescript
typescriptreturn-typevoidcleanup
Do not return null from functions typed to return void
When a function's declared return type is void, drop the explicit `return null` since it contradicts the signature.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | const handleSubmit = async (data): Promise<void> => { |
| 2 | await save(data); |
| 3 | return null; |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const handleSubmit = async (data): Promise<void> => { |
| 2 | await save(data); |
| 3 | }; |
Explanation (EN)
Objašnjenje (HR)