Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG 🐛: <Footer> gets rewritten to <footer> + all other case insensitive html tag collisions #4

Closed
borisv opened this issue Sep 13, 2021 · 2 comments · Fixed by #19

Comments

@borisv
Copy link

borisv commented Sep 13, 2021

When an imported component has a tag reference name that collides with one of the standard tag names in HTML - like for instance <Footer /> - the plugin resets it to <footer />. Thus being lowercase then it won't get rendered by astro and the component is missing in the output.

I don't like the clunkiness of having to keep a complete nomenclature in mind to avoid collisions like these.

Also the compiler doesn't complain - how could it be aware? - so the then missing component gets dropped silently.

@jasikpark jasikpark added the bug label Sep 15, 2021
@jasikpark jasikpark changed the title tags of imported components get reset Bug: <Footer> gets rewritten to <footer> + all other case insensitive html tag collisions Sep 18, 2021
@jasikpark jasikpark changed the title Bug: <Footer> gets rewritten to <footer> + all other case insensitive html tag collisions Bug 🐛: <Footer> gets rewritten to <footer> + all other case insensitive html tag collisions Sep 18, 2021
@jasikpark jasikpark changed the title Bug 🐛: <Footer> gets rewritten to <footer> + all other case insensitive html tag collisions BUG 🐛: <Footer> gets rewritten to <footer> + all other case insensitive html tag collisions Sep 18, 2021
@togami2864
Copy link
Contributor

I'm working on this issue now.
I know what's causing it.
https://github.com/snowpackjs/prettier-plugin-astro/blob/d497577881283551dc09126f28e7aa924b5dcdb4/src/printer.js#L108-L112

Inline components without '{' are considered not to be jsx.
The following case can be solved by commenting on the above part. (Of course, the modification is needed to deal with more complex cases.)

---
import { Footer } from 'Footer'
---

<Footer></Footer>
<footer></footer>

and run

$ prettier -w ./<Filename>

another problem

I used VScode and executed the above command in the terminal. It worked as expected.
But, the code formatted by Format On Save in vscode, I got the following.

---
import { Footer } from 'Footer'
---

<footer></footer>
<footer></footer>

Does anyone else have the same problem?

reproduction

1 npm init astro
2 npm i prettier
3 npm i github:snowpackjs/prettier-plugin-astro
4 comment out L 108 ~ L 112 in printer.js in prettier-plugin-astro
5 run formatting executed by Format On Save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants