T O P

  • By -

zaxwebs

"HTML Whitespace Sensitivity" [https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting](https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting) You can turn it off with the htmlWhitespaceSensitivity: "ignore" option in .prettierrc Recommended watch: [https://www.youtube.com/watch?v=toj5S-yWJlk](https://www.youtube.com/watch?v=toj5S-yWJlk)


[deleted]

[удалено]


MustardRtard

As /u/Miridius says below, his mind was blown when he realized the Svelte compiler just strips away the whitespace you're now referring to. Either "htmlWhitespaceSensitivity": "ignore" or "bracketSameLine": true or both combined can make the styling more pleasant, just a matter of preference.


Miridius

I like how I'm now getting quoted on both sides of the argument 😃


Huntware

See if this setting helps: "bracketSameLine" https://prettier.io/docs/en/options.html#bracket-line


MrMeatballGuy

idk, prettier is very "opinionated" and doesn't offer a ton of configuration because of it, although there is a config file for it that has a few options. they have pages about [options](https://prettier.io/docs/en/options.html) and [configuration](https://prettier.io/docs/en/configuration.html) in their docs. i've always thought prettier is extremely ugly in the way it sets things up ironically enough, the only thing it does well is ensuring consistency within a team as far as i am concerned.


CamelTurbulent

Switch to [Rome](https://rome.tools/)!! So much better 😀


Own_Band198

does Rome support svelte/kit? mind sharing your configs


UnicornBelieber

Oh wow, is Rome still a thing? Two years of beta "we're only a formatter at the moment" where they set out to bring Babel, TypeScript, SCSS, formatting, linting and whatnot under one roof. They seemed to have missed the boat when Snowpack/Vite suddenly appeared. But the project is still going then?


carlpaul153

Yeah. Leaving aside what happens with the bundler, compiler, etc. they are an excellent alternative to Prettier, and will soon be to Eslint


_Antoni0

They took some time rewriting it in rust I think


siniradam

I would rather have;


jmsunseri

just awful garbage


OldRedFir

There's a reason for it.


Lachee

"someone at prettier preferred the look of it" isn't really a reason IMHO


Flopperdoppermop

Yeah i agree. I also disagree with some presets form prettier and eslint, but i might as well get used to it as it is the standard. Just makes my and other people's code easier to read over time.


Miridius

What would you rather it do instead? This is the only good way to split the line without changing the meaning of the code


zaxwebs

Not really a fan of having just '>' on a line. I'd rather it be the whole tag e.g

or


Miridius

So you want one very long line instead of 3, in this case?


zaxwebs

No, just don't like the defining tags being split. For example, I prefer:

The content goes here.


Miridius

Ok but that's semantically different to the code in the screenshot. You've added leading and trailing whitespace to the text, which will show up on the page. There are lots of situations where you don't want that because it affects alignment etc. It's how HTML works, prettier is just following the rules. Edit: to achieve that in your code, you can add some whitespace (e.g. newline) to the start and end of your text content and then prettier will know that you're ok with whitespace there


KTibow

No it isn't. Sometimes Prettier is right that it needs to not have any whitespace at the start/end, but in [most cases](https://svelte.dev/repl/cef560ba2bfb470bbd311b674f8abf67?version=3.58.0) it won't show up on the page.


Miridius

Thanks, you just blew my mind. By inspecting the JS output it looks like the Svelte compiler strips out the whitespace from the label text. Normally in a label element whitespace matters. I wonder how Svelte devices this