Why should you validate with JSLint or JSHint


In computer programming, a lint is a piece of software that scans the code and looks for problems. When languages like C and C++ were young, lots of issues where ignored by their primitive compilers. It made sense to use a lint to find bugs statically.

JavaScript is a very young (for its age) language, intended for small works, but, today, used for big projects. Without a proper syntax, set of rules or a compiler: you can write big applications in JavaScript, but you can’t maintain them. To solve this issue some smart programmers wrote lints for JavaScript. These tools are able to enforce good practices and to find most common bugs and dangerous patterns by scanning the code statically. The most popular among them are: JSHint and JSLint.

The problems found by these tools are not necessarily  syntax errors, although  often they are. They also look at some style conventions as well as structural problems. These tools does not prove that your program is correct. They just provide another set of eyes to help spot problems.

Yes I know, sometimes the warnings these tools produce may hurt your feelings but on the long run you will be more productive and your code will be maintainable. With these tools you will be able to avoid plain syntax errors as well as run-time caveats that many of us stumble onto way too often..

You can read more about it in the JSLint documentation, but briefly put, it’s a great tool for verifying the syntax as well as best practices in your JavaScript code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s