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

misc(lint): break lines after operators #6592

Closed
wants to merge 1 commit into from
Closed

Conversation

brendankenny
Copy link
Member

@brendankenny brendankenny commented Nov 17, 2018

inspired by #6579 (comment)

Surprised this wasn't on either.
eslint-config-google has the very helpful lines

// TODO(philipwalton): add a rule to enforce the operator appearing
// at the end of the line.

:P Were we all just following this unconsciously?

I learned from reading about the operator-linebreak rule that some people really do prefer to have the ternary (ConditionalExpression) operators at the start of a new line, so we could maybe discuss that for these since there's some preexisting ones.

However, in our code base the ? and : at the end of lines outnumbered them at the beginning of lines by like 5 to 1, so if we go with one of these choices, the changes in this PR seem like the better option.

(operator-linebreak is also supported by --fix, so should be fine for those using prettier and then fixing)

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@paulirish
Copy link
Member

I think I like 'before' better. 😀

@brendankenny
Copy link
Member Author

I think I like 'before' better. 😀

which one? All of them? One issue is they don't match our style elsewhere

? end of line: 33 results
? beginning of line: 8 results

: end of line: 21 results
: beginning of line: 8 results

+ end of line: 303 results
+ beginning of line: 2 results

|| end of line: 59 results
|| beginning of line: 4 results

&& end of line: 67 results
&& beginning of line: 1 result

and all other operators have been put at the end of lines 😛

@patrickhulce
Copy link
Collaborator

I like prettier, and as a majority of the changes in this PR are on my files that were formatted with prettier on save, I'm a bit bummed that dream would die 😞

Personally though, I do prefer after to before even if that habit originated from foolish ASI paranoia.

@wardpeet
Copy link
Collaborator

we might consider eslint-config-prettier if we like the prettier approach so we don't conflict with eslint rules.

@brendankenny
Copy link
Member Author

brendankenny commented Nov 18, 2018

if we like the prettier approach

That will never be a problem we (unanimously) have :P

@patrickhulce
Copy link
Collaborator

Good job adding "unanimously" I was about to bring down the 🔨 😛

@brendankenny
Copy link
Member Author

😀 😛

@paulirish
Copy link
Member

image

@paulirish paulirish closed this Dec 7, 2018
@brendankenny brendankenny deleted the opbreak branch December 10, 2018 19:02
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.

5 participants