Closed kevinansfield closed 3 years ago
Interesting, are there not memory benefits from using const over let? I assumed rather than know.
Perhaps a rule to turn on only in the Ember context - I have been using const everywhere π³
Not that I'm aware of but definitely interested to hear if there are any! π€ JavaScript const
only denotes an immutable binding rather than an immutable value so I think any benefits would come from the compiler being more free to inline literal values without deep introspection. In Ember that was never an issue anyway because everything was transpiled back to var
for browser support.
Regarding let
vs const
use, this article outlined many of the reasons I went with the ember-suave rule in the past https://madhatted.com/2016/1/25/let-it-be (the "constantly const" section has the arguments against using const everywhere)
I prefer constantly const.
const
means constant reference and not constant value (cannot reassign a reference).const
is not really immutable, because you can still reassign values of an object - that's why defining them as purely constants is IMO wrong/weird (you would need to freeze them too)Just some references for constantly const:
@kirrg001 this is only for the Ember ruleset. Ember itself and most of the community uses the no-const-outside-module-scope rule, Ghost-Admin already uses this rule throughout too.
@kevinansfield Yeah i know π.
Wouldn't it be nice to use one approach for Admin+Server (and npm libraries we maintain)? π€There are different opinions and philosophies, but somehow i feel like it would be nice to agree on one direction - if that is even possible π
e.g. imagine we want to create a Ghost Coding Style Guide.
Closing for now. We can open a separate issue if there's a renewed desire to force a particular style in ember code
In Ghost-Admin we used to have this
no-const-outside-module-scope
rule. It would be nice to bring this back to keep our let vs const usage consistent.Rule docs: https://github.com/DockYard/eslint-plugin-ember-suave/blob/master/docs/rules/no-const-outside-module-scope.md