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

Issue with conditional JS in string indented excessively #87

Closed danharrin closed 9 months ago

danharrin commented 9 months ago

Each time the formatter runs, it indents this conditional JS string further:

https://github.com/filamentphp/filament/pull/10289/files#diff-3a5f85b5a0bee7fed3a2d500962199457bc0fa36eff36c29c4773a55b525cddf

So over many PRs, this string gets worse and worse 😅

Another note: wrapping it in ignore just deletes most of the code inside it when the formatter next runs 😁

<x-filament::grid
    :x-data="$isRoot ? '{}' : null"
    :x-on:form-validation-error.window="
        $isRoot ? ('if ($event.detail.livewireId !== ' . Js::from($this->getId()) . ') {
            return
        }

        $nextTick(() => {
            error = $el.querySelector(\'[data-validation-error]\')

            if (! error) {
                return
            }

            elementToExpand = error

            while (elementToExpand) {
                elementToExpand.dispatchEvent(new CustomEvent(\'expand\'))

                elementToExpand = elementToExpand.parentNode
            }

            setTimeout(
                () =>
                    error.closest(\'[data-field-wrapper]\').scrollIntoView({
                        behavior: \'smooth\',
                        block: \'start\',
                        inline: \'start\',
                    }),
                200,
            )
        })') : null
    "
    :default="$getColumns('default')"
    :sm="$getColumns('sm')"
    :md="$getColumns('md')"
    :lg="$getColumns('lg')"
    :xl="$getColumns('xl')"
    :two-xl="$getColumns('2xl')"
    :attributes="
        \Filament\Support\prepare_inherited_attributes($getExtraAttributeBag())
            ->class(['fi-fo-component-ctn gap-6'])
    "
>
    {{-- --}}
</x-filament::grid>
JohnathonKoster commented 9 months ago

Thanks for the report; I'll take a look sometime this week and let you know what I find out! :)

JohnathonKoster commented 9 months ago

Excessive subsequent indentation resolved in 1.6.18

danharrin commented 9 months ago

Thanks! Did you have a chance to wrap the whole thing in {{-- format-ignore-start --}}?

JohnathonKoster commented 9 months ago

Are you wrapping the entire component in that or just the attribute/parameter itself?

danharrin commented 9 months ago

Wrapping the entire component deletes most of the component, wrapping the attribute throws a syntax error

JohnathonKoster commented 9 months ago

Thanks for the extra info - I'll look into that and address it in an update sometime soon 🙂

JohnathonKoster commented 9 months ago

@danharrin The issue with content being removed with {{-- format-ignore--start --}} {{-- format-ignore-end --}} in certain scenarios has been addressed in 1.6.19 🙌

danharrin commented 9 months ago

Thank you very much!

zepfietje commented 9 months ago

Wow, thanks for fixing this so swiftly, @JohnathonKoster!