Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code linting and full compliancy #210

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open

Code linting and full compliancy #210

wants to merge 32 commits into from

Conversation

zenoamaro
Copy link

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.

@felixhammerl
Copy link

thanks for the work, man! i guess it might make sense to put this on a development branch for a v2 ov lawnchair ... i'll think of something. can't promise when i'll have the time to go through it, but a big thanks already!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants