Skip to content

Latest commit

 

History

History
57 lines (49 loc) · 2.14 KB

jshint-setup.md

File metadata and controls

57 lines (49 loc) · 2.14 KB

Back to top

Enable JSHint validation for Javascript files

CommitHooks app has a validator to connect JSHint Javascript files validator. You may install it.

Install

Let's admit you already have NodeJS and npm. If not, please take a look the references below.

JSHint

$ npm install -g jshint

Integration

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.

Configure JSHint validation

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

References

$ curl -Ls https://gist.github.com/andkirby/3f65c5a6499739c842e25fb7f6d5e682/raw/node-npm-git-bash-win.sh | bash

Back to top