Skip to content

fix(css-in-js) Keep newlines in CSS-in-JS Templates (Fixes: #5147)#5240

Merged
lipis merged 5 commits intoprettier:masterfrom
onurtemizkan:fix/js/do-not-join-template-element-content
Nov 1, 2018
Merged

fix(css-in-js) Keep newlines in CSS-in-JS Templates (Fixes: #5147)#5240
lipis merged 5 commits intoprettier:masterfrom
onurtemizkan:fix/js/do-not-join-template-element-content

Conversation

@onurtemizkan
Copy link
Copy Markdown
Contributor

Fixes: #5147

Keep newlines after CSS-in-JS quasi-literal substitutes.

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.

Copy link
Copy Markdown
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job

\`;

styled.span\`
\${foo}: \${bar};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks we insert unnecessary semicolon, need fix it

\`;

styled.span\`
\${foo}: \${bar};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also semicolon was inserted 😞

Copy link
Copy Markdown
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need fix ; cases

@onurtemizkan
Copy link
Copy Markdown
Contributor Author

@evilebottnawi updated 😊

Copy link
Copy Markdown
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job

@alexander-akait
Copy link
Copy Markdown
Member

@onurtemizkan Looks i find one strange problem, maybe not related, maybe related, will be great if you investigate.

Input:

export const FlexBox = styled.div`
  ${$var}

  > * {
      width: ${p => (p.howManyPerRow ? `${100 / p.howManyPerRow}%` : 'auto')};
  }
`

Output:

export const FlexBox = styled.div`
  ${$var}

  > * {
    width: ${p => (p.howManyPerRow ? `${100 / p.howManyPerRow}%` : "auto")};
  }
`;

All fine. But:

Input:

export const FlexBox = styled.div`
    ${$var}

    > * {
        width: ${p => (p.howManyPerRow ? `${100 / p.howManyPerRow}%` : 'auto')};
    }
`

Output:

export const FlexBox = styled.div`
  ${$var}

    > * {
    width: ${p => (p.howManyPerRow ? `${100 / p.howManyPerRow}%` : "auto")};
  }
`;

> * have extra indent

@onurtemizkan
Copy link
Copy Markdown
Contributor Author

@evilebottnawi Sure, checking.

@lydell
Copy link
Copy Markdown
Member

lydell commented Oct 25, 2018

@onurtemizkan Did you find anything? Would be awesome to get this into the next release. I guess we could merge as-is, too.

@onurtemizkan
Copy link
Copy Markdown
Contributor Author

onurtemizkan commented Oct 25, 2018

@lydell, I haven't found it yet. Let's merge this and I'll create another issue to continue if it's ok.

@lipis
Copy link
Copy Markdown
Member

lipis commented Nov 1, 2018

Shall we take this in..?

@alexander-akait
Copy link
Copy Markdown
Member

@lipis feel free to merge, problem with indent should be solved in other PR

@lipis lipis merged commit f6d8be8 into prettier:master Nov 1, 2018
@lipis lipis added this to the 1.15 milestone Nov 1, 2018
@lipis lipis mentioned this pull request Nov 1, 2018
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants