Svelte code is rejected because of adjacent elements
See original GitHub issuePrettier 1.19.1 Playground link
--parser babel
Input:
<svelte:head>
<title>Tic Tac Toe</title>
</svelte:head>
<h1>Tic Tac Toe</h1>
<button on:click={newGame}>New Game</button>
{#if message}
<h2>{message}</h2>
{/if}
<Board {game} clickCell={(x, y) => (game = game.click(x, y))} />
<style>
/* Styling goes here */
</style>
<script>
/* JavaScript goes here */
</script>
Output:
SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (5:1)
3 | </svelte:head>
4 |
> 5 | <h1>Tic Tac Toe</h1>
| ^
6 |
7 | <button on:click={newGame}>New Game</button>
8 |
Expected behavior: The Svelte file should not be considered JSX, and the code should be accepted and formatted correctly.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Can't figure out why <span> jumps to next line (svelte material ...
A solution is to use flexbox on the <Formfield> element. Instead of display:inline , try using display:flex -- that alone might fix your...
Read more >svelte | Yarn - Package Manager
Svelte is a new way to build web applications. It's a compiler that takes your declarative components and converts them into efficient JavaScript...
Read more >Module context / Sharing code • Svelte Tutorial
Module context / Sharing code • Svelte Tutorial. In all the examples we've seen so far, the <script> block contains code that runs...
Read more >About Queries | Testing Library
getBy... : Returns the matching node for a query, and throw a descriptive error if no elements match or if more than one...
Read more >rollup.js
Rollup is a module bundler for JavaScript which compiles small pieces of code ... It uses the new standardized format for code modules...
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
see https://github.com/prettier/prettier/issues/7762#issuecomment-599515317
We support JS in
<script>
tags. I think we might support SCSS in<style>
if it’s marked as such.