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

Why the options are not consistent with `prettier` core? #428

Closed
JounQin opened this issue Nov 8, 2019 · 8 comments
Closed

Why the options are not consistent with `prettier` core? #428

JounQin opened this issue Nov 8, 2019 · 8 comments

Comments

@JounQin
Copy link

@JounQin JounQin commented Nov 8, 2019

As title.

I tried singleQuote: false but failed, and I found it was named as preferSingleQuotes, why???

@kddeisz

This comment has been minimized.

Copy link
Member

@kddeisz kddeisz commented Nov 8, 2019

Sorry about the confusion!

If they were the same option, you would not be able to have both single quotes in Ruby and double quotes in JavaScript. Also, the JavaScript ones have more options that don't make sense in a Ruby context. So I've had to differentiate them. I've also gone with "prefer" since in some cases you have to use double quotes (for interpolation), so it means something slightly different.

@kddeisz kddeisz closed this Nov 8, 2019
@JounQin

This comment has been minimized.

Copy link
Author

@JounQin JounQin commented Nov 8, 2019

@kddeisz No, prettier supports overrides option so different configurations for different files are definitely possible and should not use different option name.

@JounQin

This comment has been minimized.

Copy link
Author

@JounQin JounQin commented Nov 8, 2019

@JounQin

This comment has been minimized.

Copy link
Author

@JounQin JounQin commented Nov 8, 2019

And also, the default option value should not be different with prettier itself IMO.

@kddeisz

This comment has been minimized.

Copy link
Member

@kddeisz kddeisz commented Nov 8, 2019

Okay a couple of things to respond to here. Yes, prettier supports overrides, but that means that for people to configure the ruby plugin, they'd have to override every type of ruby file in their config instead of just changing one option. Not a very good user experience there.

Second of all, some of the options don't even make sense for ruby. For example, prettier has a trailing commas option, which could potentially match up with ruby's, but one of the options for configuration is "es5", which means nothing in the context of Ruby. So they would again have to go and override everything and it would be very confusing.

Finally, as for matching up to the prettier defaults, the only one that it makes sense for that is quotes. In this case, for the prettier plugin I've decided to go with single quotes if you don't need interpolation and double if you do, which matches up with rubocop and rufo standard configuration. That's what the ruby community has generally settled on for "most popular". While that doesn't match up with prettier's default, I think it makes more sense to defer to the ruby community than the javascript community when configuring a ruby formatter, regardless of which language is actually doing the formatting. I appreciate your opinion on this, but the quotes default is not going to change.

@JounQin

This comment has been minimized.

Copy link
Author

@JounQin JounQin commented Nov 8, 2019

@kddeisz

but that means that for people to configure the ruby plugin, they'd have to override every type of ruby file in their config instead of just changing one option

{
  "overrides": [
    {
      "files": "*.rb",
      "options": {}
    }
  ]
}

Is that really complicated? And if all plugins add a new option instead of extending core's, why overrides option is even provided?

Now that plugin-ruby has been an official prettier plugin, it should lead the community to use overrides instead of opposing. It's very confusing for other prettier plugin authors like me.

Second of all, some of the options don't even make sense for ruby.

Again, overrides should be the only solution in this case.

About quotes, I'm fine to have different default with core. Actually I'm a newbie in ruby community who prefer single quotes for all files but just using Homebrew then I have to learn some basic ruby. Homebrew audition prefers double quotes, that's why I'm confused why this plugin prefers single.

So it seems that Homebrew prefers different quote style with rubocop and rufo standard configuration.

@JounQin

This comment has been minimized.

Copy link
Author

@JounQin JounQin commented Nov 10, 2019

@kddeisz Any further discussion?

@kddeisz

This comment has been minimized.

Copy link
Member

@kddeisz kddeisz commented Nov 12, 2019

Thanks for the input @JounQin. I'll keep it in mind going forward. I'm going to stick with the options I've configured for now, but I'll look into what it would mean to go entirely with the overrides option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.