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).
fullstack ruleP2stack specificStack: javascript
configvitetypescriptdx
Avoid the function form of config when a static object works
Prefer the plain-object form of a config (e.g. Vite `defineConfig({...})`) over the function form unless you genuinely need the injected args, because the function form makes the type checker flag the whole call instead of the offending field.
PR: hegnar-bellsheep-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | export default defineConfig(({ mode }) => { |
| 2 | const env = loadEnv(mode, process.cwd()); |
| 3 | return { /* a typo here underlines the whole defineConfig call */ }; |
| 4 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const env = loadEnv('production', process.cwd()); |
| 2 | export default defineConfig({ /* field-level type errors are pinpointed */ }); |
Explanation (EN)
Objašnjenje (HR)