prettier-plugin-blade
prettier-plugin-blade copied to clipboard
[Formatting Bug]: @empty causes issues with @forelse
Version
1.14.1
Template before formatting
<div class="px-4 py-5 sm:p-6 flex-1">
<ul class="grid grid-cols-1 lg:grid-cols-2 gap-4">
@forelse($user->permissions as $permission)
<li class="flex items-start text-sm space-x-2">
<svg class="flex-shrink-0 h-5 w-5 text-green-600 stroke-current" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24">
<path d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"></path>
</svg>
<span>{{ $permission->friendly_name }}</span>
</li>
@empty
<li>
<span class="text-gray-400 italic">Aucune permission attitrée</span>
</li>
@endforelse
</ul>
</div>
Template after formatting
<div class="px-4 py-5 sm:p-6 flex-1">
<ul class="grid grid-cols-1 lg:grid-cols-2 gap-4">
@forelse($user->permissions as $permission)
<li class="flex items-start text-sm space-x-2">
<svg class="flex-shrink-0 h-5 w-5 text-green-600 stroke-current" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24">
<path d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"></path>
</svg>
<span>{{ $permission->friendly_name }}</span>
</li>
@empty
<li>
<span class="text-gray-400 italic">Aucune permission attitrée</span>
</li>
@endforelse
</ul>
</div>
Expected Behaviour
It should format properly, instead, it throws an error.
Relevant log output
Error: Unknown node type: undefined
at Object.f [as print] (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\@shufo\prettier-plugin-blade\dist\index.cjs:1:4075)
at callPluginPrintFunction (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:8601:26)
at mainPrintInternal (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:8550:22)
at mainPrint (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:8537:18)
at printAstToDoc (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:8529:18)
at coreFormat (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:8837:20)
at formatWithCursor2 (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:9021:18)
at \\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:38183:12
at Object.format (\\wsl$\Ubuntu\home\morfra\code\refonte-intranet\node_modules\prettier\index.js:38197:12)
at C:\Users\morfra\AppData\Local\Programs\PhpStorm\plugins\prettierJS\prettierLanguageService\prettier-plugin.js:148:46
Process finished with exit code -1