Javascript Code Review Tool

Some details in code review are repetitive at times, such as: “always use strict equal in JS”, “Function unused”. So, what about to automating these things with a great tool?

Step 1: Signing in Hound CI

Hound CI is a hosted service that reviews GitHub pull requests for Ruby, JavaScript, CoffeeScript, and SCSS style guide violations.
Go to https://houndci.com/ and Sign In with your Github account:

Sign Hound CI

This gonna open your repository list. I created a hound-ci-tutorial, you can choose whatever you want. So, choose a repository and activate it:

Active Hound CI

Step 2: Open Pull-Request

To test, I will create a pull-request in the repository have chosen with some JS file and view the hound CI standards validations.

Github PR

Step 3: Custom Configuration

This is the default JS setting Hound CI. You can see the default version here. Let’s create a custom validator. In your repository create a file called .javascript-style.json with this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"asi": false,
"bitwise": true,
"browser": true,
"camelcase": true,
"curly": true,
"forin": true,
"immed": true,
"latedef": "nofunc",
"maxlen": 80,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"predef": [
"$",
"jQuery",
"jasmine",
"beforeEach",
"describe",
"expect",
"it",
"angular",
"inject",
"module"
],
"quotmark": true,
"trailing": true,
"undef": true,
"unused": true,
"eqnull": true
}

We copy the default version and added this eqnull line. After that, create .hound.yml file in your repository with this code:

1
2
javascript:
config_file: .javascript-style.json

You can create a test file, this will raise eqnull error:

1
2
3
function eqnull(){
return 1 == 2;
}

So you can see the result:

Github PR

Conclusion

You can take a look and see the other features available not only for javascript, but for css, ruby, python. It’s a fantastic tool.


Comments:


Comments: