Skip to content

Two comments straight after each other breaks formatting and swaps content by accident #3532

@kripod

Description

@kripod

Prettier 1.9.2
Playground link

Input:

import React from 'react';

/*
import styled from 'react-emotion';

const AspectRatioBox = styled.div`
  &::before {
    content: '';
    width: 1px;
    margin-left: -1px;
    float: left;
    height: 0;
    padding-top: ${props => 100 / props.aspectRatio}%;
  }

  &::after {
    /* To clear float *//*
    content: '';
    display: table;
    clear: both;
  }
`;
*/

const AspectRatioBox = ({
  aspectRatio,
  children,
  ...props
}) => (
  <div
    className={`height: 0;
  overflow: hidden;
  padding-top: ${props => 100 / props.aspectRatio}%;
  background: white;
  position: relative;`}
  >
    <div>{children}</div>
  </div>
);

export default AspectRatioBox;

Output:

import React from "react"; /*
    content: '';
    display: table;
    clear: both;
  }
`;
*/

/*
import styled from 'react-emotion';

const AspectRatioBox = styled.div`
  &::before {
    content: '';
    width: 1px;
    margin-left: -1px;
    float: left;
    height: 0;
    padding-top: ${props => 100 / props.aspectRatio}%;
  }

  &::after {
    /* To clear float */ const AspectRatioBox = ({
  aspectRatio,
  children,
  ...props
}) => (
  <div
    className={`height: 0;
  overflow: hidden;
  padding-top: ${props => 100 / props.aspectRatio}%;
  background: white;
  position: relative;`}
  >
    <div>{children}</div>
  </div>
);

export default AspectRatioBox;

Expected behavior:

The comments after /**/ should not appear at the beginning of the first comment, but at the end of the second original comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:commentsIssues with how Prettier prints commentsarea:idempotencyIssues with re-printing Prettier’s outputlang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions