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 ruleP2universalStack: TypeScript
api-designnamingencapsulation
Don't expose an internal constant as a parameter when the method name already implies it
If a method's name fixes the data set (e.g. agendaIrWidgetArticles), don't take the defining id/tag as a caller parameter; keep it internal so callers can't pass a contradictory value.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | repo.agendaIrWidgetArticles(tagId); // caller could pass any tagId |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | // inside repo |
| 2 | private readonly INVESTOR_RELATIONS_TAG_ID = '70635'; |
| 3 | public agendaIrWidgetArticles() { return this.byTagId(this.INVESTOR_RELATIONS_TAG_ID)...; } |
| 4 | // caller |
| 5 | repo.agendaIrWidgetArticles(); |
Explanation (EN)
Objašnjenje (HR)