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).
backend ruleP1universalStack: TypeScript
single-responsibilityside-effectsclean-code
Keep functions to a single responsibility
A function named for a query/check (e.g. isRegionOnly) should not also perform an unrelated mutation like a DB update; split the concerns.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | async isRegionOnly(id: number): Promise<boolean> { |
| 2 | await this.repo.update({ flag: true }, { where: { id } }); // unrelated mutation |
| 3 | return checkRegionOnly(id); |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | async isRegionOnly(id: number): Promise<boolean> { |
| 2 | return checkRegionOnly(id); |
| 3 | } |
| 4 | // caller performs the update separately when needed |
Explanation (EN)
Objašnjenje (HR)