Join Nostr
2024-12-06 21:57:46 UTC

Lea Verou, PhD on Nostr: The idea behind prefer-const is well intentioned: if you plan to never reassign a ...

The idea behind prefer-const is well intentioned: if you plan to never reassign a variable, make it a constant to declare your intent upfront, reducing cognitive load.

But intent is crucial here. Good code expresses *intent*, not coincidence.

Yet linters try to enforce this rule by looking at the current snapshot of the code and asserting that if a variable currently _happens_ to not be reassigned, it means you MUST formalize this as a restriction so that it can never be reassigned! 🙃