Add JS hint & gjslint #35

Closed
ctavan opened this Issue Apr 12, 2012 · 5 comments

Projects

None yet

2 participants

@ctavan
Contributor
ctavan commented Apr 12, 2012

I've seen you have added travis-ci, which is great! What about adding some linting to enforce consistent code style? I'm usually using the following make targets to achieve that:

test: jshint gjslint
    # start testsuite here

JSHINT = node_modules/jshint/bin/hint {lib,test,bin}/**/*.js \
    --config share/jshint-config.json

jshint:
    @shopt -s globstar && echo '$(JSHINT)' && $(JSHINT)

gjslint:
    gjslint --debug_indentation --nojsdoc --unix_mode \
        -e test/fixtures \
        -r lib -r test -r bin

Here's the jshint-config. It's tuned to follow the Google Javascript Style-Guide.

@devdazed
Member

I actually use linting myself, I have the following in my settings, but adding a make target would also be a good idea:

{    "jshint_options":
    {
        "evil": true,
        "regexdash": true,
        "browser": true,
        "wsh": true,
        "trailing": true,
        "sub": true,
        "curly": true,
        "eqeqeq": true,
        "forin":true,
        "newcap":true,
        "nonew":true,
        "plusplus":true,
        "regexp":true,
        "undef":true,
        "es5":true,
        "devel":true,
        "jquery":true,
        "nonstandard":true,
        "node":true,
        "strict":false,
        "globalstrict":true
    }
}
@ctavan
Contributor
ctavan commented Apr 12, 2012

I think for a node-only project like this one, options browser, wsh, jquery should be set to false.

I personally like to allow plusplus and i think trailing = false would also help to remove trailing whitespaces (I see them in my editor and they hurt my feelings).

I like gjslint a lot since it does quite proper code-style checking (like where to put spaces, avoiding tabs, respect 80-char line limit etc. pp.). Would you allow that or is that too strict for you?

@devdazed
Member

ill allow it, but plusplus is a must for me. It's part of the good parts and it keeps things like this from happening: v = + +i

@ctavan
Contributor
ctavan commented Apr 13, 2012

OK, I can live with plusplus. What do you think about applying the Google Styleguide rules?

@devdazed
Member

I agree with the Google StyleGuide rules.

@devdazed devdazed closed this May 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment