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

[ENHANCEMENT] Vanilla Prettier setup in blueprints [RFC 1055] #10596

Merged

Conversation

bertdeblock
Copy link
Member

No description provided.

@bertdeblock bertdeblock force-pushed the vanilla-prettier-setup-in-blueprints branch 3 times, most recently from e6889c5 to 82981fb Compare December 28, 2024 11:43
@bertdeblock bertdeblock force-pushed the vanilla-prettier-setup-in-blueprints branch 3 times, most recently from 4a37796 to 08865f4 Compare December 28, 2024 15:19
@bertdeblock bertdeblock force-pushed the vanilla-prettier-setup-in-blueprints branch 3 times, most recently from 77d8f44 to fa6480f Compare January 6, 2025 15:24
Copy link
Contributor

@ef4 ef4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested alternative: can we put **/*.html in the prettierignore?

Because the formatting prettier is producing here is not great. You were forced to add the special prettier-ignore comment line. And prettier is making several tags self-closing that are not actually supposed to be self-closing in the HTML spec.

The current blueprint doesn't do prettier formatting for html, so this is not a loss of existing functionality.

Separate question: is this introducing prettier formatting to markdown, and if so does it also rewrite people's READMEs? If so, that would possibly be another extension to ignore.

@bertdeblock
Copy link
Member Author

bertdeblock commented Jan 16, 2025

I'm now slightly worried that my RFC wasn't clear enough.
The intention was to format all files Prettier supports, including (but not limited to) *.html and *.md files.

Functionally, the ignore comments are not needed and I can remove them.
I understand the issue about self-closing void tags, but that would also happen in *.hbs, *.gjs and *.gts files (e.g. <input> => <input />).
If we would ignore those extensions as well, than a large portion of a project would go unformatted, which would go against the intention of the RFC.

@NullVoxPopuli
Copy link
Contributor

hbs / gjs / etc are not explicitly HTML tho -- and this goes for jsx, vue, svelte, ng / angular, it's all shorthand to (eventually) generate HTML.

the HTML file is the only real HTML we have.

@mansona
Copy link
Member

mansona commented Jan 16, 2025

apparently there is a plugin that fixes the issue? prettier/prettier#15336 (comment)

@bertdeblock
Copy link
Member Author

I'm only saying that formatting-wise the same issue occurs in hbs, gjs, ...

@bertdeblock
Copy link
Member Author

Indeed, but I didn't really want to include yet another dependency in the blueprint. I would prefer to just follow Prettier. To me, that's kind of the point of using Prettier. Let it decide what's best readability/formatting wise.

@mansona
Copy link
Member

mansona commented Jan 16, 2025

I agree with the point of prettier (I may not like it but I agree with what it's trying to do)... but in this case it's just wrong 🤔 Void elements are not and should not be "self closing"

@mansona
Copy link
Member

mansona commented Jan 16, 2025

https://html.spec.whatwg.org/multipage/syntax.html#start-tags

Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single U+002F SOLIDUS character (/), which on foreign elements marks the start tag as self-closing. On void elements, it does not mark the start tag as self-closing but instead is unnecessary and has no effect of any kind. For such void elements, it should be used only with caution — especially since, if directly preceded by an unquoted attribute value, it becomes part of the attribute value rather than being discarded by the parser.

@SergeAstapov
Copy link
Contributor

if another vote matters, I agree with @mansona that Prettier is surely wrong and ignorant for that issue (the reason is most likely because of React and JSX, like this reddit thread suggest https://www.reddit.com/r/reactjs/comments/jc8964/self_closing_tags_in_react/)

Hence, my vote goes to doing right thing and either ignore .html files (but do format .hbs, .gts, .gjs, etc.) or use Prettier plugin (only if it works perfectly).

@bertdeblock
Copy link
Member Author

fwiw, I'm not arguing that Prettier is doing the right thing. I agree that it's not according to the spec. I just feel that's a discussion for the Prettier project.

@SergeAstapov
Copy link
Contributor

maybe we should do RFC amendment to clarify this in RFC rather than in this thread? just a thought

@bertdeblock
Copy link
Member Author

Yeah, maybe it's safer to ignore html files for now then. Most projects only have 2 anyways.

@ef4
Copy link
Contributor

ef4 commented Jan 16, 2025

I'm now slightly worried that my RFC wasn't clear enough.
The intention was to format all files Prettier supports, including (but not limited to) *.html and *.md files.

Looking at the RFC I think your intent is clear, but speaking for myself the thing I was paying attention to in the RFC is stopping running prettier inside eslint. That is, IMO, the most important motivation. Having the option of running prettier on more file types is only one of the benefits of that decision, and not nearly the most important one.

(Having prettier inside eslint is miserable. I've seen way too many developers reacting to red squiggles from the prettier eslint plugin, which is defeats the point of having prettier, which should free you to stop paying attention to formatting).

@bertdeblock bertdeblock force-pushed the vanilla-prettier-setup-in-blueprints branch from 30aef65 to cf19dec Compare January 17, 2025 07:35
@bertdeblock
Copy link
Member Author

HTML changes are reverted, and *.html is added to the Prettier ignore file.
Ready for another review I think!

@ef4 ef4 merged commit 7060c4c into ember-cli:master Jan 17, 2025
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants