Skip to content

Latest commit

 

History

History
128 lines (96 loc) · 2.92 KB

CHANGELOG.unreleased.md

File metadata and controls

128 lines (96 loc) · 2.92 KB
  • JavaScript: Do not format functions with arguments as react hooks (#5778 by @SimenB)

    The formatting added in Prettier 1.16 would format any function receiving an arrow function and an array literal to match React Hook's documentation. Prettier will now format this the same as before that change if the arrow function receives any arguments.

    // Input
    ["red", "white", "blue", "black", "hotpink", "rebeccapurple"].reduce(
      (allColors, color) => {
        return allColors.concat(color);
      },
      []
    );
    
    // Output (Prettier stable)
    ["red", "white", "blue", "black", "hotpink", "rebeccapurple"].reduce((
      allColors,
      color
    ) => {
      return allColors.concat(color);
    }, []);
    
    // Output (Prettier master)
    ["red", "white", "blue", "black", "hotpink", "rebeccapurple"].reduce(
      (allColors, color) => {
        return allColors.concat(color);
      },
      []
    );
  • JavaScript: Add necessary parentheses for decorators (#5785 by @ikatyang)

    Parentheses for decorators with nested call expressions are optional for legacy decorators but they're required for decorators in the current proposal.

    // Input
    class X {
      @(computed().volatile())
      prop
    }
    
    // Output (Prettier stable)
    class X {
      @computed().volatile()
      prop
    }
    
    // Output (Prettier master)
    class X {
      @(computed().volatile())
      prop
    }
  • MDX: Correctly recognize inline JSX (#5783 by @ikatyang)

    Previously, some inline JSXs are wrongly recognized as block HTML/JSX, which causes unexpected behaviors. This issue is now fixed.

    <!-- Input -->
    _foo <InlineJSX /> bar_
    
    <!-- Output (Prettier stable) -->
    _foo
    
    <InlineJSX /> bar_
    
    <!-- Output (Prettier master) -->
    _foo <InlineJSX /> bar_