Code is formatted wrongly, breaking strings
See original GitHub issueWhen I format the following code:
<div class="details-header">
<div class="details-title">{$t('details.title')}</div>
<div class="more-info" on:click="toggleTooltips()">
{#if showTooltips}
<Icon
icon={{
name: 'close',
className: 'text-size-normal material-icons align-middle text-color-red'
}}
/>
{:else}
<Icon
icon={{
name: 'help_outline',
className: "text-size-normal material-icons align-middle text-color-red"
}}
/>
{/if}
</div>
</div>
the result is broken – notice the split string in the 4th line, the one starting with text-size-normal material-icons
– part of the text goes into the next line, causing a JavaScript error.
<div class="details-header">
<div class="details-title">{$t('details.title')}</div>
<div class="more-info" on:click="toggleTooltips()">
{#if showTooltips} <Icon icon={{ name: 'close', className: 'text-size-normal material-icons
align-middle text-color-red' }} /> {:else} <Icon icon={{ name: 'help_outline', className:
"text-size-normal material-icons align-middle text-color-red" }} /> {/if}
</div>
</div>
I’m using the latest version of Prettier (github:prettier/prettier) plus the 1.1.0 version of prettier-plugin-svelte
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Black incorrectly formatting code - output has lines with more ...
Run Black on it with no arguments. Observe that nothing happens, even though the first line has 125 characters and so should be...
Read more >Improperly formatted string arguments - AWS Documentation
Format strings appropriately for their argument types. For example, use %d , not %s , for integers. This ensures locale-sensitive formatting. Detector ID....
Read more >Format String Bugs - The Amazing King
By now, its time for a break from buffer overflows. In this tutorial, we'll be discussing a different sort of vulnerability called format...
Read more >How can I break up this long line in Python? - Stack Overflow
It's not a bad practice to define your longer strings outside of the code that uses them. It's a way to separate data...
Read more >Formatting errors - Loco - Translation
Incorrectly formatted strings can cause fatal errors under PHP 8. This is likely to be a mistake in the translation, rather than in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this (the string line breaking) has been resolved; I can’t reproduce it. The comment by @nickarora seems to refer to an unrelated issue.
I’d propose closing this issue.
We are definitely experiencing this:
Before formatting:
after
prettier config:
How can we prevent quotes from wrapping attributes when we are passing a variable or object to a component?
edit: nevermind – it’s caused by this setting:
"svelteStrictMode": true,