CommitHooks app has a validator to connect JSHint Javascript files validator. You may install it.
Let's admit you already have NodeJS
and npm
. If not, please take a look the references below.
$ npm install -g jshint
Installed jshint
package has a binary file. So as an interpreter we may use bash
(or use node
instead).
$ commithook config --global --xpath validators/JsHint/execution/interpreter_type bash
Note: you may check your interpreter path, e.g. node
:
$ commithook config --xpath code/interpreter/node
c:/xampp/node/node.exe
$ commithook config --xpath code/interpreter/bash
bash
If jshint
binary file is not allowed globally define a path to it then:
commithook config --global --xpath validators/JsHint/execution/linter /path/to/jshint
And now, let's enable the validation:
commithook config validator:disable JsHint --enable
There is a created file .commithook/JsHint.xml
.
You may define your JSHint configuration in file .jshintrc
in project root directory.
Also your may define it in packages.json
in the project root (see how).
And you may define your own custom path within project, for instance (it can be packages.json
or .jshintrc
file):
$ commithook config --project --xpath validators/JsHint/config/file/custom/any_name path/to/file/packages.json
- Quick install NodeJS and NPM (Windows / GitBash only)
$ curl -Ls https://gist.github.com/andkirby/3f65c5a6499739c842e25fb7f6d5e682/raw/node-npm-git-bash-win.sh | bash