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

[JavaScript] Comments between ternary operator formatting result is ugly #16218

Open
ntnyq opened this issue Apr 11, 2024 · 2 comments
Open

[JavaScript] Comments between ternary operator formatting result is ugly #16218

ntnyq opened this issue Apr 11, 2024 · 2 comments
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:enhancement A potential new feature to be added, or an improvement to how we print something

Comments

@ntnyq
Copy link

ntnyq commented Apr 11, 2024

Prettier 3.2.5
Playground link

--parser typescript

Input:

const foobar = isFoo 
  ? 'foo'
  // This is foo
  : 'bar'

Output:

const foobar = isFoo
  ? "foo"
  : // This is foo
    "bar";

Expected output:

const foobar = isFoo 
  ? 'foo'
  // This is foo
  : 'bar'

Why?

The operator : won't mix with the comment. This is more clear.

@SirJosh1987
Copy link

Is this my fault

@ghost
Copy link

ghost commented Apr 13, 2024

Great idea to take into consideration but i think it should still be this way since it is what most people is used to by now

@sosukesuzuki sosukesuzuki added type:enhancement A potential new feature to be added, or an improvement to how we print something lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) type:enhancement A potential new feature to be added, or an improvement to how we print something
Projects
None yet
Development

No branches or pull requests

3 participants