Skip to content

Conversation

@yungcheng
Copy link
Contributor

Proposed rule change: object-curly-spacing from always to never, also
react/jsx-curly-spacing from always to never

The rules we have now it's not consistent, we set object-curly-spacing to always but with objectsInObjects set to false, which makes the following valid

/*eslint object-curly-spacing: ["error", "always", { "objectsInObjects": false }]*/

var obj = { "foo": { "baz": 1, "bar": 2 }};

(Note the spacing is asymmetric considering in the end there's no space, but there is a space after opening curly brace)

Same for our react/jsx-curly-spacing rule, we set it to always but spacing: { objectLiterals: 'never' }, which makes the following valid:

<App blah={ 3 } foo={{ bar: true, baz: true }} />;

This PR turns both rule to never which eliminates all unnecessary spaces and confusions. It also makes code more compact and easier to read and author.

References:
object-curly-spacing
react/jsx-curly-spacing

@indexzero
Copy link
Contributor

Thoughts on simply changing objectsInObjects to true?

@yungcheng
Copy link
Contributor Author

I can live with that, but I don't feel those spaces improve read-ability much. However, as long as spaces are symmetric and consistent, I am okay.

@yungcheng
Copy link
Contributor Author

close this now that #48 is merged as the spacing is now symmetric

@yungcheng yungcheng closed this Dec 5, 2018
@yungcheng yungcheng deleted the object-curly-spacing-never branch December 5, 2018 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants