Standardized formatting?

Issue #40 new
coderpatsy created an issue

Moving this discussion into an issue...

Do we want to bother with standardizing source code format? Stuff like:

  • Tabs vs spaces for indentation?
  • no space between ) and { - already there except the odd outlier
  • spaces inside parentheses - if ( cond ){ vs if (cond){
  • spaces around + - * / math operators

Some of this can be helped through a .editorconfig file.

And while I'm here there's hundreds of jshint warnings (I use the notepad++ plugin for reference), mostly mixed spaces and tabs, variable already declared, and better written in dot notation (object.key instead of object["key"]). I had to turn off the latter just to be able to scan all of buildings.js. There's also unused variable argument warnings but I think we can ignore those for the most part.

Comments (6)

  1. David Nivens

    Personally, I give this idea a +1.
    As far as tabs vs spaces go, I think there's a git config option that can be set so that they will be automagically changed to whichever one is chosen when you commit your changes.
    Could be wrong though. If I am, git hooks could probably be written that would do the same thing.

  2. Arima B. repo owner

    I don't mind having standardizing format. :)

    JS hint on other hand can sometimes be overzealous. Some of it's warnings are questionable, some (no on redefining the var with the same name in the scope) are a bit aggravating. I would rather not blindly follow it all the time.

    object.key instead of object["key"]

    There is a semantic difference. Later puts an emphasis on the object as a dictionary. And I like this semantic difference instead of JShint's "No, you must use dot notation".

    Just my two cents.

  3. coderpatsy reporter

    It'd definitely less of a curmudgeonly stickler than jslint at least. But yeah, that's why I only touched the missing semicolons, and only when I was already in the file.

  4. Tomáš Arcanis Jílek

    Recently, there is another interesting option, .editorconfig file (http://editorconfig.org/). It has very small subset of funcionality (tab size, utf...) BUT, all major IDEs and editors will use this project settings. We use in work something like

    # editorconfig.org
    root = true
    
    [*]
    indent_style = space
    indent_size = 2
    end_of_line = lf
    charset = utf-8
    trim_trailing_whitespace = true
    insert_final_newline = true
    
  5. Log in to comment