FG
💻 Software🛠️ Developer Tools

Linebreaks weirdly in long ES6 template strings with expressions

Freshalmost 2 years ago
Mar 14, 20260 views
Confidence Score79%
79%

Problem

Prettier 1.8.2 Playground link [code block] Input: [code block] Output: [code block] Expected behavior: I would prefer a long string to _not_ get split into multiple lines, even if it contains expressions. When there are no expressions, Prettier correctly lets a long string go beyond the `print-width` limit. I can't decide if this is a bug or a personal preference, but it's been creating weird hard to read code in our codebase. We can clean most of it up by simplifying our expressions, but there's only so short we can go.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
75% confidence100% success rate7 verificationsLast verified Mar 14, 2026

Solution: Linebreaks weirdly in long ES6 template strings with expressions

Low Risk

I'd say a lot of people, including myself, could dig an option that reverts to previous behaviour i.e. rule to disable formatting template literals completely e.g. ignoreTemplateLiterals: true. Does this exist already? Any reason this would be a problem?

75

Trust Score

7 verifications

100% success
  1. 1

    I'd say a lot of people, including myself, could dig an option that reverts to p

    I'd say a lot of people, including myself, could dig an option that reverts to previous behaviour i.e. rule to disable formatting template literals completely e.g. ignoreTemplateLiterals: true.

  2. 2

    Does this exist already? Any reason this would be a problem?

    Does this exist already? Any reason this would be a problem?

Validation

Resolved in prettier/prettier GitHub issue #3368. Community reactions: 34 upvotes.

Verification Summary

Worked: 7
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prettierformattingjavascriptstatus:needs-discussionlang:javascriptlocked-due-to-inactivityarea:template-literals