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

Epic: Trailing commas in TS/Flow #6198

Closed
duailibe opened this issue Jun 7, 2019 · 7 comments
Closed

Epic: Trailing commas in TS/Flow #6198

duailibe opened this issue Jun 7, 2019 · 7 comments
Labels
lang:flow Issues affecting Flow-specific constructs (not general JS issues) lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Milestone

Comments

@duailibe
Copy link
Member

duailibe commented Jun 7, 2019

This is an old problem and I thought I had an issue open to discuss this topic, but we should make a decision on this matter:

How do we handle trailing commas in different versions of Flow/TS?
Should we add flowXXX and tsX.X options?
Should we always support new trailing commas in "all" and treat "es5" as "none"?

cc @prettier/core

@duailibe duailibe added lang:flow Issues affecting Flow-specific constructs (not general JS issues) lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) status:needs discussion Issues needing discussion and a decision to be made before action can be taken labels Jun 7, 2019
@duailibe
Copy link
Member Author

duailibe commented Jun 7, 2019

Issues raised on this topic: #6197 #3722 #3662 #3313

@alexander-akait
Copy link
Member

alexander-akait commented Jun 7, 2019

Should we add flowXXX and tsX.X options?

I think yes, we planned same for php plugin, sometimes languages change syntax

Should we always support new trailing commas in "all" and treat "es5" as "none"?

To avoid breaking code we should considered:

  • all and tsX.X/flowXXX together (all + ts3.3 !== all +ts3.5 )
  • with none no problems
  • es5 was bad idea, i don't know here solution, maybe apply trailing comma for lower level (i.e. apply commas only for lower ts/flow version like we use es5 and lower ts/flow version)

@ikatyang
Copy link
Member

ikatyang commented Jun 7, 2019

  • Personally, I think we should replace --trailing-comma <none|es5|all> with --[no-]trailing-comma/--js-trailing-comma es5, but unfortunately there's no backward-compatible way to do it in the CLI since string flags would suddenly become part of filenames.
  • PHP plugin: any option that wants to extend the existing one should have their own name, --php-trailing-comma for example. (Since we do support sub-language formatting (embed), it's not possible to use the same name with different option.)

I meant the php-specific value (php5, php7.2) should have their own name (--php-trailing-comma) but the general value (all, none) can still be used as before (--trailing-comma). The --php-trailing-comma should take precedence over --trailing-comma in this plugin, something like:

function getPhpTrailingCommaValue(options): "all" | "php5" | "php7.2" | "none" {
  if (options.phpTrailingComma) return options.phpTrailingComma;
  if (options.trailingComma === "es5") return "none";
  return options.trailingComma;
}

Same thing can be applied to TS/Flow as well.

@duailibe duailibe added this to the 2.0 milestone Jun 7, 2019
@duailibe
Copy link
Member Author

duailibe commented Jun 7, 2019

@ikatyang your solution sounds reasonable. I'll investigate that for 2.0

@kachkaev
Copy link
Member

We can probably close this issue in favor of #11465

@nickmccurdy
Copy link
Member

I just noticed #3722 is still open. Should that be included with Prettier 3?

@fisker
Copy link
Member

fisker commented Feb 9, 2023

Fixed by #14085

@fisker fisker closed this as completed Feb 9, 2023
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:flow Issues affecting Flow-specific constructs (not general JS issues) lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. status:needs discussion Issues needing discussion and a decision to be made before action can be taken
Projects
None yet
Development

No branches or pull requests

6 participants