Once upon a time
you can jump over that section it's merely an introduction of what has led me to adopt standardjs
As a dev coming from the world of Java to JavaScript some 6-7 years ago I was kind of lost by the "liberty" of coding that JS offered. Then again with that was a good deal of good and bad things and I quickly ended up using JSLint to help me navigate through this world and to teach me what was right and what was wrong.
It wasn't enough though. I quickly moved on to JSHint, later to JSCS and to ESLint with each time a new set of recommendations and some change to my coding style and habits. It is worse noting that most of these tools were actually a great help to polish my skills little by little each of them providing finner and finner warnings.
What's the link with Standard.js?
That I've seen a lot of different style of JavaScript and I am use to the discomfort of changing your coding habits from one style to the other depending on which project one works on.
Recently, I've been working on 3 different freelance projects all using different configuration of ESLint... Why are we doing that to ourselves when there is a single style without config (a.k.a divergences) readily usable!
By using one single config for all the JS code out there no more time spent configuring an IDE, no more time "configuring" our brain to read and write the code according to this or that style.
The ultimate rules!
As said previously, standardjs makes opinionated yet fully justified choice regarding the coding style. You may not agree with all of them but it doesn't matter! (I disagree with many exceptions of the French language but I still accept them :x).
Here are the "main" ones:
- no unused variable: it always drive me nuts when I review some code to see them... I become a game of guessing, what that supposed to be used somewhere? Should I delete the whole stuff?
- plenty of aesthetic decisions that helps make the code clearer
- plenty of totally sound decisions about more or less obscure things that are allowed by JavaScript but that should never have been! (like reassigning const, calling constructor without parenthesis when there is no parameters, ...)
Globally there is nothing out of the ordinary in there. Most of these rules are already applied by most of the good coding styles out there. The most important change however is yet to be introduced.
Getting ride of the semicolon
Perhaps the most important change when switching to standardjs is to stop putting ;
all around the place. We don't need it! If you doubt it, go read this and that.
When I read it for the first time I paused for a second and asked myself why I had always put some? 'cause I was coming from Java and Java forced me to... Right but other than that? No idea.
Moreover, how many lines of code do we type everyday? sparing that one key press if helping greatly to reduce the stress and repetitive strain injury risks to our right ring finger. Ain't it great?
Just a few more words
A few notes to conclude this totally biased post:
- standard is totally compatible with ES6!
- there is an effort toward porting standard to the TypeScript world
- you don't need to agree with me but please give standard a try :D
Top comments (0)