Styleguides

Of course! :smiley: https://twitter.com/mathias/status/247708186696634368

(No, there is not even a performance difference ā€¦ http://jsperf.com/single-quote-vs-double-quote/3 )

Any such reason for preferring ' in JS?

None, it is just personnal preference. And I prefer using " " for class or id when I define inline HTML, so this prevent quotes collision and usage of \".

Edit : yeah, just like @faldrian :stuck_out_tongue:

Also, about JS, I like JSON rather that function() for object definitions :

JSON :

var object = {
    var1: 'var',
    var2: 'var also'
}

Function definition :

var object = function(){
    var1 = 'var';
    var2 = 'var also;
}

Prettier and easier to read.

Would be nice to set option multistr to true, Milou bothers me with that >.<

The JSHint docs say

Multi-line strings can be dangerous in JavaScript because all hell breaks loose if you accidentally put a whitespace in between the escape character () and a new line.

I didnā€™t know that. Canā€™t wait for ES6ā€¦

So, shall we put mandatory comments to a vote?

Since we exchanged arguments with pretty much no effect, this might be a good idea.

I think so.

To me, proposition should at least include these elements :

  • mandatory comments required for eavery PR
  • at least for JS code
  • at least for functions that are above 3 lines.

mandatory comments required for eavery PR
at least for functions that are above 3 lines.

Thatā€™s contradictory, please clarify.

at least for JS code

All or nothing, doing it for part of the code base and for another part not is just worse.

I say at least, now if we vote fore mandatory comments and you think itā€™s better to

Thatā€™s contradictory, please clarify.

Every new function has to be documented unless it is obvious (less than 3 instructions) eg. this is obvious and this too.

I consider as an instruction any call of method. So, if thereā€™s chained methods call, each call is an instruction. Eg :

var.call1().call2().call3().call4()

is 4 instructions. But Iā€™d like to limit a too big number of chained call (not more than 4, maybe ?) if possible.

Also, about SCSS is nesting limit relevant ?

Thatā€™s way too vague, you canā€™t measure complexity in LoC or calls.

Itā€™s just a proposition, I donā€™t see any other easy way to measure it. Itā€™s not useful to put mandatory comments for very obvious case, but we need a clear rule to determine what is ovious and what is not.

I donā€™t like rules and hard limits where none are necessary. It is already possible to look through new pull requests and add comments like ā€œhmā€¦ big block of code, care to comment some of that?ā€ - if the developer not already has done so.
We all want to write good and understandable code - if there are people who have hints how to make code better understandable, they can say so in the PRs.

I think the solution to documentation issues will more likely be solved by communication and external documentation than by enforcing arbitrary rules on the structure of new code.

Letā€™s focus more on gettings things done here than setting up a ruleset to play byā€¦ (that wonā€™t be used if people donā€™t see the purpose of it).

Iā€™m totally with Faldrian. Since there obviously are no simple rules to determine when a mandatory comment should be placed, do you still hold to wanting them?

We have to find how to better document the code. This is the solution I found. If Iā€™m the only one on this, of course it will never be accepted.

But the problem is still here : the code is still abstruse. So, no matter what, we need a solution on this.

When the styleguide is set, what if I set up a RubyMine inspection file for the official repo ?

But the problem is still here : the code is still abstruse. So, no matter what, we need a solution on this.

The way forward is to make it less abstruse, not to bury the clear parts in comments.

When the styleguide is set, what if I set up a RubyMine inspection file for the official repo ?

I donā€™t use RubyMine, so maybe. We will most likely add the above mentioned linters with configs that match the styleguide as good as possible and enable Hound.

I donā€™t use RubyMine, so maybe. We will most likely add the above mentioned linters with configs that match the styleguide as good as possible and enable Hound.

BTW, RM supports JSHinter and JSLinter.

JSLint is a bunch of cr*p. Itā€™s too harsh for any sane person. JSHint is the way to go, I guess. I think comments should be optional, but each file should at least have a comment, explaining what itā€™s trying to do in the system, why itā€™s needed there. But this can be enforced when accepting PRā€™s, thereā€™s no need for a linter to check it.

Regarding SCSS - Itā€™s a mess right now. Iā€™ve been thinking a lot about it, and itā€™s a difficult problem.

I propose to use the SMACSS approach and use these rules to separate the selectors:
https://smacss.com/book/categorizing

We should have 5 folders and a file:

  • base

    • _base.scss (only for including this folder files)
    • random .scss files
  • layout

    • _layout.scss

    • the same rules as before

  • module

  • state

  • themes

    • default (a folder)

      • _main.scss (to include the other files) (this should be nested under default folder, itā€™s something weird with loomio markdown)
      • whatever files the theme creator wanted, it may again follow the SMACSS structure
  • application.scss

@import ā€˜base/baseā€™, ā€˜layout/layoutā€™, ā€˜module/moduleā€™, ā€˜state/stateā€™;
@import ā€˜themes/cerulean/_mainā€™; (changed the theme to cerulean)

@dumitruursu We already use JSHint.