Stillat / blade-parser-typescript

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

[Question] Avoid line break for components attributes #78

Closed robsontenorio closed 1 year ago

robsontenorio commented 1 year 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 1 year 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 1 year ago

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

Thanks!