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
Upgrade XO and add Prettier #121
Conversation
GeneralIMO, these are the type of changes which you should first open an issue and discuss, prior to submitting a PR. Discussing this with the various stakeholders first and obtaining buy-in from the various userscript projects prior to proposing code changes allows you to get buy-in that any change along these lines is even desired. After that, you can have a discussion and get agreement on the specifics of the formatting choices. Basically, by issuing a PR first, you make it appear, or at least engender the feeling, that you are attempting to impose on the project your personal opinion of what code formatting should be. (OK, it's a view of "good" code formatting that you probably share with your "Prettier" project, but from the POV of this project, it's your own personal opinion of what code should look like.) Starting from this point will naturally set some people in opposition to the change, because of the way that you went about it, rather than discussing it and getting some agreement that change of this type is desirable. While I'm generally in favor of having consistent code styles, it's been the choice of this project to permit each userscript to establish their own formatting and parameters for xo. Imposing additional formatting changes upon multiple scripts does not feel appropriate (even upon just those scripts that have not established their own xo parameters), without having first discussed this. |
As to the specific code formatting changes chosen, I agree with some of them, but others I feel are detrimental to readability/maintainability. Brief review of some specific changesBreaking "long" lines in detrimental waysMany of the changes you're making appear to be to satisfy some arbitrary length requirement, rather than focusing on readability/maintainability. For instance, You change:
to:
IMO, a change like this has no benefit, and reduces readability. Frankly, there are a large number of changes like this, few/none of the ones in this category make the code easier to read, and many/most make it harder. This appears to be due to imposing an automatic formatting requirement that lines won't exceed some (quite small) length limit. However, where these have been applied, they are mostly harmful, not helpful. A line-length requirement opens up a few different issues, not the least of which is "how long is too long". Based on the change made to the above line, you've chosen something in the 80 character range. While that length may have made sense 30 years ago, displays these days are far more capable. While some length guidelines, intelligently applied, are, IMO, desirable, a fixed limit, particularly one so small, is not. IMO, breaking lines like this is worse than useless. You've still ended up with a line that exceeds your set limit. You've just made it harder to read by spreading it over three lines. There are times when it's a really good idea to have a limit on the length of lines. However, this, specifically, is not the type of change that makes code better. There are many examples of this in the changes you've made. Multiple lines for arguments and parametersWhile this can be beneficial, in some situations, in others it can, IMO, significantly reduce readability/maintainability. This may just be an extension of having set a low limit on the line length. Example: You've changed the following three statements (these are simple to read and compare by just scanning down the three lines):
Into the following 15 lines, which require scanning the eye back and forth across multiple lines to determine that, in fact, they are almost completely identical:
At least to me, what you've changed this to is far less readable than what it was originally. There are, again, many examples of this type of change in what you've done.
|
TL;DR: if the individual scripts can choose the parameters for Prettier, I'm fine with this; if not, we need a discussion with script authors. Upgrading xo is a good thing in either case. |
Related: #37 |
I’m sorry if I came off as trying to impose a style. I meant for this to be a discussion, since it’s harder to debate whether or not to make these changes if you can’t actually see what’s going to be changed.
I agree that these don’t look great, but I feel like it’s one of the tradeoffs that you make so you never need to worry about formatting. Although we could increase the
I allowed xo to make the changes automatically.
Yikes, do you have a reproducible example of this? If so, that’s a bug in ESLint that should be fixed.
These syntaxes are almost fully interchangeable. The only differences AFAIK are that you can’t construct (
If you have an example of jQuery throwing an error, that’s a bug which should be reported. Otherwise, the only case where arrow functions could cause problems is where you’re trying to use
This is one of those cases where Prettier picks a style and uses it. This makes code more consistent, rather than having some numbers be uppercase and others lowercase.
You should be able to put a That’s the best I can do at 6am :) If you want a longer explanation for something, please don’t hesitate to ask & I’ll see what I can do. |
Oh, one more thing: almost all of the syntax changes came from XO. Prettier only changes whitespace and a few other things, like parens and semicolons. |
This upgrades XO to the latest version, fixing newly reported errors. It also adds Prettier, which standardizes formatting end helps ensure consistency.
Appending
?w=1
to the diff URL makes the changes more readable.(full disclosure: I’m a Prettier contributor)