Lint : a code quality tool for your development environment

As to ensure the quality of the code that is added to the project, we ask all the developers to setup a code quality tool on their development environment to enhance the overall code.

Install pylint

Make sure you are in the development environment and run :

pip install pylint git-pylint-commit-hook

The command pylint and git-pylint-commit-hook will now be accessible in your system.

install jslint

For this, you’ll need to have NodeJS installed on you computer as well as NPM (Node Package Management tool).
First you’ll have to install the latest version of NodeJS on your computer :

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs

Then install jslint and jshint

npm config set registry http://registry.npmjs.org/
sudo npm install jslint -g
sudo npm install jshint -g

https://github.com/reid/node-jslint
After running those commands, the jshint binary should be available in the directory /usr/local/bin/jshint

Setup git hook

In your repository, you’ll need to edit the file (or create it) .git/hooks/pre-commit with the following :

#!/usr/bin/env bash
./tools/pre-commit

In the root folder of your repository, make sure that you have the following files :

.jshintrc

//http://www.jshint.com/docs/options/
//http://jslinterrors.com/
{
  "asi": false,
  "expr": true,
  "loopfunc": true,
  "curly": false,
  "evil": true,
  "white": true,
  "undef": true,
  "node": true,
  "camelcase": false,
  "eqeqeq": true,
  "indent": 4,
  "quotmark": "double",
  "unused": false,
  "trailing": true,
  "maxlen": 100,
  "white": true,
  "globals": {
    "$": false,
    "jQuery": false,
    "angular": false,
    "console": false,
    "require": false
  }
}

.jshintignore

node_modules
cpwp/cwp/public/lib

.pylintrc

Click to see the file : .pylintrc
And this is it. Now with this you should be ready to commit

Setup lint in Eclipse

For python you can enable pylint inside Eclipse to have code assist with usefull tips.
Go in Window > Preferences > PyDev > PyLint
Capture du 2014-04-14 15:13:02

Setup lint in Vim

Here are a few links to setup the Lint environment in Vim :
pylint.vim : compiler plugin for python style checking tool
Jshint2.vim : Lightweight, customizable and functional Vim plugin for JSHint integration.
Syntastic : Syntax checking hacks for vim

Leave a Comment.