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: node
architectureseparation-of-concernsdata-layerproviders
Keep filtering logic out of low-level data providers
A data provider should accept the inputs it queries on and return raw results; perform selection/filtering one level up rather than baking it into the provider.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | getEvents() { |
| 2 | return api.fetch().then(events => events.filter(this.activeChannels)); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | getEvents(channelIds: ChannelId[]) { |
| 2 | return api.fetch(channelIds); // filtering decided by the caller |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)