-
-
Couldn't load subscription status.
- Fork 33.6k
Description
This conversation started here: #3036 (comment).
It seems there's an implicit rule of preferring const over var for variables that hold values that never change, which makes sense. It's been mentioned in #1243, and seems to be enforced during code reviews.
However, it's not currently caught by our eslint setup. To paraphrase #3036 (comment), I'm not a big fan of having implicit coding style rules. It becomes frustrating for maintainers to enforce them every time, and for contributors because they don't have any tool to check that their code complies to the guidelines.
However, using the prefer-const rule does not apply to function-scoped variable declarations, so we would need to use the no-var eslint rule too and use let instead of var, which I assume would require a significant amount of work.
#1243 mentions that let's V8's implementation had performance at some point.
My question thus is: is moving from var to let and enforcing const with eslint worth investigating now?
/cc @nodejs/tsc