Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Coding standards #181

Closed
attiks opened this issue Mar 15, 2014 · 4 comments
Closed

Coding standards #181

attiks opened this issue Mar 15, 2014 · 4 comments

Comments

@attiks
Copy link
Contributor

attiks commented Mar 15, 2014

Hi, I saw you're using jshint to check code style, but I also saw a mix of tabs and spaces for indentation, and I was wondering if there are some coding guidelines.

To decide:

  • tabs, spaces or smartTabs
  • indentation: 2 or 3 spaces
  • space after if or not
  • use hasOwnProperty in iterations
  • jsdoc parameter type requires {}
@attiks
Copy link
Contributor Author

attiks commented Mar 17, 2014

related #184

@kevee
Copy link
Collaborator

kevee commented Mar 17, 2014

Thanks, @attiks, I think we should also codify these in an editorconfig file if possible. My immediate reaction is:

  • Two spaces for indentation
  • A liberal spacing style (space after if, between parenthesis)
  • Using hasOwnProperty
  • Formally adopting jsdoc

Standing on the shoulders of giants, we could stand on the shoulders of giants a bit and adopt the jQuery style guide or something similar.

@attiks
Copy link
Contributor Author

attiks commented Mar 17, 2014

I'll work on it, will try to create a PR tonight, I'll update .jshintrc accordingly

@jessebeach
Copy link
Member

Agreed on all fronts. My one nitpick

array = [ "*" ];

array = [ a, b ];

foo( arg );

foo( "string", object );

foo( options, object[ property ] );

foo( node, "property", 2 );

I wouldn't put spaces inside the parens like this. Drupal style guide prohibits this extra spacing.

My editor automatically removes trailing whitespace. I convert tabs to spaces manually.

Let's just try to keep coding standards changes isolated and not part of other commits so that diffs with behavior changes are clean.

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

No branches or pull requests

3 participants