neoki07 / prettier-plugin-astro-organize-imports

A Prettier plugin for formatting imports in Astro files
https://www.npmjs.com/package/prettier-plugin-astro-organize-imports
MIT License
33 stars 2 forks source link

Files with a conditional top-level element cause a `<PrettierPluginAstroOrganizeImports>` tag to be left behind #178

Closed blimmer closed 3 weeks ago

blimmer commented 3 weeks ago

Consider this file:

---
const { foo } = Astro.props;
---

{
  foo === 'bar' && (
    <div>Foo is bar</div>
  )
}

{
  foo === 'baz' && (
    <div>Foo is baz</div>
  )
}

When formatted, the file looks like this:

---
const { foo } = Astro.props;
---

{
  foo === 'bar' && (
    <div>Foo is bar</div>
  )
}

<PrettierPluginAstroOrganizeImports>
{
  foo === 'baz' && (
    <div>Foo is baz</div>
  )
}
</PrettierPluginAstroOrganizeImports>

I have a failing test to show the issue here: https://github.com/neoki07/prettier-plugin-astro-organize-imports/pull/177

neoki07 commented 3 weeks ago

Sorry for the delay in responding. I will investigate a solution to this issue this week or so.

blimmer commented 3 weeks ago

No problem at all - thanks!