The int() helper is the part people tend to skip. parseInt on its own silently accepts a typo like "30o0" as 30, so a strict numeric check (Number() plus Number.isInteger, or a regex) is what actually catches it at startup. One small extension of the same rule: a booleans helper that only accepts "true" or "false", since "0" and "no" are both truthy strings in JS and will happily turn a feature flag on. Object.freeze on the export is a nice touch too, it stops someone patching config at runtime in a test and leaking it into the next one.
StackShortlist
Proof Over Promises.
The int() helper is the part people tend to skip. parseInt on its own silently accepts a typo like "30o0" as 30, so a strict numeric check (Number() plus Number.isInteger, or a regex) is what actually catches it at startup. One small extension of the same rule: a booleans helper that only accepts "true" or "false", since "0" and "no" are both truthy strings in JS and will happily turn a feature flag on. Object.freeze on the export is a nice touch too, it stops someone patching config at runtime in a test and leaking it into the next one.