Skip to content

fix(docs): wrap adjacent JSX elements in fragments for Prettier compat#42389

Closed
pierluigilenoci wants to merge 3 commits intotwbs:mainfrom
pierluigilenoci:fix/astro-jsx-fragments
Closed

fix(docs): wrap adjacent JSX elements in fragments for Prettier compat#42389
pierluigilenoci wants to merge 3 commits intotwbs:mainfrom
pierluigilenoci:fix/astro-jsx-fragments

Conversation

@pierluigilenoci
Copy link
Copy Markdown
Contributor

Summary

Fixes 4 Astro files that caused Prettier's Astro parser to fail with SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag.

Changes

File Fix
site/src/components/head/Head.astro Wrap <Stylesheet> + <ScssProd.default> in <>...</>
site/src/layouts/DocsLayout.astro Wrap <button> + <strong> + <hr> + <div> in <>...</>
site/src/components/shortcodes/Code.astro Replace empty fragment (<></>) with null
site/src/components/head/ScssProd.astro Reformatted only (no logic change)

Motivation

These files contain adjacent JSX elements inside conditional expressions without a wrapping fragment, which is invalid JSX and causes prettier-plugin-astro to error out. After this fix, prettier --check site passes on all Astro files.

Test plan

  • npx prettier --plugin prettier-plugin-astro -c <4 files> — passes
  • No functional changes — only JSX structure and formatting

pierluigilenoci and others added 2 commits May 2, 2026 23:12
Astro files with adjacent JSX elements in conditional expressions
caused Prettier's Astro parser to fail with "Adjacent JSX elements
must be wrapped in an enclosing tag" errors.

- Head.astro: wrap Stylesheet + ScssProd in <>...</>
- DocsLayout.astro: wrap button + strong + hr + div in <>...</>
- Code.astro: replace empty fragment (<></>) with null
- ScssProd.astro: reformatted (no logic change)

Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

cc @julien-deramond @mdo @louismaximepiton — these are the 4 Astro files that fail prettier --check due to adjacent JSX elements not wrapped in fragments. Minimal fix, no logic changes.

@julien-deramond
Copy link
Copy Markdown
Member

Thanks to your PR, I spotted that we haven't enabled prettier-plugin-astro in our Prettier config 🙃

I've made the changes in #42390. Maybe this PR, when rebased, can be closed as npm run docs-prettier-check doesn't raise any errors.

I'm not sure why you add to modify other files in this PR. Is there an issue in our conf?

@pierluigilenoci
Copy link
Copy Markdown
Contributor Author

Thanks @julien-deramond — you're right, enabling prettier-plugin-astro in #42390 was the proper fix. After rebasing, the formatting issues are gone without needing the fragment wrappers. Closing this as superseded. Appreciate the quick turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants