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

Inconsistent spacing between objects and arrays #1335

Closed
mafintosh opened this issue Jul 18, 2019 · 2 comments

Comments

@mafintosh
Copy link
Contributor

commented Jul 18, 2019

On the latest version of standard when writing objects I have to write them like this:

const foo = { foo: 'bar } // with the space

But when I make arrays I now have to do it like this

const foo = ['foo', 'bar']

Whilst [ 'foo', 'bar' ] is now disallowed.

I personally find this confusing so I was wondering if there was any motivation behind this change? :)

@LinusU

This comment has been minimized.

Copy link
Member

commented Jul 18, 2019

I think the motivation was mostly that that is how the majority of the eco-system does it. Enforcing arrays with spacing broke a ton of repositories, and enforcing objects without spacing also broke a ton of repositories.

For what it's worth, prettier also defaults to this. XO seems to enforce no spacing in both array and object.

I agree that it's a bit weird that it's not the same, but this has been the style that I've personally always used, and it's the one I've seen most used in the wild as well...

@feross

This comment has been minimized.

Copy link
Member

commented Aug 11, 2019

What @LinusU said :) We tried both ways and no spaces felt more natural and would cause the least ecosystem breakage when updating to the latest version of standard.

Also, anecdotally speaking, It's actually a great style once you get used to it. :)

@feross feross closed this Aug 11, 2019

@feross feross added the question label Aug 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.