Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About multiline lists and maps #56

Closed
valeriangalliat opened this issue Jan 7, 2015 · 7 comments
Closed

About multiline lists and maps #56

valeriangalliat opened this issue Jan 7, 2015 · 7 comments
Labels

Comments

@valeriangalliat
Copy link

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
Copy link
Owner

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

@valeriangalliat
Copy link
Author

Multi-lines lists are prohibited anyway.

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

@tobysteward
Copy link

Multiline's are coming - sass/sass#216

@valeriangalliat
Copy link
Author

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

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

@KittyGiraudel
Copy link
Owner

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
Copy link
Owner

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

@KittyGiraudel
Copy link
Owner

You got it.

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

No branches or pull requests

3 participants