Linting is parenting

Develoger
Develoger
Published in
4 min readMay 22, 2017

--

Let’s face it right from the start. People hate rules. There is something in human nature which simply refuses to obey rules. We see them as limitations and an act of domination. I personally, like many of us programmers, felt the same when back in the day I was introduced to code linting.

People are like wolves, we fight for the leadership role.
People are like ants, we fight for each other and the common goal.

No matter if you see yourself as wolf or ant, you will need rules if you are going to be part of either pack or colony. A pack can easily become a colony in the growing process of our app. So you must take it seriously.

Scalability is a funny word

When engineers think about scalability they think about codebase.
When managers think about scalability they think about engineers.

Parenting

I remember when my mother gave me orders. Most of the time she would end them with Because I say so. That is exactly why many people initially dislike code linting. To obey rules one needs at least to understand the reasons, if not to believe in them.

A good parent can be an alpha leader.
A good parent is an ant queen.

The thing is that kids don’t understand rules since they don’t see the big picture. Additionally, rules tend to change with time. A good parent will adjust expectations while their children grow.

Nothing grows standalone

Plants need sun + water + lots of stuff.
Humans need food for both their body and mind.

A good parent would never set the rules without consulting the children. In the same way, a project lead should always include all team members when linter config is being defined.
Still, above everything else, people must know that…

This is the core reason why linters exist.
Especially in languages such as JavaScript.

Gist link

Remember when Douglas Crockford wrote JavaScript: The Good Parts? He stated that the only way to fix JavaScript is to use its good parts and ignore bad things. Since books are rarely enough, he made JSlint a tool which will force people to follow what he wrote in his bestseller. More than less age of JavaScript code linting began with that. Nowadays ESlint is maybe the best solution when JS linting is the topic. It is fully configurable to whatever code style you and your team prefer. You can follow Crockford’s rules or come up with your own.

Linter is bad

It provides a scenario in which people can follow best practices without really understanding how they benefit from them.
Luckily this statement is somewhat false. Since no matter if one understands linter rules or not, following them would become a habit as time passes.

Linter is good

Those annoying linter errors reduce with time as well. The process itself forces us to become better for the colony, I mean the team.

Diff(erence)

Code linting must be automated. It is part of your responsibility to keep your team aligned. We sure need diversity among our colleagues, but when code base is the topic; unification is the way to go.

Running tests manually is like pulling an automobile with a horse.

The whole point of working with a computer is to let it think about stuff that we humans tend to forget.

All this means is that you should lint your code while you code (most of text editors and IDEs have plugins for this) with a final check on updated files during commit.

Running linter with a pre-commit hook will not slow you down. As a matter of fact it will incrementally make you better. If it is implemented in an appropriate manner it can be quite fast.
Lint only files that are being updated, not the entire project.

Rules are there to be broken by setting new rules.

The whole point of code linting is teamwork. Include your coworkers into a definition of rules and make it transparent that it is an ongoing process. Don’t let your project end up being complicated instead of complex!

If you are reading this it means that you are curious and passionate about JavaScript and Front-End in general. That makes two of us!
Consider joining me on this adventure of discovery by following me here, clicking on that heart, or checking out my twitter account https://twitter.com/develoger

Once I hit 1000 followers on the blog I will share the prizes (public draw) -- 2 yearly subscriptions to https://egghead.io

--

--