shufo / prettier-plugin-blade

Format your blade template using Prettier
https://www.npmjs.com/package/@shufo/prettier-plugin-blade
MIT License
316 stars 8 forks source link

[Bug]: Blade components format is not compliant with Prettier #240

Closed antonioribeiro closed 6 months ago

antonioribeiro commented 9 months ago

Description

When having a bit more complex blade components, format not pretty, not very readable, and in complete disconformity with Prettier itself. Here's an example

image

Suggested Solution

This is what we believe it should have done:

image

And if you take a look at how Prettier is formatting HTML (had to remove some stuff to make it a valid HTML, but the idea is still there), we get something very similar as the above:

Screenshot 2023-10-09 at 10 42 51

Here's the playgroud link:

https://prettier.io/playground/#N4Igxg9gdgLgprEAuEAeAHgWjACzmAawgFcYACASygAdSA6AcwCcTqywAbAQwGceBeADohmFACbYIHTD2pcomAExkAtmKSiJkabPmYAjMLIAZLgCM4HISADCFGAE8jcJiyYDhAZRdueAfiMmOABHYgogsQA+QSgMbDxCEnIg0PC4MTIAemjYzKxcfCJSSJAAGhAIahgKaB5kUC5XCAB3AAVGhDqULg5mrgc68rMmLkI4GE8uFThjKjhkADMenjghkbGJuTAqBmQYJmJVkBWVCj2Do54djjgARWIIeEXlo4ArHnRPa7uHp6QljgrcqhR5wVosahdEC8TBQODpdJlED7LgUDg7GwQFQqLjIaEcDhIq5QBg3ACCMH2FDMpDBLlmcOegKOOBgKg4AHUcPY4LowHBvFArtUAG72Bx4sB8JEiw4ASSgYgQEzATAoVTJis8jhuTKBIGoLBWHJG1Dxht5LhF83KVBWTBg4K4DBxeqOcncLjxrPZSMNVBgHPEMBwyAAHAAGcopMJBJ0u3H-F7lGDmINiEPIRTlYgrAAq5i6AP1cBUFjESrEphJxGdcAAYhAmDjKTs8VxSBAQABfbtAA

Alternatives

No response

Additional Context

No response

calebdw commented 8 months ago

This is because this plugin is using js-beautify as opposed to prettier to format the HTML/CSS---instead of trying to make js-beautify look like prettier should probably just use prettier to format

antonioribeiro commented 8 months ago

Yeah, if you are building a Prettier plugin, using Prettier to format it is the best option, as this is also the easiest way to be compliant with the Prettier ecosystem. As we are using Prettier on almost every language (templating system, framework...) we write, we want our code to look as close as possible to each other (if they relate, of course).

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days