gitKrystan / prettier-plugin-ember-template-tag

A prettier plugin for formatting Ember template tags
MIT License
22 stars 12 forks source link

[Bug] `prettier . --write` does not run on .gjs/.gts files #113

Closed simonihmig closed 10 months ago

simonihmig commented 1 year ago

🐞 Describe the Bug

prettier . --write does not run on .gjs/.gts files

🔬 Minimal Reproduction

I run prettier . --write

😕 Actual Behavior

It reformats all files, except for .gjs/.gts files. CLI output list all kind of files, like .js/.cjs/.mjs, but no .gjs/.gts

🤔 Expected Behavior

Should reformat .gjs/.gts files.

🌍 Environment

➕ Additional Context

When I run prettier path/to/component.gts --write then it does work! Also running prettier using VSCode does work correctly. So it seem only prettier . seems to ignore any .gjs/.gts files

fdeters commented 1 year ago

I've reproduced this issue, and found that it does work when specifying a file, like npx prettier --write app/components/my-component.gjs, but doesn't work with directories, like npx prettier --write app/components.

NullVoxPopuli commented 1 year ago

My prettier command is now:

prettier -c "**/*.{js,gjs,cjs,mjs,json,hbs,ts,cts,mts,gts}"

:sweat_smile:

My changes: https://github.com/NullVoxPopuli/limber/pull/1312/commits/80433f77df98d4cc46c93f26110e1fb35c4ab50e#diff-fcf5729f4474308f357cea6ec1123607ce116df8a7a60516595fac5f5327e01bR33

gitKrystan commented 1 year ago

Sorry for the annoying bug. :-(

Based on Prettier's documentation, prettier --write . should be working, but it seems like we actually need to do prettier --write --plugin prettier-plugin-ember-template-tag. I am finding other plugins using this hack too but no one seems to mention it's a hack?

I will update the documentation accordingly and open an issue on prettier.

gitKrystan commented 1 year ago

https://github.com/prettier/prettier/issues/15351 https://github.com/gitKrystan/prettier-plugin-ember-template-tag/pull/124

gitKrystan commented 1 year ago

Looks like this bug was introduced in prettier v3 and there is a fix in the works. More info at https://github.com/prettier/prettier/issues/15079

In the meantime add the plugin flag as I mentioned above.

gitKrystan commented 1 year ago

Supposedly this is fixed by https://github.com/prettier/prettier/pull/15433 but I haven't tried it yet. LMK if it works!

NullVoxPopuli commented 1 year ago

it does not, I still have this issue :(

ah, it's not released yet: https://github.com/prettier/prettier/pull/15433#issuecomment-1732958073

bartocc commented 10 months ago

Like @NullVoxPopuli commented on discord, prettier@3.1 has been released this WE 🎉

gitKrystan commented 10 months ago

README updated. I will re-open this if it's still borked.