Skip to content

Bound Blade component attributes become invalid with singleQuote: false #150

@dansan92

Description

@dansan92

With PHP formatting enabled, certain :attribute="..." bindings become invalid after formatting.

For example:

<x-ui.image :src="$article['image']" />
<x-div :title="__('Hello')"></x-div>

After formatting:

<x-ui.image :src="$article[&quot;image&quot;]" />
<x-div :title="__(&quot;Hello&quot;)"></x-div>

Using the following config:

"plugins": [
  "prettier-plugin-blade",
  "prettier-plugin-tailwindcss",
  "@prettier/plugin-php"
],
"overrides": [
  {
    "files": [
      "*.blade.php"
    ],
    "options": {
      "parser": "blade",
      "bladePhpFormatting": "safe",
      "bladePhpFormattingTargets": [
        "directiveArgs",
        "echo",
        "phpBlock"
      ],
      "bladeKeepHeadAndBodyAtRoot": false
    }
  }
]

If I add "singleQuote": true, both examples format correctly, so this seems to be triggered specifically by "singleQuote": false inside bound Blade attributes.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions