shufo / prettier-plugin-blade

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

[Formatting Bug]: PHPStorm Reformat Code does nothing on blade files #287

Open sven-ahrens opened 5 months ago

sven-ahrens commented 5 months ago

Version

1.14.1

Template before formatting

<template>
  <div>
    <a href="https://vitejs.dev" target="_blank">
      <img src="/vite.svg" class="logo" alt="Vite logo" />
    </a>
    <a
        href="https://vuejs.org/"
        target="_blank"
    >
      <img
          src="./assets/vue.svg"
          class="logo vue"
          alt="Vue logo"
      />
    </a>
  </div>
</template>

Template after formatting

<template>
  <div>
    <a href="https://vitejs.dev" target="_blank">
      <img src="/vite.svg" class="logo" alt="Vite logo" />
    </a>
    <a
        href="https://vuejs.org/"
        target="_blank"
    >
      <img
          src="./assets/vue.svg"
          class="logo vue"
          alt="Vue logo"
      />
    </a>
  </div>
</template>

Expected Behaviour

Beforehand, the command npx prettier . --write works perfectly fine. If I execute this command, it'll format the code just how I'd expect it.

The problem is the PHPStorm Reformat Code function. It basically does nothing. Here is a video demonstrating my problem:

https://github.com/shufo/prettier-plugin-blade/assets/18313443/d6e3db43-fde3-48de-a883-ef8ac7e1d2df

This is the end result, how it should look like:

<div>
    <a
      href="https://vitejs.dev"
      target="_blank"
    >
      <img
        src="/vite.svg"
        class="logo"
        alt="Vite logo"
      />
    </a>
    <a
      href="https://vuejs.org/"
      target="_blank"
    >
      <img
        src="./assets/vue.svg"
        class="logo vue"
        alt="Vue logo"
      />
    </a>
  </div>

This is my .prettierrc config:

{
  "singleAttributePerLine": true,
  "singleQuote": true,
  "semi": false,
  "plugins": ["@shufo/prettier-plugin-blade"],
  "overrides": [
    {
      "files": ["*.blade.php"],
      "options": {
        "parser": "blade",
        "tabWidth": 2
      }
    }
  ]
}

My specs:

Relevant log output

No response

sven-ahrens commented 5 months ago

I just want to add, that it does work on Visual Studio Code. No problems at all.

Maybe I'm missing something in PHPStorm, but that's what I could find for now

AsKode commented 3 months ago

Same issue. Can't make it work.

chrillep commented 2 months ago

@AsKode @sven-ahrens The docs will help you ;) you need to add blade.php as an extension to listen after.

https://github.com/shufo/prettier-plugin-blade?tab=readme-ov-file#jetbrains-webstorm-phpstorm-pycharm

github-actions[bot] commented 3 weeks 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