loading...

Discussion on: Here are Top 5 Best Practices for JavaScript you MUST ALWAYS FOLLOW

Collapse
metalmikester profile image
Michel Renaud

Using braces even for only one statement was in our guidelines on a previous project. A new guy "defied" it, saying it was nonsense. Then it bit him in the a** a couple of times. Now he uses them everywhere. Not just in JavaScript, but also C#.

If they're missing I'll add them. If someone removes them. Hmmm... OK let's stop here for alibi purposes. :D

Collapse
adam_cyclones profile image
Adam Crockett

In our project we have a linter which won't let you commit unless you fix your code. It's a sure fire way of getting everyone to behave the same way, because that is all it's really about.

Thread Thread
metalmikester profile image
Michel Renaud

Can you tell me what tools you are using for linting? That would be useful to us since we have been bringing in new people on board (I've been on this project less than three months, some less and new one coming in soon), all with various levels of experience.

Thread Thread
adam_cyclones profile image
Adam Crockett

Sure, let's see, first sass-lint, that fails in CDCI, then we have es-lint with the Airbnb preset (it's a good one) we extended it and turned off a couple of js features that we don't transpile for per reasons. Lastly we have a strange stack with an equally odd templating language which is domain specific, so I adapted htmlhint with some custom rules to lint that (proud). Not all of the linting is switched on to fail CDCI yet and only JavaScript has a commit hook tool. The hook tool is quite new so I don't know the name but I will find out and get back to you.

Thread Thread
metalmikester profile image
Michel Renaud

Cool stuff, I'll look into that. Thanks! :)

Collapse
adam_cyclones profile image
Adam Crockett

Oh futher reply, Michael it's not about brace or not to brace that I respect about your comment, it's that you have a good strong opinion. That is the most important part. I always say, it can be consistently good or consistently bad but atleast it's consistently changeable.

Whatever we decide is punishable by death, stick to those guns and lint, lint, lint.

Thread Thread
metalmikester profile image
Michel Renaud

Ultimately it's 31+ years of experience (and I still have SO much to learn; things change so fast in this field - .NET Core 3.0 just landed and I'm all excited), and a lot of that experience was going through pains of even little things like that that often cost us hours or days and could have been avoided with better practices, etc.

Many of my coworkers have come to learn that if I'm really insisting on something and speaking strongly in favour or against something, there's a good reason (which they may or may not understand yet, depending on their level of experience). I'll sometimes fill them in on horror stories while having a cold beer at a nearby restaurant. :)