fix(docs): wrap adjacent JSX elements in fragments for Prettier compat#42389
fix(docs): wrap adjacent JSX elements in fragments for Prettier compat#42389pierluigilenoci wants to merge 3 commits intotwbs:mainfrom
Conversation
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>
|
cc @julien-deramond @mdo @louismaximepiton — these are the 4 Astro files that fail |
|
Thanks to your PR, I spotted that we haven't enabled I've made the changes in #42390. Maybe this PR, when rebased, can be closed as I'm not sure why you add to modify other files in this PR. Is there an issue in our conf? |
|
Thanks @julien-deramond — you're right, enabling |
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
site/src/components/head/Head.astro<Stylesheet>+<ScssProd.default>in<>...</>site/src/layouts/DocsLayout.astro<button>+<strong>+<hr>+<div>in<>...</>site/src/components/shortcodes/Code.astro(<></>)withnullsite/src/components/head/ScssProd.astroMotivation
These files contain adjacent JSX elements inside conditional expressions without a wrapping fragment, which is invalid JSX and causes
prettier-plugin-astroto error out. After this fix,prettier --check sitepasses on all Astro files.Test plan
npx prettier --plugin prettier-plugin-astro -c <4 files>— passes