While reading this set of ECMAScript 5 coding standards is a step in the right direction, it does not get you all of the way. Some rules are easier to remember and stick to than others. It is best to have a tool that programmatically checks your sources code for violations of coding standards as you develop, and highlights them within your IDE, and gives you detailed output as part of your build process.
These options are configurable using a file named
which usually sits at the root directory of a project.
.jshintrc file which conforms to the rules
that have been described in the ES5 specifications will be made available soon.
Essentially all the default JsHint options are used, with a few exceptions.
Using WebStorm with JSHint
JSHint is integrated into the WebStorm code quality tooling, it offers realtime feedback and analysis reports. The real time feedback can greatly accelerate a developer’s familiarity in complying with JSHint and preventing errors.
Setting it up in the IDE is done in the menu:
In the JSHint configuration click the
Use config files and set the
Custom configuration file path
to the provided
.jshintrc file above.
Now you need to verify the JSHint Inspection is also enabled in the Inspections menu, it may previously be enabled on your system.
When your JSHint configuration is working, you will see JSHint output as you code. The jshint issues appear in the line gutter in red and an underline on relevant the code. Hover the gutter to view the error message to see the pop-up like in the example.
WebStorm also integrates JSHint in it’s inspection tools. This is useful for checking and updating multiple files quickly and using the rest of WebStorm’s code quality tools.
In the main WebStorm menu run Inspection.
Code -> Inspect Code...
Choose a scope to inspect in the window that pops up. You can recursively inspect a project of choose a particular file.
OK the UI will provide populate a list of inspection results.
Clicking the items let you jump to files to resole any issues.