Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Parse boolean environment variables explicitly, never rely on truthiness
Environment variables are strings, so the literal "false" is truthy; compare against the expected string or transform to a real boolean before using it in conditions.
Bad example
| 1 | // FEATURE_FLAG="false" is a non-empty string => truthy => feature ON |
| 2 | if (process.env.FEATURE_FLAG) { |
| 3 | enableFeature(); |
| 4 | } |
Explanation (EN)
The nonempty string false is truthy, so Boolean coercion can enable a disabled feature.
Objašnjenje (HR)
Good example
| 1 | // Compare against the string, or transform once at the boundary |
| 2 | const featureEnabled = process.env.FEATURE_FLAG === 'true'; |
| 3 | if (featureEnabled) { |
| 4 | enableFeature(); |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Parse environment flags once at the configuration boundary using the accepted spelling, missing-value default and invalid-value policy.
Exceptions / Tradeoffs (EN)
Support alternative spellings only when the configuration contract specifies them; do not silently map a malformed required value to false.