-
-
Notifications
You must be signed in to change notification settings - Fork 7
Description
When using prettier-plugin-blade to format Blade templates (.blade.php files), the following issues occur:
-
JavaScript inside Blade templates gets incorrectly formatted
- Inline JavaScript with Blade directives (e.g.,
@lang()) gets broken. - Prettier introduces unwanted line breaks or removes quotes, causing syntax errors.
- Inline JavaScript with Blade directives (e.g.,
-
Trailing commas and indentation issues
- Arrays, function arguments, and parameters do not respect the
"trailingComma": "all"setting. - Indentation inside Blade
@foreach,@if, and@sectionstructures sometimes gets inconsistent.
- Arrays, function arguments, and parameters do not respect the
-
Prettier conflicts with ESLint in Blade files
- Running
eslint --fixon Blade templates causes additional unintended formatting. eslint-plugin-htmldoes not recognize Blade directives, leading to parsing errors.
- Running
================
.prettierrc.json
{
"trailingComma": "all",
"singleQuote": true,
"semi": true,
"tabWidth": 4,
"plugins": ["prettier-plugin-blade"],
"overrides": [
{
"files": "*.blade.php",
"options": {
"parser": "blade"
}
}
]
}
Sample blade -
<script> let a = "@lang('global.resend_available_in')"; var b = 60; </script>===================
Expected Behavior
Inline JavaScript inside Blade templates should remain correctly formatted.
Blade directives should not be broken or reformatted incorrectly.
The trailingComma rule should apply consistently across Blade files.
Actual Behavior
Prettier introduces syntax-breaking changes to inline JavaScript.
Some Blade directives get incorrectly modified or removed.
Prettier and ESLint conflict, leading to unwanted formatting changes.