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 ruleP1stack specificStack: node
build-toolspluginsconfigurationrobustness
In build plugins, use the resolved config root, not process.cwd()
Build tooling/plugins should read the bundler's resolved root rather than process.cwd(), so they stay correct when the project root differs or the command is run from a subdirectory.
PR: hegnar-zephr-components · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | function myPlugin() { |
| 2 | return { |
| 3 | name: 'my-plugin', |
| 4 | buildStart() { |
| 5 | runGit({ cwd: process.cwd() }); |
| 6 | }, |
| 7 | }; |
| 8 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | function myPlugin() { |
| 2 | let root; |
| 3 | return { |
| 4 | name: 'my-plugin', |
| 5 | configResolved(config) { root = config.root; }, |
| 6 | buildStart() { runGit({ cwd: root }); }, |
| 7 | }; |
| 8 | } |
Explanation (EN)
Objašnjenje (HR)