One feature that I have been using a lot lately is the integration with JSHint.
What is JSHint?
How does it work?
The output from JSHint will be listed as Messages in the Error List (If the Error List is not visible, you can show it by selecting View –> Error List from the main menu).
In this example, we can see that I have a method that is never used and a missing semi-colon on line 5.
JSHint has a long list of rules that it checks against. Try not to take it personally if your Error List contains a large number of JSHint. After all, JSHint is just trying to help.
You might not agree with some of the things that JSHint points out in your code, and that’s okay. Your style is your style. You have the option to change JSHint options globally (for all Visual Studio solutions and projects) by selecting Web Essentials –> Edit global JSHint settings (.jshintrc) from the main Visual Studio menu.
The JSHint settings is simply a text file containing a JSON object that will be passed on to JSHint when it runs. The configuration options are all very well documented on the JSHint website, with a complete list of options here.
JSHint Options – Solution Level
Note: Creating a file that starts with a . can be difficult from Windows Explorer or from Visual Studio. The easiest way to create this file is to open a command prompt and enter echo.>.jshintrc. Once the file is created, include it in your Visual Studio project.
In this file, set whatever JSHint options you want. For example, if for some reason you wanted to allow missing semi-colons you could set the asi option to true.
Now all you need to do is add the file to source control and your settings are shared across your development team.
JSHint Options – File Level
You also have the option to override JSHint options at the file level using special comments.
For example, you could allow missing semi-colons for a specific file by adding
/* jshint asi:true */ to the top of the file.