question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

odd output for template literals

See original GitHub issue

given the following code:

insertRule(`*, *:before, *:after {
  box-sizing: inherit;
}`)

I get the following output:

insertRule(
  `*, *:before, *:after {
  box-sizing: inherit;
}`,
)

The formatting of the last two lines seems odd to me. I’m not sure why a comma is added or why the line with the closing bracket is on the same indentation as the closing parenthesis.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
techniqcommented, Mar 4, 2017

I thought the formatting for an optional styled-component rule was a little odd (although not terrible), but thought I’d throw another template literal example here to consider. This one has nested template literals.

const Wrapper = styled.div`
  padding-top: 64px;
  padding-left: 8px;
  padding-right: 8px;
  transition: margin .3s;

  ${({sidebar}) => sidebar.docked && sidebar.open && css`
    margin-left: ${sidebar.width}px
  `}
`;

formats to

const Wrapper = styled.div`
  padding-top: 64px;
  padding-left: 8px;
  padding-right: 8px;
  transition: margin .3s;

  ${({ sidebar }) => sidebar.docked &&
  sidebar.open &&
  css`
    margin-left: ${sidebar.width}px
  `}
`;
1reaction
j-f1commented, Apr 8, 2018

@hundsim This issue should be fixed. If you’re having formatting issues, please open a new issue and fill out the template so we can more easily track them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick ( ` ) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Inadvisable template literal tricks
Introduced in ES2015, template strings are a new kind of JavaScript string. ... and passes in the tagged string as an odd arrangement...
Read more >
Getting weird error when concatenating template-literals
The output should just be a string that I can insert into the document. Any help would be appreciated. javascript · html ·...
Read more >
Template Literals in JavaScript: The Complete Guide
Template literals are, as the name suggests, designed to create templates with ... Demystifying the strange but incredibly practical syntax ... The output:...
Read more >
ES6 Template Literals: Techniques and Tools - SitePoint
Evaluating Expressions in Template Strings ... Template literals also solve another problem: they can evaluate variables within the string. The ${ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found