prettier-plugin-astro icon indicating copy to clipboard operation
prettier-plugin-astro copied to clipboard

🐛 BUG: Added unnecessary end tag in expression

Open kagankan opened this issue 3 years ago • 1 comments

Describe the Bug

Failure Pattern

Probably, the conditions are:

  • inside expression
  • 2 or more attributes
  • > is in next line

Input

<div>
  {
    (
      <div id="id" class="class"
      >text
      </div>
    )
  }
</div>

Output

<div>
  {
    (
      <div id="id" class="class"></div>
        text
      </div>
    )
  }
</div>

added unnecessary </div> .

Success Patterns

the line ends with >

Input
<div>
  {
    (
      <div id="id" class="class">
      text</div>
    )
  }
</div>
Output
<div>
  {
    (
      <div id="id" class="class">
        text
      </div>
    )
  }
</div>

outside expression

Input
<div>
  <div id="id" class="class"
  >text
  </div>
</div>
Output
<div>
  <div id="id" class="class">text</div>
</div>

with single attribute

Input
<div>
  {
    (
      <div class="class"
      >text
      </div>
    )
  }
</div>
Output
<div>
  {(<div class="class">text</div>)}
</div>

Notes

  • I'm using prettier-plugin-astro via astro-vscode v0.24.4.
  • my printWidth setting is 120.

Steps to Reproduce

See Describe the Bug

kagankan avatar Sep 10 '22 08:09 kagankan

Hello, it seems like this is not a bug in the Prettier plugin, but in VS Code's auto closing. Setting html.autoClosingTags to false fixes the issue (but, of course disable tags auto closing).

Not sure if there's way on our end to fix it, I'll investigate

Princesseuh avatar Sep 26 '22 21:09 Princesseuh

The auto closing logic in the extension has been upgraded and it seems like this is not an issue anymore, as such I'll close this issue

Princesseuh avatar Aug 11 '23 20:08 Princesseuh