Why Use JSHint?
It’s simple, JSHint can save you time and make you a better developer. A lot of developers think that linting tools are a waste of time, since they can already debug their own code, but that’s not the point! It’s not about being able to detect errors in your code, it’s about being able to detect them faster and more efficiently. It’s about improving your development workflow by integrating static analysis in to it.
I’ll be honest, I don’t like JSHint very much.
The main advantage of using JSHint is that your code will be more reliable, understandable and maintainable – the three most important traits of good software development.
JSHint is a great tool for making sure that you write quality code, but it can also be used to enforce coding standards within your development team. You can easily setup JSHint with Grunt to make sure that every developer on your team adheres to the same rules and conventions.
What makes it so special?
It detects errors and potential problems and immediately provides you with warnings.
The warnings are not limited to syntax-related issues, but also include semantic problems. For example, JSHint will warn you if you use an assignment expression in a conditional statement or if you declare or access variables outside their intended scope.
It has an online version where you can test your code. You can also install it as a browser extension for Chrome and Firefox, or as a Node package (for Grunt users).
You run JSLint and immediately see that something isn’t right. There are a ton of errors, many of which seem unrelated to your feature or the code you’ve changed. You ignore them for now, but later when you come back to the project these errors will still be there, staring at you in the face every single time you try to commit new changes. You don’t want to fix these errors because they’re not related to your work, but at the same time it doesn’t feel right committing new code with these errors in place.
JSHint has a lot of options that let you customize it to your own style guide, which makes it the best tool for enforcing your team’s conventions. JSHint can be easily added to projects’ build system or continuous integration environments.
– Unused variables
– Undeclared variables (implied globals)
– Semicolon insertion (ASI)
– Strict mode violations
– Trailing whitespace found (“trailingspaces”)
– Expected an assignment or function call and instead saw an expression (“experession”)