brianleroux/lawnchair — pull request #210 by zenoamaro (2014-12-27 23:22:07+00:00)
Title: Code linting and full compliancy

This adds a lint step over `src/*` using [jshint].

I've tried to replicate the current project style (taken from the main module, rather than adapters), the NPM style, and @brianleroux's own comments in #208, producing a `.jshintrc` in the project root.

Here is a summary of changes:
- Some whitespace has been normalized (no tabs, 2 spaces indents, spaces around braces, colons, etc).
- Line lengths have been capped at 80 chars (as per NPM).
- All code now runs in strict mode (but not global strict).
- Explicitly marked globals and exports, and fenced some "peculiar" code.
- Fixed a couple of global variable leaks found by linting.
- Added lint step in the makefile, before `test` during `default` and `release`.

Notes:
- I did not normalize semicolons, curly braces, etc. until an explicit choice is made by the BDFL. When making changes, I simply left whatever style was there before.
- I tried to mess with logic as little as possible, but where I had to (mostly because of long lines), I tried to format everything in the style of surrounding code.
- Not all tests pass for me in `master` (I don't have a couchdb available), but those that do still pass in this branch.
- Lots of semicolons still lurking out there.

It can still be improved. Code style in adapters still varies wildly, for example, and there are opportunities for optimization and deduplication here and there. But they are out of scope for this PR, which is supposed to leave everything unchanged.

There is [eslint] too, which has different options for forcing code style, and [jscs] which is focused on enforcing code style only, but jshint is the safe choice so I picked that.

[jshint]: https://github.com/jshint/jshint/
[eslint]: https://github.com/eslint/eslint
[jscs]: https://github.com/jscs-dev/node-jscs