You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Meta: Switch from Prettier to dprint for formatting #7372
Are there any considerations about switching the formatter from Prettier to dprint? dprint is a plugins-based formatter, and it's written in Rust so it's fast.
But speed and performance isn't the most important factor, dprint is highly configurable while Prettier is opinionated. So, code styles can be easily customized to get satisfication.
The reason why I recommend dprint is that I've noticed you opened an issue about the bug of formatting CSS selectors with comments in Prettier: prettier/prettier#15356 . dprint doesn't have official plugins for formatting CSS at this moment, but here is a third-party one: Malva.
Malva is also highly configurable and customizable, and it provides more options than Prettier. Also, it works with comments better than Prettier. For the bug you caught in Prettier, Malva works well: Malva playground. Malva also fixes some other bugs in Prettier, such as prettier/prettier#16232 (comment) .
I gave it a try in 6210d1e but I think it's a downgrade in a few spots, especially with comments being wrapped to the next line, or moved before the selector. :is() and :has() are particularly troublesome as they're just one-lined. Quotes are also broken I think:
Would you be open to send a PR? Last week I had two issues:
:has(), :is() wrapping
comments position
If the first one can be fixed to maintain what we expect, we can probably figure something out with the comments positioning. Biome actually moved some comments before the comma and that made sense, for example.
- a, /* comment */+ a /* comment */,
b {
}
But in the last dprint PR, the formatting in this case was changed to this instead, which isn't what we expect:
Can you give me some examples about :has() and :is()? (expected results)
Recently I'm fixing comments problems.
dprint has a Biome plugin and Biome supports GraphQL, so we can format GraphQL indirectly.
dprint also has a Prettier plugin. If you don't like Biome, you can still use Prettier to format GraphQL. Compared to using Prettier directly, running Prettier in dprint will be faster because files will be formatted in parallel.
the expected result is what we have now, more or less. The wrong result is when multiple long selectors are on a single line inside is(), as shown in my screenshot a few comments back
yes GQL would need to use biome or prettier, I had also set biome for GQL without issues in my PR. Prettier would be preferred since it's part of our dependencies anyway (via XO)
Malva v0.6.0 has been published with many comments improvements. Would you like to try it again? Don't forget to configure Malva as the dprint.json example below:
Can you give me some examples about :has() and :is()? (expected results)
Recently I'm fixing comments problems.
dprint has a Biome plugin and Biome supports GraphQL, so we can format GraphQL indirectly.
dprint also has a Prettier plugin. If you don't like Biome, you can still use Prettier to format GraphQL. Compared to using Prettier directly, running Prettier in dprint will be faster because files will be formatted in parallel.
I had a look at this comment unfortunatly it seems like graph ql formatter is unreleased for biome so dprint can't support as it's not released.
Activity
Jayllyz commentedon May 23, 2024
Biome could replace both prettier and eslint 👀 (+ some stylelint rules soon)
fregante commentedon May 23, 2024
Thank you but prettier is good enough for now.
Biome doesn't have compatibility with eslint plugins, which we have a lot of.
fregante commentedon Jul 16, 2024
I gave it a try in 6210d1e but I think it's a downgrade in a few spots, especially with comments being wrapped to the next line, or moved before the selector.
:is()and:has()are particularly troublesome as they're just one-lined. Quotes are also broken I think:This was done for #7553
g-plane commentedon Jul 16, 2024
Quotes can be configured.
fregante commentedon Jul 26, 2024
Would you be open to send a PR? Last week I had two issues:
If the first one can be fixed to maintain what we expect, we can probably figure something out with the comments positioning. Biome actually moved some comments before the comma and that made sense, for example.
But in the last dprint PR, the formatting in this case was changed to this instead, which isn't what we expect:
fregante commentedon Jul 26, 2024
We're only using Prettier for CSS and GQL for now. I think GQL would still need Prettier because I don't see it (via dprint plugin)
https://dprint.dev/plugins/
g-plane commentedon Jul 26, 2024
:has()and:is()? (expected results)fregante commentedon Jul 27, 2024
g-plane commentedon Jul 27, 2024
Just enable
"linebreakInPseudoParens"option, and the result of:is()and:where()can be better. playgroundg-plane commentedon Aug 1, 2024
Malva v0.6.0 has been published with many comments improvements. Would you like to try it again? Don't forget to configure Malva as the
dprint.jsonexample below:{ "malva": { "quotes": "preferSingle", "blockSelectorLinebreak": "always", "linebreakInPseudoParens": true } }eveeifyeve commentedon Aug 7, 2024
I had a look at this comment unfortunatly it seems like graph ql formatter is unreleased for biome so dprint can't support as it's not released.