Skip to content

Use a code style linter #727

Description

@stephenplusplus

Now that we are seeing more contributions, it would be a good time to remove the guesswork from matching our library's style rules. https://github.com/jscs-dev/node-jscs can integrate with our npm run lint command, so PRs will catch any issues.

@callmehiphop do you know of a better one than jscs?

Activity

  1. callmehiphop commented on Jul 17, 2015

    @callmehiphop
    Contributor

    @stephenplusplus I like jscs personally, has there ever been any documented conversations around general dos and don'ts?

  2. stephenplusplus commented on Jul 17, 2015

    @stephenplusplus
    ContributorAuthor

    Laced all throughout PRs and issues history. We should try the --auto-configure option: http://jscs.info/overview.html#options.

  3. callmehiphop commented on Jul 17, 2015

    @callmehiphop
    Contributor

    --auto-configure tests your code against several pre-made style guides and tells you how many times you violate it. It looks like you can then use those style guides as a base and make adjustments if you want to turn on/off additional rules.

  4. callmehiphop commented on Jul 17, 2015

    @callmehiphop
    Contributor
    Preset Errors Rules
    airbnb 224 11
    crockford 4279 6
    google 117 7
    grunt 47 6
    jquery 4815 10
    mdcs 5256 8
    node-style-guide 296 10
    wikimedia 8401 11
    wordpress 3869 11
    yandex 3825 8
  5. stephenplusplus commented on Jul 17, 2015

    @stephenplusplus
    ContributorAuthor

    Ah okay, probably want to find the closest match and make adjustments then. Here are some things:

    // good
    function fn() {}
    
    // bad
    var fn = function() {};
    
    // good
    aMethod(function(err) {
    });
    
    // bad
    aMethod(function (err) {
    });
    
    // good
    if (something) {
    } else if (somethingElse) {
    }
    
    // bad
    // any other way of spacing if clauses

    Let me know if I can answer any "this" or "that"s!

  6. stephenplusplus commented on Jul 17, 2015

    @stephenplusplus
    ContributorAuthor

    I don't know if these could be covered, but:

    // good
    var self = this;
    
    // bad
    var that = this;
    
    // good
    var self = this;
    aMethod(function() {
      self.anotherMethod();
    });
    
    // bad
    aMethod(function() {
      this.anotherMethod();
    }.bind(this));
  7. added a commit that references this issue on Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions