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
testingunit-testsutilities
Add unit tests for pure utility functions
Pure, deterministic helper functions are good candidates for unit tests; add coverage for them.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | // FormValidation.ts has removeHtml/maxLength but no tests |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | describe('FormValidator.maxLength', () => { |
| 2 | it('rejects strings over the limit', () => { |
| 3 | expect(FormValidator.maxLength(5)('toolong')).not.toBe(true); |
| 4 | }); |
| 5 | }); |
Explanation (EN)
Objašnjenje (HR)