Skip to content

Adds unnecessary lines and incorrect format on some edge cases #130

@mansoorkhan96

Description

@mansoorkhan96

I am loving this plugin so much. Thank you @JohnathonKoster for the amazing work ❤️❤️❤️.

I am hitting some edge cases where it adds unnecessary lines and if you keep formatting, it keeps on adding those lines and tabs repeatedly:

Simple Example:

Before Formatting

<div
    x-bind:style="() => {
        @foreach ($secondaryFeatures as $index => $feature)
            if (activeTab === @js($feature['name'])) {
                return 'transform: translateX(-' + @js($index * 100) + '%)';
            }
        @endforeach
    }"
></div>

After Formatting

<div
    x-bind:style="() => {
        @foreach ($secondaryFeatures as $index => $feature)

            if (activeTab === @js($feature['name'])) {
                return 'transform: translateX(-' + @js($index * 100) + '%)';
            }
        @endforeach

    }"
></div>

Complex Example:

This block of code gets formatted incorrectly, the plugin adds extra/unexpected lines. This could also be a result of incorrect configuration, I am not sure.

Before Formatting

<div
    x-bind:style="() => {
        @php $index = 0; @endphp

        @foreach ($secondaryFeatures as $feature)
            if (activeTab === @js($feature['name'])) {
                return 'transform: translateX(-' + @js($index * 100) + '%)';
            }

            @php $index++; @endphp
        @endforeach
    }"
></div>

After Formatting

<div
    x-bind:style="() => {
        @php
        $index = 0;

@endphp
        @foreach ($secondaryFeatures as $feature)

            if (activeTab === @js($feature['name'])) {
                return 'transform: translateX(-' + @js($index * 100) + '%)';
            }

            @php
$index++;


@endphp
        @endforeach

    }"
></div>

NOTE: These are not made up examples 😁. I have extracted these examples from a codebase and tweaked a little to just demonstrate only the problematic part. Hope it helps.

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