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 ruleP2stack specificStack: Vite / Rollup
vitepluginsbuildidiomatic
Use the plugin's apply predicate instead of a separate enabled flag
For Vite/Rollup plugins, decide whether to run inside the `apply` function from env/command rather than gating each hook on a hand-rolled `enabled` boolean.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | const enabled = process.env.TRACE_ANCESTORS === 'true'; |
| 2 | return { name: 'x', apply: 'build', generateBundle() { if (!enabled) return; /* ... */ } }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | return { |
| 2 | name: 'x', |
| 3 | apply(_config, { command }) { |
| 4 | return process.env.TRACE_ANCESTORS === 'true' && command === 'build'; |
| 5 | }, |
| 6 | generateBundle() { /* ... */ }, |
| 7 | }; |
Explanation (EN)
Objašnjenje (HR)