shufo / prettier-plugin-blade

Format your blade template using Prettier
https://www.npmjs.com/package/@shufo/prettier-plugin-blade
MIT License
318 stars 8 forks source link

[Formatting Bug]: Unspecified single quotes #196

Closed Sn0wye closed 9 months ago

Sn0wye commented 1 year ago

Version

1.8.12

Template before formatting

<html>

<head>
    <meta charset='utf-8'>
    <meta
        name='viewport'
        content='width=device-width, initial-scale=1'
    >
    <meta
        name='csrf-token'
        content='{{ csrf_token() }}'
    >
    <link
        rel='preconnect'
        href='https://fonts.googleapis.com'
    >
    <link
        rel='preconnect'
        href='https://fonts.gstatic.com'
        crossorigin
    >
    <link
        href='https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap'
        rel='stylesheet'
    >
    <link
        rel='shortcut icon'
        href='{{ asset('favicon.ico') }}'
    >
    @section('head')@show
    @vite('resources/css/styles.css')
    @vite('resources/js/scripts.js')
</head>

<body class='flex flex-col bg-white pt-[100px] text-black lg:pt-0'>
    @include('common.header')
    @include('common.navbar')

    @yield('content')

    @include('common.footer')
    @include('common.mobile')
</body>

</html>

Template after formatting

@extends('common.layout')

@section('head')
    <title>{{ $settings->title }}</title>
@endsection

@section('content')
    <x-sliders.swiper />
    <div class="mb-8 h-[150px] w-full bg-gray-100"></div>
    <x-content.container>
        <x-content.title>Products</x-content.title>
        <x-catalog.grid :products="$products" />
        <x-catalog.banners
            :columns="3"
            :banners="$banners->featured"
        />
        <x-catalog.grid :products="$products" />
        <x-catalog.banners
            :columns="2"
            :banners="$banners->release"
        />
        <x-catalog.grid :products="$products" />
        <x-catalog.banners
            :columns="1"
            :banners="$banners->promotion"
        />
    </x-content.container>
@endsection

Expected Behaviour

Hey, noticed that even though I explicitly specified the singleQuote to false, it's still using it. The quote attribute seems to not work at all inside blade files.

My prettier config:

//.prettierrc.cjs
/** @type {import('prettier').Config} */
module.exports = {
    plugins: [require.resolve("@shufo/prettier-plugin-blade")],
    sortTailwindcssClasses: true,
    tailwindcssConfigPath: "./tailwind.config.js",
    wrapAttributes: "force-expand-multiline",
    semi: true,
    tabWidth: 4,
    singleQuote: false, // should be using double quotes, right?
    arrowParens: "avoid",
    endOfLine: "auto",
    bracketSpacing: true,
    printWidth: 80,
    trailingComma: "none",
    quoteProps: "preserve",
    overrides: [
        {
            files: ["*.blade.php"],
            options: {
                parser: "blade",
                tabWidth: 4
            }
        }
    ]
};

Relevant log output

No response

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

shufo commented 11 months ago

Fixed at https://github.com/shufo/prettier-plugin-blade/releases/tag/v1.10.0

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days