Skip to content

✂prettier:content✂="". SvelteKit Prettier bug. #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
timscodebase opened this issue Oct 7, 2024 · 2 comments
Open

✂prettier:content✂="". SvelteKit Prettier bug. #466

timscodebase opened this issue Oct 7, 2024 · 2 comments

Comments

@timscodebase
Copy link

timscodebase commented Oct 7, 2024

Why does prettier keep adding ✂prettier:content✂="" to my head scripts.

Before

<Partytown
	script={`
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2145750142271743" ="anonymous">{}</script>
        <meta name="google-adsense-account" content="ca-pub-2145750142271743" />
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2145750142271743" crossorigin="anonymous">{}</script>
	<script async src="https://www.googletagmanager.com/gtag/js?id=G-FZH87M6DDV">
	</script>

	<script>
		window.dataLayer = window.dataLayer || []

		function gtag() {
			dataLayer.push(arguments)
		}

		gtag('js', new Date())
		gtag('config', 'G-FZH87M6DDV')
	</script>
`}
></Partytown>

After

<Partytown
	script={`
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2145750142271743"
     crossorigin="anonymous" ✂prettier:content✂="" ✂prettier:content✂="e30=">{}</script>
<meta name="google-adsense-account" content="ca-pub-2145750142271743" />
	<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2145750142271743"
     crossorigin="anonymous" ✂prettier:content✂="">{}</script>
	<script async src="https://www.googletagmanager.com/gtag/js?id=G-FZH87M6DDV">
	</script>
	<script>
		window.dataLayer = window.dataLayer || []

		function gtag() {
			dataLayer.push(arguments)
		}

		gtag('js', new Date())
		gtag('config', 'G-FZH87M6DDV')
	</script>
`}
></Partytown>
@1muen
Copy link

1muen commented Feb 5, 2025

Same here with

<svelte:head>
    {@html `
        <script
            type="text/javascript"
            src="${env.PUBLIC_CDN_URL}/office.js"
        ></script>`}
</svelte:head>

turns into

<svelte:head>
    {@html `
        <script
            type="text/javascript"
            src="${env.PUBLIC_CDN_URL}/office.js"
         ✂prettier:content✂="">{}</script>`}
</svelte:head>

@MS90D3V
Copy link

MS90D3V commented Mar 12, 2025

<script lang="ts">
	import { Footer, Util } from '$lib';
	import { getCurrentWebview } from '@tauri-apps/api/webview';

	getCurrentWebview()
		.onDragDropEvent((event) => Util.listFilesInDirectory(event.payload))
		.then((value) => console.log(value));
</script>

Turns into

<script lang="ts" ✂prettier:content✂="CglpbXBvcnQgeyBGb290ZXIsIFV0aWwgfSBmcm9tICckbGliJzsKCWltcG9ydCB7IGdldEN1cnJlbnRXZWJ2aWV3IH0gZnJvbSAnQHRhdXJpLWFwcHMvYXBpL3dlYnZpZXcnOwoKCWdldEN1cnJlbnRXZWJ2aWV3KCkKCQkub25EcmFnRHJvcEV2ZW50KChldmVudCkgPT4gVXRpbC5saXN0RmlsZXNJbkRpcmVjdG9yeShldmVudC5wYXlsb2FkKSkKCQkudGhlbigodmFsdWUpID0+IGNvbnNvbGUubG9nKHZhbHVlKSk7Cg==">{}</script>

If I comment out the imports like this:

<script lang="ts">
	// import { Footer, Util } from '$lib';
	// import { getCurrentWebview } from '@tauri-apps/api/webview';

	getCurrentWebview()
		.onDragDropEvent((event) => Util.listFilesInDirectory(event.payload))
		.then((value) => console.log(value));
</script>

It formats correctly but the project breaks ofcourse. Not a viable solution. But reproducible.

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

No branches or pull requests

3 participants