Skip to content

wrong indent (tab width) when using ternary in jsx #3384

Closed

Description

@brikou

Prettier 1.7.4
Playground link

--print-width 40
--tab-width 4

Input:

const Foo = () => (
    <div>
        {foo === null
            ? ""
            : foo === true
              ? "Yes"
              : "No"}
    </div>
);

Output:

const Foo = () => (
    <div>
        {foo === null
            ? ""
            : foo === true
              ? "Yes"
              : "No"}
    </div>
);

Expected behavior:

 const Foo = () => (
     <div>
         {foo === null
             ? ""
             : foo === true
-              ? "Yes"
-              : "No"}
+               ? "Yes"
+               : "No"}
     </div>
 );

BTW thank you all!

Activity

  1. lydell commented on Dec 3, 2017

    @lydell
    Member

    My guess is that only the “align with two spaces in ternaries” thing is done here, and we forgot to indent. Most tests use 2-space indentation, so this probably slipped through because of that...

  2. brikou commented on Dec 3, 2017

    @brikou
    Author

    @lydell great it should be easy to fix then :)

  3. azz commented on Dec 3, 2017

    @azz
    Member

    Similar to #2771

  4. added
    lang:jsx
    on Dec 7, 2017
  5. added
    status:has pr
    lang:javascript
    and removed
    lang:jsx
    on Jan 15, 2018
  6. added
    locked-due-to-inactivity
    on Jul 6, 2018
  7. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  8. added theissue type on Mar 3, 2025
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

    lang:javascriptlocked-due-to-inactivitystatus:has pr

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions