Skip to content

Create style guide #19

Closed
Closed

Description

@cletusc

We need consistent formatting of code and we should define it very explicitly. We can always do cleanup commits, or even have someone specifically assigned to do code cleanup.

Activity

  1. jerone commented on Nov 7, 2013

    @jerone
    Contributor

    We can look at existing style guides, like the one from jQuery: http://contribute.jquery.org/style-guide/

  2. simonzack commented on Nov 7, 2013

    @simonzack
    Member

    Something I'm not quite sure about is the use of camel case vs underscore, which I think carries over from java. Jquery has it in it's guidelines, but it's imo much harder to read. Which casing should we adopt?

  3. cletusc commented on Nov 7, 2013

    @cletusc
    ContributorAuthor

    camel case vs underscore

    IMO, camel case. Thinking in the future here, if we use underscore.js (_(stuff).func()) or some sort of i18n (usually seen as __('Some string here.')), the extra underscores from variable names might confuse some.

    I would recommend basing a lot of it on idiomatic.js, which is what I kind of follow already albeit with some white space changes.

  4. jerone commented on Nov 7, 2013

    @jerone
    Contributor

    I don't mind which style guide we choose, as long as make use of tabs (instead of spaces). With tabs I can choose my own size (2, 4, 8, ...), which is 4 for me personally.

  5. cletusc commented on Nov 7, 2013

    @cletusc
    ContributorAuthor

    make use of tabs (instead of spaces)

    Agreed, I propose we use tabs for indentation, and spaces for alignment of anything else after the indentation is correct, should we need to align anything.

  6. simonzack commented on Nov 7, 2013

    @simonzack
    Member

    make use of tabs (instead of spaces)

    Agreed, I propose we use tabs for indentation, and spaces for alignment of anything else after the indentation is correct, should we need to align anything.

    Same here, I absolutely love tabs.

  7. sizzlemctwizzle commented on Nov 7, 2013

    @sizzlemctwizzle
    Member

    I despise tabs, and so does most of the open source community from my experience. Challenge: find a popular open source project that uses tabs for indentation. Also the tab width on GH is huge so our code will look like shit here. Also, this is another barrier to entry. Spaces work everywhere, but tab width must be set where ever (if even possible) you plan to view the code.

    Find a proper source code editor that will add the appropriate number of spaces when you hit the tab button (I know Notepad++ supports this). If this is a must have for you guys, I will write a node script that converts tabs to spaces and vice versa.

    Also, I vote for the Greasemonkey style guidelines, with a few exceptions for the parts that apply to Firefox addon development.

    @joesimmons What do you think? (I hope tagging a user brings it to their attention)

  8. joesimmons commented on Nov 7, 2013

    @joesimmons
    Member

    Can we use Douglas Crockford's code conventions?
    It's idiomatic, from what I understand of that word.

    I'm for using spaces. I used to use tabs but spaces are actually better.
    Notepad++, as sizzle said, can replace tabs (as you type them) with a certain # of spaces.
    I really like indentation to be 4 spaces, as it's clear to me when a block is indented. I could use 2, but I'd have to switch back and forth all the time when developing for the site, and developing my own scripts.

  9. cletusc commented on Nov 7, 2013

    @cletusc
    ContributorAuthor

    We could look into integrating an editor config to simplify things--there are plugins for all major text editors by the looks of it. This would fix any issues with tabs, line endings, and EOF newlines.

    Most of all, I want to avoid any major debate between tabs and spaces. As we don't have a unified opinion, let's find a middle ground--editorconfig should help.

    For clarification, I am OK with GM style guide aside from the space/tab issue.

  10. sizzlemctwizzle commented on Nov 7, 2013

    @sizzlemctwizzle
    Member
    Can we use Douglas Crockford's code conventions?
    I agree with all that, but it's very similar to the Greasemonkey style guide.
    I really like indentation to be 4 spaces, as it's clear to me when a block is indented. I could use 2, but I'd have to switch back and forth all the time when developing for the site, and developing my own scripts.
    I like using 2 spaces because you indent 4 spaces for a statement that continues onto the next line. If we use 4 spaces, that means 8 spaces on a continuation and it will quickly explode.
    We could look into integrating an editor config to simplify things
    So we just plug this into our editor of choice and it saves the files according to the defined guidelines? That page doesn't explain it very well.
  11. jerone commented on Nov 7, 2013

    @jerone
    Contributor

    And so starts the big spaces versus tabs discussion :)

    As it stands now, we have:

    • 3 users for tabs
    • 1 user for using 2 spaces
    • 1 user for using 4 spaces
  12. cletusc commented on Nov 7, 2013

    @cletusc
    ContributorAuthor

    So we just plug this into our editor of choice and it saves the files according to the defined guidelines?

    That's the idea I think. I'll look more into it when I get home, but jQuery uses it and I'm sure many others as well. It's a good idea if it works.

    And so starts the big spaces versus tabs discussion :)

    What I was trying to avoid... :P

  13. sizzlemctwizzle commented on Nov 7, 2013

    @sizzlemctwizzle
    Member

    And so starts the big spaces versus tabs discussion :)

    I thought this debate was settled before I was even born, but apparently I was wrong. I thought we were all spacemen by now.

    That's the idea

    Well if it works, then win-win.

  14. jerone commented on Nov 7, 2013

    @jerone
    Contributor

    Does Node.js has a style guide?

  15. sizzlemctwizzle commented on Nov 7, 2013

    @sizzlemctwizzle
    Member

    It's written in C++.

  16. 14 remaining items

  17. added a commit that references this issue on Jul 11, 2014
  18. locked as resolved and limited conversation to collaborators on Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureSomething we don't already have implemented to the best of knowledge but would like to see.team bizThis is similar to a meta discussion.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions