Visitar URL original
Fix embedded HTML template expression idempotency by deepakganesh78 · Pull Request #19722 · prettier/prettier · GitHub
Skip to content

Fix embedded HTML template expression idempotency - #19722

Closed
deepakganesh78 wants to merge 2 commits into
prettier:mainfrom
deepakganesh78:fix-19518-embedded-template-idempotency
Closed

deepakganesh78 wants to merge 2 commits into
prettier:mainfrom
deepakganesh78:fix-19518-embedded-template-idempotency

Conversation

@deepakganesh78

@deepakganesh78 deepakganesh78 commented Jul 25, 2026 •

Copy link
Copy Markdown

Description

Fixes #19518.

Embedded HTML template expressions were aligned to their indentation in the original source even though the HTML printer can move the interpolation. Multiline JavaScript inside a moved interpolation therefore used stale absolute indentation and needed another Prettier pass to stabilize.

This change lets embedded HTML control expression indentation while preserving the existing source-alignment behavior for regular, CSS, GraphQL, and Markdown template literals. Regression coverage includes the reported nested .map()/ternary case and JavaScript embedded in a <pre> element.

Validation:

  • FULL_TEST=1 yarn jest tests/format/js/multiparser-html --runInBand
  • yarn eslint src/language-js/embed/html.js src/language-js/print/template-literal.js tests/format/js/multiparser-html/html-template-literals.js
  • yarn prettier src/language-js/embed/html.js src/language-js/print/template-literal.js tests/format/js/multiparser-html/html-template-literals.js tests/format/js/multiparser-html/__snapshots__/format.test.js.snap --check
  • yarn lint:format-test
  • yarn lint:typecheck
  • git diff --check

Checklist

  • 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).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.
  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

deepakganesh78 and others added 2 commits July 25, 2026 16:09
Avoid preserving source indentation for expressions whose placement is controlled by the embedded HTML printer. Add nested template and preformatted-content regressions for prettier#19518.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 67efa31
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6a64928fc749b00008f65907
😎 Deploy Preview https://deploy-preview-19722--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 25, 2026

Copy link
Copy Markdown

✅ Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 55add0b
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/6a6492b86d677a00080c39a2
😎 Deploy Preview https://deploy-preview-19722--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/plugin-hermes@19722.tgz
yarn add https://pkg.pr.new/@prettier/plugin-oxc@19722.tgz
yarn add https://pkg.pr.new/@prettier/plugin-yuku@19722.tgz
yarn add https://pkg.pr.new/prettier@19722.tgz

commit: 55add0b

@fisker fisker mentioned this pull request Jul 26, 2026
4 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded template-literal formatting is not idempotent for nested .map() inside a ternary (regression in 3.9.0)

1 participant