Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space after directives with laravel Pint #98

Open
devinvb opened this issue Apr 23, 2024 · 1 comment
Open

Space after directives with laravel Pint #98

devinvb opened this issue Apr 23, 2024 · 1 comment

Comments

@devinvb
Copy link

devinvb commented Apr 23, 2024

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.

@JohnathonKoster
Copy link
Contributor

Very interesting! I'll dig in later this week and see what I can find out 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants