KittyGiraudel / sass-guidelines

Guidelines for writing sane, maintainable and scalable Sass.
http://sass-guidelin.es
MIT License
908 stars 222 forks source link

About multiline lists and maps #56

Closed valeriangalliat closed 9 years ago

valeriangalliat commented 9 years ago

Current guidelines, about lists:

do not add a trailing comma. It is ugly and it does not help.

And maps:

comma (,) at the end of each key/value except the last;

I agree with these guidelines when the list/map fits in a signle line, but I like adding a trailing comma for multiline lists and maps. It allows to keep clean diffs when moving, appending or deleting lines, and don't require the developer (or a script) to handle differently the last line when editing code (this is annoying when using sed, multicursors, range substitution or macros for example).

I know this is not something everybody likes, but at least the two style guides I follow for JavaScript and PHP are recommending this too, and I see Rust is looking forward to recommend this practice too.

So basically, I'm for the following (let's assume the example strings are long enough to require a multiline structure):

$foo: (
  "a": "b",
  "c": "d",
);

$bar: (
  "a",
  "b",
);

However, I would be okay with not having commas at all in a multiline list.

Opinions?

KittyGiraudel commented 9 years ago

Multi-lines lists are prohibited anyway. Although I am thinking of forcing a trailing comma on maps.

valeriangalliat commented 9 years ago

Multi-lines lists are prohibited anyway.

I don't recall reading this, maybe it should be added?

tobysteward commented 9 years ago

Multiline's are coming - https://github.com/sass/sass/issues/216

valeriangalliat commented 9 years ago

Oh it's prohibited at Sass level. I misunderstood Hugo's comment.

Well if it's comming, we can still anticipate this!

KittyGiraudel commented 9 years ago

I don't recall reading this, maybe it should be added?

I should make this clear. I don't think it is a good idea to use multiple lines for a list unless it has too many items to fit on a 80-characters long line.

I'll add this.

KittyGiraudel commented 9 years ago

Added some extra content about lists. I'm still thinking about allowing/forcing trailing on maps. I can see the benefit.

KittyGiraudel commented 9 years ago

You got it.