unitaryfund/metriq-api

Prefer `const` over `let` where appropriate

Closed this issue · 1 comments

I'm not sure if there any efficiency gain in doing this, but there is at least some level of clarity gain from defining variables that should be constant with the const keyword over the let keyword.

One such example would be the userSchema variable in:

let userSchema = mongoose.Schema({

This might be overly general, and perhaps, something we'd want to (somehow) bake into some CI/CD thing (if that's even possible to check, my guess is probably not though).

Good call. const prevents the reassignment of the named object, (but not the "mutation", per se). Wherever we will not reassign, let's use const, and let's err toward the side of using it always and backing off it if reassignment is really necessary.