1 | mocha-jshint
|
2 | ------------
|
3 |
|
4 | Run jshint as Mocha tests.
|
5 |
|
6 | To install in your node.js project as devDependency, run this command, in the root of your project
|
7 | ```
|
8 | npm install mocha-jshint --save-dev
|
9 | ```
|
10 |
|
11 | usage
|
12 | -----
|
13 | Mocha defaults to looking for your test specs in the `test` folder of your project.
|
14 | Add this file as `test/jshint.spec.js` in your project, with the following content:
|
15 |
|
16 | ```js
|
17 | require('mocha-jshint')();
|
18 | ```
|
19 |
|
20 | That is it you are done.
|
21 |
|
22 | To grep only the jshint test, just do
|
23 | ```
|
24 | mocha --grep jshint
|
25 | ```
|
26 |
|
27 | configuring jshint
|
28 | ------------------
|
29 | In the root of your project you can add a `.jshintignore` file, where each line is a file or directory for jshint to ignore
|
30 | and not check for errors. (see this project for an example)
|
31 |
|
32 | At the root of your project you can add a `.jshintrc` file, that specifies what options you want jshint to run with
|
33 | (see this project for an example)
|
34 |
|
35 | You can also add a `.jshintrc` file to any subdirectory of your project, to override the .jshintrc settings in the root.
|
36 | For example in this project I allow some global variables in the `test` folder. Global variables that are set when I
|
37 | run mocha tests. Global variables that are only allowed to be used, in the .js files in the test folder
|
38 |
|
39 | Why?
|
40 | ---
|
41 | This module was created to:
|
42 |
|
43 | - Make adding jshint testing to a project using Mocha as easy as possible
|
44 | - Make it easy to piggyback on all the different Mocha reporters (dot, spec, teamcity etc) for jshint output
|
45 | - Make sure that you get a click-able link directly to the problem in WebStorm, when jshint fails
|
46 | - Make sure that there is no unnecessary noise in the test output |
\ | No newline at end of file |