Skip to content

formatDirectivePhpParameters false has wrong indentation #124

@BoGnY

Description

@BoGnY

Hi, this is the .blade.format.json config file:

{
    "useLaravelPint": false,
    "formatInsideEcho": false,
    "spacesAfterDirective": 0,
    "spacesAfterControlDirective": 0
}

I have the following code:

<div class="flex flex-col items-stretch justify-around border border-black dark:border-white">
    @foreach($graph_array as $graph => $value)
        <div @class([
            'flex h-36 flex-row p-4 gap-2' => true,
            'border-b border-black dark:border-white' => !$loop->last,
        ])>
            <div @class([
                'ml-4 mr-2 basis-2/3 text-justify -indent-4.5' => true,
                'text-xl' => $print,
            ])>
                {!! trans("alarm.description.{$graph}", ['additional_class' => $print ? 'text-base' : 'text-sm']) !!}
            </div>

            <div class="flex basis-1/6 flex-col items-center justify-center" wire:ignore>
                <div class="relative flex w-[180px]">
                    <canvas id="{{ str('chart_' . $graph)->camel() }}"></canvas>
                </div>

                @if(!$value['good'])
                    <x-animate-pulse :$print class="mt-2">{{ trans('alarm.disequilibrium') }}</x-animate-pulse>
                @endif
            </div>
        </div>
    @endforeach
</div>

Applying prettier add space after NOT operator (so I got !$loop->last formatted as ! $loop->last), and I don't want this, so I have added "formatDirectivePhpParameters": false to config file.

So, new .blade.format.json config file:

{
    "useLaravelPint": false,
    "formatInsideEcho": false,
    "formatDirectivePhpParameters": false,
    "spacesAfterDirective": 0,
    "spacesAfterControlDirective": 0
}

This disable the space after NOT operator, but this is the result of prettier:

<div class="flex flex-col items-stretch justify-around border border-black dark:border-white">
    @foreach($graph_array as $graph => $value)
        <div @class([
                    'flex h-36 flex-row p-4 gap-2' => true,
/*
|_______|_______|___|
|   8   |   8   | 4 | (spaces) but should be 8 + 4
*/
                    'border-b border-black dark:border-white' => !$loop->last,
                ])>
            <div @class([
                            'ml-4 mr-2 basis-2/3 text-justify -indent-4.5' => true,
/*
|___________|___________|___|
|     12    |     12    | 4 | (spaces) but should be 12 + 4
*/
                            'text-xl' => $print,
                        ])>
                {!! trans("alarm.description.{$graph}", ['additional_class' => $print ? 'text-base' : 'text-sm']) !!}
            </div>

            <div class="flex basis-1/6 flex-col items-center justify-center" wire:ignore>
                <div class="relative flex w-[180px]">
                    <canvas id="{{ str('chart_' . $graph)->camel() }}"></canvas>
                </div>

                @if(!$value['good'])
                    <x-animate-pulse :$print class="mt-2">{{ trans('alarm.disequilibrium') }}</x-animate-pulse>
                @endif
            </div>
        </div>
    @endforeach
</div>

It looks like the parent element's indentation will be taken and doubled, with an extra 4 spaces added since it is a child element and needs to be indented, while the closing tag line has only doubled spaces (rightly without 4 extra spaces)..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions