Add .jshintrc and format code accordingly

Added project configuration for jshint and updated code accordingly.
The code will still raise one issue which is related to
[#1016](https://github.com/jshint/jshint/issues/1016). This can be
ignored.