Skip to content

Nested ternaries aren't very pleasant to look at #3018

@rye

Description

@rye

Prettier 1.7.4
Playground link

Input:

const platformString =
  Platform.OS == 'ios'
    ? 'iOS'
    : Platform.OS == 'android' ? 'Android' : 'unknown'

Output:

const platformString =
  Platform.OS == "ios"
    ? "iOS"
    : Platform.OS == "android" ? "Android" : "unknown";

Expected behavior:

const platformString =
  Platform.OS == "ios"
    ? "iOS"
    : Platform.OS == "android" 
      ? "Android" 
      : "unknown";

(Or something like this.)

Metadata

Metadata

Assignees

Labels

lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions