Skip to content
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

Choose what to format #55

Open
gbouteiller opened this issue Aug 14, 2019 · 5 comments
Open

Choose what to format #55

gbouteiller opened this issue Aug 14, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@gbouteiller
Copy link

Hello,
First of all, thank you for your work. I'm currently using your plugin via the vscode extension but I posted the issue here as I think it is more appropriate.
I'm using pug templating so I have 3 main tags in my files : template, script and style. Currently, the plugin does not give you the opportunity to choose what to format and I ended up deactivating formatting because it messes up my pug template.
Would it be possible to activate/deactivate formatting for script/style/template independently as it is the case for Vue with Vetur?
Thank you.

@umanghome
Copy link

I'm using stylus for my CSS and this plugin either messes the styles up or refuses to process the file altogether. Would love an option to bypass prettifying everything inside the <style> tag.

@ghost
Copy link

ghost commented Sep 30, 2019

I have the same problem as @umanghome. I can't even disable it, it's terrible. please at least let us disable it!

@jesseskinner
Copy link
Contributor

Would implementing <!-- prettier-ignore --> here address the issue? See https://prettier.io/docs/en/ignore.html

Seems it is already partially implemented for HTML, but not for <script> and <style>.

@dummdidumm
Copy link
Member

Choosing what to format feels like the wrong solution, prettier is an opinionated code formatter after all. What we can - and did - though is to disable formatting for unsupported languages and supporting the <!-- prettier-ignore --> comment which marks the next node as "do not format". What's missing is support for default languages from svelte.config.js but I'm not sure if we can add this in a good way.

@RapidOwl
Copy link

RapidOwl commented Mar 23, 2021

I'm having a bit of trouble with this. <!-- prettier-ignore --> does not prevent formatting from occurring in my Svelte files. The example below shows the mess Prettier has made of a style element inside a template literal. I'm using the official Svelte plugin for VS Code and Svelte 3.0.

<!-- prettier-ignore -->
<script>
	export let animationName;
	export let calculatedLength;
	export let keyFrames;

	let styleElement = `
<style ✂prettier:content✂="Cgkuc3R1ZmYgewoJCWNvbG9yOiByZWQ7Cgl9Cg=="></style>
	`;
</script>

I'm getting around it for now by adding the file in question to my .prettierignore.

@dummdidumm dummdidumm added the enhancement New feature or request label Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants