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

Wrong indentation #73

Closed zepfietje closed 1 year ago

zepfietje commented 1 year ago

https://github.com/filamentphp/filament/blob/3.x/packages/notifications/resources/views/notification.blade.php

<x-filament-notifications::notification
    :notification="$notification"
    :x-transition:enter-start="
        \Illuminate\Support\Arr::toCssClasses([
            'opacity-0',
            ($this instanceof \Filament\Notifications\Http\Livewire\Notifications)
            ? match (static::$horizontalAlignment) {
                'left' => '-translate-x-12',
                'right' => 'translate-x-12',
                'center' => match (static::$verticalAlignment) {
                    'top' => '-translate-y-12',
                    'bottom' => 'translate-y-12',
                    'center' => null,
                },
            }
            : null,
        ])
    "
    ...

The ternary expression arms are missing one level of indentation.

JohnathonKoster commented 1 year ago

Just want to make sure I'm on the same page, are you referring to this content here 🙂?

            ? match (static::$horizontalAlignment) {
                'left' => '-translate-x-12',
                'right' => 'translate-x-12',
                'center' => match (static::$verticalAlignment) {
                    'top' => '-translate-y-12',
                    'bottom' => 'translate-y-12',
                    'center' => null,
                },
            }
            : null,
zepfietje commented 1 year ago

Yes! As you can see, the ? and : are on the same level as the ( the line above it.

JohnathonKoster commented 1 year ago

Tracked it down. Pint/cs-fixer will not add that indentation by itself. I've refactored some code that normalizes the left whitespace when formatting directive parameters to help Pint preserve that whitespace.

The ternary arms will not automatically be indented by Pint, but if you re-indent them, that relative indentation will now be preserved inside Blade component params as of 1.6.10 👍

zepfietje commented 1 year ago

Yeah it's mainly about making sure it's preserved if you put them on the correct level manually. Thanks, John!