Codementor Events

How and why I build with JSLint

Published Jul 18, 2018Last updated Jul 25, 2018

About me

I'm CTO of The Imaginary Jobs Program. I'm also a Full stack Q&A Lead at Thinkful.

The problem I wanted to solve

I use this on all my projects now. It helps me stay up to date with the latest and best in Code Quality and Defensive Programming. If I am using a style of programming that works against me and makes it easier for me to make a mistake, JSLint tells me right away which line and column the problem is on. It even helps with broad stroke capability security problems by preventing the use of the "this" operator.

What is Why I JSLint?

I have used it to build a Static Site Generator, Frontend Widgets, servers and cli tools.

Tech stack

The repo is JSLint which is found on Douglas Crockford's Github page.

I use bash command line scripts instead of NPM to scaffold it.
This can include the use of wget, diff and nodejs.

The process of building Why I JSLint

Setting it up is simple. Most of it is simple wiring. Writing the code and running it presents new problems and they are solved problem by problem.

Challenges I faced

The hardest part on a team is when someone writes code that JSLint doesn't like, but they may not think it is so bad. In this case often someone who is more familiar with JSLint may have to explain to them why it is so important. If they believe that they are right and JSLint is wrong, they can also join the JSLint community on G+. In the community Douglas Crockford can be directly asked or challenged as to that error. If the user has made a good enough point, JSLint itself will be changed.

For instance, JSLint does not allow use of the "this" operator or the ++ operator. In the case of "this" a whole class of security vulnerabilities can be avoided by not using it. In the case of ++, many high frequency confusions can be avoided that are hard to spot. Many people are against it, but it is really just good defensive programming.

Key learnings

On a team when you introduce stricter styles, people may be surprised by what you are preventing. If you take the time to understand why, others will get behind it with full force.

Tips and advice

I suggest you join the JSLint Google Group. I also suggest that you take your time in bringing your team on to using JSLint and not impose it on them.

Final thoughts and next steps

I use JSLint in everything I make with JavaScript. It has served me well for years and makes me a better programmer. Of course it is no replacement for TDD, but along with TDD it will make your code considerably stronger.

Discover and read more posts from Beaei Pardo
get started
post commentsBe the first to share your opinion
Show more replies