Stillat / blade-parser-typescript

A Laravel Blade parser, compiler, and static analyzer written in TypeScript.
https://stillat.com
MIT License
82 stars 2 forks source link

[Question] Avoid line break for components attributes #78

Closed robsontenorio closed 11 months ago

robsontenorio commented 11 months ago

It formats this

 <x-button label="Delete" icon="o-trash" />

To this

 <x-button
    label="Delete"
    icon="o-trash"
 />

Iis there any option to avoid this behavior ? I wanna keep blade attributes on same line

 <x-button label="Excluir" icon="o-trash" />
JohnathonKoster commented 11 months ago

👋 Hey, there!

This can be controlled using the singleAttributePerLine prettier option: https://prettier.io/docs/en/options.html#single-attribute-per-line

Here is an example .prettierrc file with this configuration option:

{
    "tabWidth": 4,
    "singleAttributePerLine": false,
    "plugins": [
        "./node_modules/prettier-plugin-blade/"
    ],
    "overrides": [
        {
            "files": [
                "*.blade.php"
            ],
            "options": {
                "parser": "blade"
            }
        }
    ]
}
robsontenorio commented 11 months ago

In addition you also need a compatible "printWidth": 300, as much needed for your use case.

Thanks!