Files
test-repo/changelog_unreleased/javascript/9559.md
T
Alex RattrayandAlex Rattray f25a592f57 Add indentation back to nested ternaries (#9559)
* Add indentation back to nested ternaries (except JSX)

* Add a real-world test case

* Add changelog entry

---------

Co-authored-by: Alex Rattray <rattrayalex@stripe.com>
2023-09-24 15:13:00 -04:00

585 B

Add indentation back to nested ternaries (#9559 by @rattrayalex)

// Input
const message =
  i % 3 === 0 && i % 5 === 0
    ? "fizzbuzz"
  : i % 3 === 0
    ? "fizz"
  : i % 5 === 0
    ? "buzz"
    : String(i);


// Prettier stable
const message =
  i % 3 === 0 && i % 5 === 0
    ? "fizzbuzz"
    : i % 3 === 0
    ? "fizz"
    : i % 5 === 0
    ? "buzz"
    : String(i);

// Prettier main
const message =
  i % 3 === 0 && i % 5 === 0
    ? "fizzbuzz"
    : i % 3 === 0
      ? "fizz"
      : i % 5 === 0
        ? "buzz"
        : String(i);