blade-parser-typescript icon indicating copy to clipboard operation
blade-parser-typescript copied to clipboard

Space after directives with laravel Pint

Open devinvb opened this issue 10 months ago • 1 comments

Hi,

I'm running into a problem with formatting blade directives (space after), when using config "useLaravelPint": true,. If I run prettier on a single file it works, but if I run it for an entire folder it doesn't.

My .prettierrc config

{
    "singleQuote": true,
    "printWidth": 120,
    "tabWidth": 4,
    "plugins": ["prettier-plugin-blade", "prettier-plugin-tailwindcss"],
    "overrides": [
        {
            "files": ["*.blade.php"],
            "options": {
                "parser": "blade"
            }
        }
    ]
}

My .blade.format.json config

{
    "useLaravelPint": true,
    "spacesAfterDirective": 1,
    "spacesAfterControlDirective": 1,
    "phpOptions": {
        "singleQuote": true,
        "phpVersion": "8.2"
    },
    "attributeJsOptions": {
        "semi": true,
        "printWidth": 120
    }
}

My pint.json config

{
    "preset": "laravel",
    "rules": {
        "method_argument_space": true,
        "concat_space": {
            "spacing": "one"
        },
        "single_trait_insert_per_statement": true,
        "types_spaces": {
            "space": "single"
        }
    }
}

I have a test.blade.php file that looks like this:

@isset ($error)
    <p class="text-sm font-medium text-red-500">{{ $error }}</p>
@endisset

I want to keep the space after my blade directives.

Now when I run prettier on only the file: npx prettier resources/views/compontents/input/test.blade.php the space is there.

When I run prettier on the folder: npx prettier resources/views/components/input --write the space is removed.

When I set "useLaravelPint": false, the space is there when running prettier on either the file or the folder.

So the problem seems to be Laravel Pint removing the space, but only when running prettier on multiple files at once.

devinvb avatar Apr 23 '24 08:04 devinvb