TryGhost / eslint-plugin-ghost

Shared eslint configurations
MIT License
6 stars 5 forks source link

Ember `no-const-outside-module-scope` rule #6

Closed kevinansfield closed 3 years ago

kevinansfield commented 6 years ago

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

ErisDS commented 6 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 😳

kevinansfield commented 6 years ago

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)

kirrg001 commented 6 years ago

I prefer constantly const.

Just some references for constantly const:

kevinansfield commented 6 years ago

@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.

kirrg001 commented 6 years ago

@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.

kevinansfield commented 3 years ago

Closing for now. We can open a separate issue if there's a renewed desire to force a particular style in ember code