Skip to content

experimentalTernaries duplicates comment in array #18944

@zsakowitz

Description

@zsakowitz

Prettier v3.8.1
Playground link

--parser babel
--tab-width 4
--no-semi
--experimental-ternaries

Input:

condition ? ifTrue
: [
      // Hello, world!
  ]

Output:

condition ? ifTrue
    // Hello, world!
: (
    [
        // Hello, world!
    ]
)

Expected output:

condition ? ifTrue
: [
      // Hello, world!
  ]

Why?
Prettier should not duplicate the comment. I don't really have any specific expected output (other than preserving the fact that the comment is only written once), although wrapping the array in parentheses seems unnecessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JS

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions