Replace useConst with useLet #5873
Replies: 2 comments 12 replies
-
|
If there is enough interest, we could consider adding a new rule |
Beta Was this translation helpful? Give feedback.
-
|
I do have to say that the linked concern for why
The premise here sounds good. Writing good code is very much about communicating your intention. If you can convey not just what the code does, but also what it is intended to do, that's one of the most important qualities of writing maintainable code. So far we're aligned.
On the surface, this reads as if it makes sense, but it doesn't. And at first I couldn't quite put my finger onto why it doesn't. IMO, the problem is in the communication part. Let's assume for a moment that the author is correct, that the developer can communicate intention through the use of let len = array.length;
for (let i = 0; i < len; i++) {
// do something with `array[i]`.
}Here we have two declared variables, Intention is communicated with comments, and to some extent with well-chosen variable and function names. Using But as @Conaclos said, if enough people feel a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Rule:
https://next.biomejs.dev/linter/rules/use-const/
Concern:
https://dev.to/axtk/prefer-let-over-const-not-the-other-way-around-4jin
Suggestion:
It would be nice to enable an opposite rule preferring
letoverconstby default.There's a related Eslint plugin that looks like a good reference:
https://www.npmjs.com/package/eslint-plugin-prefer-let
Beta Was this translation helpful? Give feedback.
All reactions