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

Can we enable the dangling comma on this project? #3469

Closed
lipis opened this issue Dec 13, 2017 · 15 comments
Closed

Can we enable the dangling comma on this project? #3469

lipis opened this issue Dec 13, 2017 · 15 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:infra Issues about CI, publishing to npm, or similar

Comments

@lipis
Copy link
Member

lipis commented Dec 13, 2017

Because even though one line was added, two were deleted and that's confusing when reviewing.

screen shot 2017-12-13 at 11 39 30

Also if you would like to sort them, you would have to manually add the missing comma, because the there will be a syntax error if the last item will move in the middle.. (if someone will mention that these things are handled by Prettier 😃)

More reasons can be found here: https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8

@azz
Copy link
Member

azz commented Dec 13, 2017

Prettier should probably use Prettier's defaults...

@lipis
Copy link
Member Author

lipis commented Dec 13, 2017

That's what I thought.. but not really.. :) The default I guess comes based on popularity or what people wanted in a first place, but the world is evolving and maybe we can teach them the right way :P

Also if it's a hard requirement for this project to use the default values, let's change the default value :D Either case, having the dangling comma has more pros than cons..

@bakkot
Copy link
Collaborator

bakkot commented Dec 14, 2017

Please don't change the defaults without making a major version bump.

I don't see much reason for Prettier to always stick with the defaults, though, except those reasons that would apply to any other project (e.g. "use prettier's defaults" is the easiest rule which minimizes style bikeshedding).

@ikatyang ikatyang added the type:infra Issues about CI, publishing to npm, or similar label Dec 14, 2017
@lipis
Copy link
Member Author

lipis commented Dec 14, 2017

No I don't think that changing the default is the way to go.. Like I already mentioned.. there is no real need for Prettier to use the default.. we can adjust to what we want for the project.

@duailibe
Copy link
Member

Trying to make it clear: @lipis wants to change the Prettier settings we use for the Prettier codebase (i.e. only an internal thing)

@lipis
Copy link
Member Author

lipis commented Dec 14, 2017

Yes! I (hopefully more) want to enable the following on the Prettier codebase:

trailingComma: all

@azz
Copy link
Member

azz commented Dec 14, 2017

We certainly can't set it to all because we support node v4.

Prettier should be configuration free by default. Running Prettier on Prettier with Prettier's own defaults seems like it has more advantages. Don't want people to look at the Prettier source as an example and think that a config file is required.

@josephfrazier
Copy link
Collaborator

We certainly can't set it to all because we support node v4.

For what it's worth, node v4 will become EOL in April, so I imagine this might not be a blocker at that point.

Don't want people to look at the Prettier source as an example and think that a config file is required.

I'm not sure about the context of this, but Prettier did have it's own .prettierrc for a couple of weeks recently. This repo also has a .eslintrc.js that references prettier's rules. I'd (like to) think that new users would go to the website for guidance on how to get started with Prettier, rather than looking at this repo, especially since the README now links to the website instead of having the docs inline.


In general, I agree with @bakkot above: we shouldn't change the defaults without a major version bump, but I don't see an intrinsic reason why Prettier itself should use them. On the other hand, the benefits of trailing commas are pretty well-described (as in the OP, for instance).

@lipis
Copy link
Member Author

lipis commented Dec 14, 2017

Prettier is already using the proseWrap: never instead of the default preserve :)

@ikatyang
Copy link
Member

FYI, we changed back to use the default in #3395.

I don't mind to enable --trailingComma es5 at this point, but using the default can avoid something like #3385 as we often test issues via bin/prettier.js and forgot we have a .prettierrc 😂.

@josephfrazier
Copy link
Collaborator

I don't mind to enable --trailingComma es5 at this point, but using the default can avoid something like #3385 as we often test issues via bin/prettier.js and forgot we have a .prettierrc 😂.

Those are good points: we could use "es5" as a way to have more trailing commas without losing node v4 compatibility; and having a .prettierrc complicates testing because the tests aren't isolated (I also encountered this problem in #3255 (comment)).

However, since we're using eslint-plugin-prettier, we can just put the trailingComma rule in .eslintrc.js without affecting the behavior of bin/prettier.js on files in the repository. PR coming shortly :)

josephfrazier added a commit to josephfrazier/prettier that referenced this issue Dec 14, 2017
This addresses prettier#3469
as outlined in prettier#3469 (comment)

The corresponding formatting changes will be done separately for
clarity's sake.
josephfrazier added a commit to josephfrazier/prettier that referenced this issue Dec 14, 2017
This addresses prettier#3469
as outlined in prettier#3469 (comment)

The corresponding formatting changes will be done separately for
clarity's sake.
@josephfrazier josephfrazier added status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! status:needs discussion Issues needing discussion and a decision to be made before action can be taken labels Dec 14, 2017
@azz
Copy link
Member

azz commented Dec 14, 2017

Don't use eslint-plugin-prettier's config, that should be considered deprecated as it breaks formatters like Prettier-VSCode and Prettier-Atom which use the resolveConfig API.

@azz
Copy link
Member

azz commented Dec 14, 2017

I honestly think this is complete bikeshedding. I personally prefer trailing commas but that's not the point. The very reason this project exists is to remove discussion about code style, and this issue is doing the exact opposite on Prettier's own source code. Changing Prettier's own formatting to something that isn't the default will cause more discussion in other projects adopting Pretter. "Should we use the defaults or use Prettier's settings?"

josephfrazier added a commit to josephfrazier/prettier that referenced this issue Dec 14, 2017
@bakkot
Copy link
Collaborator

bakkot commented Dec 15, 2017

Alternative proposal: do nothing for now, and then when Node 4 hits EOL, change the default to all and do a major version bump. It sounds like we're mostly agreed that trailing commas are the right way to go, and that we want people to be able to use prettier and get good output with no configuration, so... that would be the right default, yes?

Downside is that it would mean people writing untranspiled code for non-current browsers and Node would start needing to configure prettier. And the major version bump, of course.

EDIT: never mind; node 6 also doesn't support trailing commas in functions, and it's not EOL until 2020.

I guess we could switch to es5 whenever we wanted, if we were willing to do a major version bump.

@azz
Copy link
Member

azz commented Dec 16, 2017

Going to close this and recommend discussion in #3503

@azz azz closed this as completed Dec 16, 2017
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jul 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:has pr Issues with an accompanying pull request. These issues will probably be fixed soon! status:needs discussion Issues needing discussion and a decision to be made before action can be taken type:infra Issues about CI, publishing to npm, or similar
Projects
None yet
Development

No branches or pull requests

6 participants