Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Document new required tooling and fail the build loudly if it's missing
New build-time tools/deps must be documented to install, and the build should error descriptively rather than fail silently when absent.
Bad example
| 1 | // build.js relies on a globally installed binary |
| 2 | import { execSync } from 'node:child_process'; |
| 3 |
|
| 4 | // if `mytool` isn't installed, this throws a cryptic ENOENT |
| 5 | // and nothing in the docs tells contributors to install it |
| 6 | execSync('mytool optimize ./assets'); |
Explanation (EN)
Introducing an undocumented required tool means contributors hit an opaque failure with no guidance on what to install or why the build broke.
Objašnjenje (HR)
Uvođenje nedokumentiranog obaveznog alata znači da se suradnici sudare s nejasnim kvarom bez upute što instalirati ili zašto je build pukao.
Good example
| 1 | import { execSync } from 'node:child_process'; |
| 2 |
|
| 3 | try { |
| 4 | execSync('mytool --version', { stdio: 'ignore' }); |
| 5 | } catch { |
| 6 | throw new Error( |
| 7 | 'mytool is required for the build. Install it with `npm i -g mytool`. See README > Setup.' |
| 8 | ); |
| 9 | } |
| 10 | execSync('mytool optimize ./assets'); |
Explanation (EN)
Probe for the tool up front and throw a clear, actionable error pointing to install instructions, and document the requirement in the README so onboarding is smooth.
Objašnjenje (HR)
Provjeri prisutnost alata na početku i baci jasnu, djelotvornu grešku koja upućuje na upute za instalaciju, te dokumentiraj zahtjev u README-u kako bi onboarding bio gladak.