Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdopt prettier for consistent formatting #811
Comments
This comment has been minimized.
This comment has been minimized.
|
Posted this too early going to edit description to include more detalis. |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Mar 3, 2017
•
|
It isnt the right thing in any way. There is ES-Beautifier that tries to do everything using the ESLint ecosystem. That's the right move. Prettier is meant to be opinionated and so it cant be easily integrated and should not be. The ESLint --fix feature is awesome, and we all should just invest some time to implement autofixes for any rules that we want, then no matter the style we will have awesome consistency prettifier and linter in one. ESLint is the right tool for such things. ESLint autofix works great here. I think the most important rule that we should implement autofix for is And everyone should use Just Prettier isn't the right tool. Tried it in last months. Both approaches - first linter than prettiefier and reversed first prettier then the linter - both not work well. ESLint is most awesome ecosystem in that community, for sure. And we should use it, everyone should use it as both Linter and Prettiefier/Beautifier/Formatter. It just need help. |
This comment has been minimized.
This comment has been minimized.
I fundamentally disagree with this. Prettier completely disregards input format and spits out in a consistent format while ESLint and tools around that attempt to preserve typed style & that is pretty much makes consistent styling impossible.
As we tried to adopt standard style we run into too many cases where ESLint was unable to fix things up.
Not in my experience there is ton of things it can not fix and there is also ton of flex in the way code can be formatted, and standard will accept. So at the end of the day we still have majority of comments in pulls about formatting, which defeats the purpose, to us anyway.
In my experience fixes actually produce awkward results in terms of formatting, my guess would be that is a reason.
You have not offered any convincing argument to support that claim, just your own opinion that ESLint is a way to go. Please try to offer more constructive input and offer some data to support claims.
I am not surprised given that prettier output does not follow stardardjs rules. By work is required I meant following @jlongster's suggestion to fork prettier to add an options for [standardjs][] rules, hopefully it would be possible to merge it back in. Can you share list of things that did not work.
It's cool that you feel that way, but saying everyone should use it is a bit too much. For flow typed projects ESLint has very little to offer other than enforcing formatting as type system deals with actual errors. And given that formatting rules are too flexible result is again, valuable engineering time is spend in discussing or comprehending code formatting. |
This comment has been minimized.
This comment has been minimized.
|
@Gozala We used a separate tool to do formatting in the past ( I think prettier is cool, especially if you want to always re-format code on every git check-in, but it's too aggressive for normal use. It will reformat even code that passes But I think we'll stick with eslint's
I'll also mention that the trend of each release of standard is to tighten up rules to prevent multiple ways of writing the same thing. There are many more formatting rules that will be added slowly in future releases. So issues like the ones you ran into should be caught in future releases once we tighten up those rules. |
feross
closed this
Mar 6, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@timoxley That's actually a neat solution for folks who prefer more aggressive regular formatting of their code. |
This comment has been minimized.
This comment has been minimized.
ArmorDarks
commented
Mar 19, 2017
That won't work, because Prettier and Standard rules will collide. It would be great if efforts could be unified and maintainers of boths libs would agree on same code style...
I think it's very strange to hear that from creator of lib, which actually aggressively enforces rules on developer. |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Mar 20, 2017
|
I think this might be one of those things we look back at in a year and be like, why did we cling on manually formatting the code. Auto standard ftw. |
This comment has been minimized.
This comment has been minimized.
ArmorDarks
commented
Mar 20, 2017
•
Yeap. I'm ready for this right now :D As a side information, about "love" between Standard and Prettier, I will just leave this link here facebook/create-react-app#1847, maybe someone has somthing meaningful to add. |
This comment has been minimized.
This comment has been minimized.
@ArmorDarks not a fan of your tone here, it could be mistaken as hostile; please show some moderation going forward. Thank you kindly |
This comment has been minimized.
This comment has been minimized.
ArmorDarks
commented
Mar 20, 2017
|
@yoshuawuyts If you read my conversation with Dan by following link above, you will see that I'm adept of Standard and defend it, thus I didn't mean to be hostile. However, yeap, I was sarcastic, because both libraries enforces aggressive rules, so it sounded like very strange and vague argument against when said by creator of one of those libs. |
This comment has been minimized.
This comment has been minimized.
|
@ArmorDarks I'm a fan of the concept of
In an ideal world, they'd adopt all the If you or someone else wants to look into this approach in more detail, I'm open to at least reviewing the PR. |
This comment has been minimized.
This comment has been minimized.
ArmorDarks
commented
Apr 8, 2017
|
Ah, @feross. nevermind my earlier replies. To make this happen we will need attitude to make compromises and changes from both and Standard, and Prettier communities, to unite efforts and focus on strongest points (linting with Standard and code formatting with Prettier) instead of continuing bikeshedding. I was hoping to make this happen, to help communities unite, but after pretty much aggressive replies of @gaearon against Standard here facebook/create-react-app#1847 and recently discovered regreatful issue #78 (which explains nature of @gaearon attitude toward Standard) started by @gaearon and supported by @jlongster (creator of Prettier) here #78, I have very little believe that this could happen. Not in this world, I guess. |
This comment has been minimized.
This comment has been minimized.
|
@ArmorDarks FWIW, I'm open to working with the Do you know if it's possible to configure |
This comment has been minimized.
This comment has been minimized.
gaearon
commented
Apr 13, 2017
|
cc @vjeux |
This comment has been minimized.
This comment has been minimized.
jlongster
commented
Apr 13, 2017
•
|
You can already use standard without its formatting rules by using https://www.npmjs.com/package/eslint-config-prettier, and then use prettier to format it. Users interested in this issue are mostly interested in getting the non-formatting rules. For standard using prettier by default, it's going to be hard, not because of any ill will on either sides, but because there is already a significant community behind both so changing the styles is going to force one of them to change a lot. I don't know what the answer is. If someone wants to pursue it we need to more concrete changes to evaluate it. Note that a large number of people prefer to run prettier in their editor frequently as they are coding (prettier by default is very fast, much faster than eslint, so it's very responsive), and do linting as a less frequent step. I think it makes sense to separate linting and formatting, and allow users to combine them how they want. |
This comment has been minimized.
This comment has been minimized.
jlongster
commented
Apr 13, 2017
•
|
Also, prettier's code wrapping (which is an integral part of why it produces good code) is always going to be a big change for the output of standard. There's no way we can make it so that our output is exactly the same as the current |
This comment has been minimized.
This comment has been minimized.
|
If we did this, we'd probably want to add a new
So, then users that want one canonical format could throw
The good news here is that |
feross
reopened this
Apr 13, 2017
This comment has been minimized.
This comment has been minimized.
kentcdodds
commented
Apr 13, 2017
|
Just thought I'd link to this: |
This comment has been minimized.
This comment has been minimized.
jlongster
commented
Apr 13, 2017
I think I'm a little confused what the goal is: do you want to take advantage of prettier's wrapping & forcing consistency on more general things (like function arguments), but still apply standard's whitespace rules? If so, that should be pretty easy: run prettier first and then Or are you all somehow wanting the output of standard to be the same as prettier, meaning it runs prettier as the last step? That seems harder because we would have to talk about all the differences and see if we can reconcile. I'm not sure I see the benefit of that since you could easily run Looks like I'm happy to continue talking about what potential integrations look like! |
This comment has been minimized.
This comment has been minimized.
|
Thinking out loud here... I think the goal of
// both styles are allowed by `standard`
const x = (z) => z
const y = z => zSince both styles are allowed by const x = z => z
const y = z => zBut this is okay, since the rewritten code is also valid Then after running So, it seems like in an ideal world, To get to this world, I think we'd need unify our style guides so that |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Apr 13, 2017
|
I think we want (I want) standard to automformat the code (such that all
standard codebases are identical, unambiguous). Maybe that just means I
should switch to prettier.
But Feross makes a good point - standard is designed to be human writable
and indeed very pleasant to write.
Feels like we should be able to converge the two, fudamentally, I mean cant
see why we need both prettier and standard. Im sure I (and anyone) could
get used to whatever slight variations of style each lib chooses. It's more
about the question of - should code style be enforced and unambiguous or
should we leave a bit of room for human interpretation (not sure which one
is better). The goal of "human writable" is great, but maybe at conflict
with "unambiguous".
…On Thu, 13 Apr 2017 at 21:30, James Long ***@***.***> wrote:
If we did this, we'd probably want to add a new standard --format flag
I think I'm a little confused what the goal is: do you want to take
advantage of prettier's wrapping & forcing consistency on more general
things (like function arguments), but still apply standard's whitespace
rules? If so, that should be pretty easy: run prettier first and then standard
--fix. Is that what standard --format could do?
Or are you all somehow wanting the output of standard to be the same as
prettier, meaning it runs prettier as the last step? That seems harder
because we would have to talk about all the differences and see if we can
reconcile. I'm not sure I see the benefit of that since you could easily
run standard --fix *after* prettier to tweak it to get all the current
rules (like a space after function name).
Looks like prettier-standard-formatter is runs prettier first and than standard
--fix which makes sense.
I'm happy to continue talking about what potential integrations look like!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#811 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AATzWIkMPFHv9-ssY2v7ORyuGYzFuwdoks5rvoXWgaJpZM4MSpCd>
.
|
This comment has been minimized.
This comment has been minimized.
jlongster
commented
Apr 13, 2017
•
|
@feross I see, thanks for explaining! I'm a little worried about both of the communities having to keep in sync and making sure that any changes need to be accepted by both, etc. But I actually think most of the things we'd change are not even whitespace-related or things that standard's formatting rules care about. Usually it's a bug with how things are laid out. Although.. that might not be true. A good example is that we are thinking of changing how we output ternaries. Right now we happen to output them as standard expects, actually. But we might change that. I think we're actually very in sync already. The biggest difference is the space after function name. I'm betting that you all don't want to change that, I don't think we're going to change that on prettier... as its a pretty frequent thing in the code. Not sure what we'd do about that specific case, but concerns about not being able to change the format still stands. Is there any reason it can't be |
This comment has been minimized.
This comment has been minimized.
Agreed! I think there's a real opportunity here, given a few compromises, to prevent further fragmentation in community conventions.
This is a fair point. But I think that if we wanted, we could each do a release where we change a rule or two and then we're totally in sync. Bam. Then we can recommend There are challenges, but this seems totally doable if both projects want to make it happen.
Your description of how But, then we don't get the huge win that would come from aligning our styles. Namely that it would be easy to switch from/to the different projects, |
This comment has been minimized.
This comment has been minimized.
jlongster
commented
Apr 13, 2017
|
Awesome. I gotta run but let's keep talking! Are you all really opinionated about the space after function name? fwiw we've been referencing the airbnb style guide to inform us (as one data point) of what is a popular style, and they don't use the space there. It also seems to be preferred by most people who use it. This is probably going to be the biggest sticking point between our styles, I'm guessing. |
This comment has been minimized.
This comment has been minimized.
jlongster
commented
Apr 13, 2017
|
Also our default style is semicolons, but we just added an option to not use semicolons, so we can do |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Apr 14, 2017
•
|
most noticeable thing for me is that prettier expands function arguments if >1 and i believe not makes code more readable but more bad. i 'm totally okey with that tobe only when >3.
as about the space after fn name, it's acceptable to relax the rule so there won't have breaking changes. |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Apr 14, 2017
|
btw, to clarify a bit about fn args expanding, i'm okey with if line is around 80 to do the expanding in multiple lines, even if the only one arg. sorry, im on phone |
This comment has been minimized.
This comment has been minimized.
|
I'd be up for helping to maintain a fork of prettier that adds the necessary options for making it compliant with Standard without having to run We could then create a tool that requires that fork, and exposes a nice cli, without any options, working like Potentially that could then be included in the Just an idea |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Oct 19, 2018
•
|
@LinusU that sounds good. I wonder if you've used
|
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Oct 19, 2018
|
If we did this, people that prefer prettier could continue using that, people that prefer raw eslint could continue using that, but standard would be for the rest of us - the linter rules we (the rest of us..) all agree to follow + a very powerful formatter. |
This comment has been minimized.
This comment has been minimized.
|
On Fri, Oct 19, 2018, 2:21 PM Linus Unnebäck ***@***.***> wrote:
I'd be up for helping to maintain a fork of prettier
Considering that tools such as prettier-standard and
prettier-standard-formatter already exist, can someone elaborate on the
possible need for direct integration with prettier itself?
Any comments on how existing tools such as prettier-standard and
prettier-standard-format compare?
I wonder if anyone might want to use prettier together with semistandard or
custom standard or eslint rules?
My understanding is:
* standard is a more simple combination of items of good practice based on
eslint
* prettier has a larger scope of making the code *look* better, hopefully
following at least some of the principles of good practice
I would favor the following:
* _document_ how standard could be used together with prettier in this
project
* Integration should be outside this project
* raise/promote an issue on prettier to provide more integrated support for
following standard, semistandard, custom eslint rules, etc.
… |
This comment has been minimized.
This comment has been minimized.
These packages basically first run It was a while since I last tried them out, but I remember having some problems with that approach, and it was also quite slow. |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Oct 19, 2018
|
Again, It's just a matter of whether the owners of What other technical challenges are there? One negative is increasing the size of standard with all of prettier.. But that's probably tolerable? |
This comment has been minimized.
This comment has been minimized.
kirillgroshkov
commented
Oct 30, 2018
|
Just saying that this thread and the possibility for the 2 biggest tools to merge (or at least be compatible with each other) is fantastic! For my team the deal-breaker is |
This comment has been minimized.
This comment has been minimized.
I think you meant I started a |
This comment has been minimized.
This comment has been minimized.
sheerun
commented
Jan 20, 2019
|
@feross While prettier definitely won't support standard.js formatting, I've updated prettier-standard to use prettierx fork for formatting. The formatting differences between One thing that is annoying is that @feross Would you be interested in using |
This comment has been minimized.
This comment has been minimized.
It there no way to configure eslint and prettierx so that they agree on whitespace? |
This comment has been minimized.
This comment has been minimized.
sheerun
commented
Jan 21, 2019
|
from my experience no, there are multiple quirks because prettier is more advanced than standard with understanding code and formatting whitespace with it. I think the best option is to get "close enough" and then switch standard to use prettier for whitespace formatting and eslint for everything else but whitespace formatting |
This comment has been minimized.
This comment has been minimized.
Discussed further in #927. Solving this would be a nice step towards consistency with Prettier formatting. (I did update the
I have mixed feelings about switching
I think it would be ideal to check and process the code using a series of plugins, like what can be done with eslint and what is generally done with Babel, keeping Prettier reformatting as an optional step. |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Jan 25, 2019
|
Hi.. I've been hanging out on this thread for a while and have recently been thinking more about this problem. Standard has been enourmously helpful in the last few years in all my projects. The two styles are slightly different, which is unfortunate. But standard is not just about code style, it's also about zero config experience, a really well curated set of eslint rules, less decision making. I've been wanting to get the best of both, prettier's formatting with standard's code quality checks and DX. I've just published a package https://github.com/KidkArolis/healthier that tries to help you combine the two. Hopefully it can be useful to some of you if you're ok with letting go off standard's style formatting rules. In the future, if standard somehow adopts prettier's formatter, that might be even better. But for now I will see if Healthier can fill that gap. |
This comment has been minimized.
This comment has been minimized.
NathanielHill
commented
Feb 25, 2019
|
So I've recently switched to The only way I can see getting that working is adding back Anyways, just wondering if anyone has gotten format on save and linting while typing working with |
This comment has been minimized.
This comment has been minimized.
sheerun
commented
Feb 26, 2019
|
You can use |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Feb 26, 2019
|
Healthier has both |
This comment has been minimized.
This comment has been minimized.
NathanielHill
commented
Feb 27, 2019
|
So, I think the ideal setup would be one npm module (+ one editor plugin) that gives you formatting on save and linting as you type - all with no configuration. Then use I've been using Long story short, I ended up going down a rabbit hole of inconsistencies between @KidkArolis Thanks for the awesome package, and great choice on the name Good bye |
This comment has been minimized.
This comment has been minimized.
NathanielHill
commented
Feb 27, 2019
|
It's a bummer that |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Feb 28, 2019
•
Same was here. But I switched around 1.5 year ago (after years of using Standard) to the @airbnb style - definitely liked it and it makes much more sense to me, cuz I always been a fan of a bit more strictness (pretty great considerations/practices and a lot lot rules). Looking from the perspective of a few years using both Airbnb+Prettier (~2y) and Standard (2y), I really think that tools like standard, xo and the others that appeared after them, isn't that great thing. It sounds and feels unnecessary stacking of tooling, APIs and deps. "Zero config". But you can have zero config with picking up basic Anyway, no bad feelings |
This comment has been minimized.
This comment has been minimized.
KidkArolis
commented
Feb 28, 2019
|
@tunnckoCore with airbnb, does airbnb code style rules not complain about prettier’s formatting? Or do you turn them off somehow? Re, “it’s probably great for someone who is junior-to-mid”, a strange way to classify this. Since so many many people and tools use standard who I wouldn’t call junior.. And I have been using standard 5+ years because of its ease of use, when you work on dozens of repos, the zero config approach shines, one dep, does it all, helps you catch the bugs, is not too strict so never complains about things that would get in the way. But admittedly, I actually never really tried airbnb, there’s just not enough time to try all the things :) |
This comment has been minimized.
This comment has been minimized.
NathanielHill
commented
Feb 28, 2019
|
@tunnckoCore I loved |
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
May 29, 2019
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
May 29, 2019
This comment has been minimized.
This comment has been minimized.
ArmorDarks
commented
May 29, 2019
|
Not a nice bot |
Gozala commentedMar 3, 2017
•
edited
@feross what do you think in terms of adopting prettier ? The reason I find it appealing is because in the process of adopting standardjs (see browserhtml/browserhtml#1271) we found out that it's too permissive and does not catch variety of awkward formatting options.
I think with a help of prettier standardjs could deliver promise of "JavaScript Standard Style". Unfortunately that would require some work prettier/prettier#736 to make prettier output standardjs compatible.