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).
Flag low-confidence derived values in dry-run output
A silently degraded derivation (e.g. an empty split result) should surface a marker in preview tooling.
Bad example
| 1 | const [firstName, ...rest] = name.split(" "); |
| 2 | const lastName = rest.join(" "); // silently "" for a one-word name |
Explanation (EN)
A single-word name produces an empty last name that passes every validation check and simply renders as a blank surname later, with nothing in the tool's output calling attention to the fact that this particular record was split oddly.
Objašnjenje (HR)
Jednorječno ime proizvede prazno prezime koje prođe svaku validaciju i kasnije se jednostavno prikaže kao prazno prezime, dok ništa u izlazu alata ne skreće pažnju da je baš taj zapis neobično podijeljen.
Good example
| 1 | const [firstName, ...rest] = name.split(" "); |
| 2 | const lastName = rest.join(" "); |
| 3 | if (!lastName) { |
| 4 | console.log(`note: "${name}" has no last name — check this split before applying`); |
| 5 | } |
Explanation (EN)
Print an explicit note whenever a heuristic derivation degrades to an edge case, so the person approving the dry-run output can catch it rather than discovering it after the real run has already applied it.
Objašnjenje (HR)
Ispiši eksplicitnu napomenu kad god heuristička izvedba padne na rubni slučaj, tako da osoba koja odobrava dry-run izlaz to može uočiti umjesto da to otkrije tek nakon što je stvarno pokretanje već primijenilo promjenu.