Skip to content

[2.9.2] Difference with Prettier for JS #891

Closed

Description

@boris-petrov

Prettier-Java 2.9.2

Playground link

# Options (if any):
--print-width 100

Input:

var future = recognizer instanceof SpeechRecognizer
  ? speechRecognizer.stopContinuousRecognitionAsync()
  : recognizer.stopContinuousRecognitionAsync();

Output:

var future = recognizer instanceof SpeechRecognizer
	? speechRecognizer.stopContinuousRecognitionAsync()
	: recognizer.stopContinuousRecognitionAsync();

Expected behavior:

var future =
  recognizer instanceof SpeechRecognizer
    ? speechRecognizer.stopContinuousRecognitionAsync()
    : recognizer.stopContinuousRecognitionAsync();

Prettier for JS

Activity

  1. jtkiesel commented on May 20, 2026

    @jtkiesel
    Contributor

    Interesting, it seems Prettier JS allows ternaries with "simple" conditionals (like a single boolean variable) to be printed like our plugin does, but not more complex ones. I will have to take a look at their heuristic to replicate their behavior.

  2. boris-petrov commented on May 20, 2026

    @boris-petrov
    Author

    I don't think it's worth investing time in this. I'm fine with you just choosing one variant and sticking with it. I don't see a reason to have two different types of printing for the (almost) same type of code. Why complicate things? So for me this issue can be closed. I'll leave the decision to you. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions