Linting - tsgrp/HPI GitHub Wiki
Linting Guidelines / Tips
- Understand the error! - Search for your error and look for the result on http://jslinterrors.com/. You'll find great detail about why there is an error reported and how you can fix it.
- It is possible to supress errors using the /jshint/ syntax, BUT Do not suppress errors unless CR'd by Analyst - Supression is is bad practice unless there is a very good reason. Sometimes though, there are errors that are produced by odd use of a plugin and suppression can be justified.
Setting up Sublime Linter for Sublime
this is optional but recommended
In order to show lint errors directly in your editor while you type, you should install a sublime package called sublime linter See Here. This plugin will look at our HPI lint settings .jshintrc and properly replicate all the jshint errors we wish to see and suppress those we have deemed safe to ignore.
Prereqs:
- Sublime Text 3
- Package Control https://sublime.wbond.net/installation
- JSHint on your path
npm install -g jshint
Installation:
- Open Sublime 3
Ctrl-Shift-P
(to open context menu) and type to autocompletepackage control install package
- When prompted find
SublimeLinter
and install Ctrl-Shift-P
again and installSublimeLinter-jshint
- Restart Sublime Text and Load a file with a lintable error in it!
Running The Linter
- It is possible at this point that the linter is running whenever you save a file, or perhaps at build time, but if not, you can run the jshint task at any time to see all issues in hpi.
- At command prompt run the following: `grunt jshint --project=[your project]
- You should see output detailing all issues. Fix them!
Running JSHint Reporting Output
- If you would like to run the jshint reporting in order to list all problems in a printer friendly format:
- Run:
grunt --no-color jshint:report --project=[your project]
- The file should be output as jshintReport.txt in the code/ folder