zackad / prettier-plugin-twig

Code formatting plugin for Prettier to handle Twig templates
Apache License 2.0
57 stars 6 forks source link

support any valid html attributes so that things like AlpineJS work #37

Closed hanoii closed 3 months ago

hanoii commented 4 months ago

I saw that you are adding the melody-parser into the module, I hope this is now easier to fix.

Things like (coming from https://alpinejs.dev/):

<button @click="toggle()" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-aida-blue-logo" aria-expanded="false">

Gives:

[error] Expected a valid attribute name, but instead found "@", which is not part of a valid attribute name.
[error]     at TokenStream.error (/var/www/html/web/themes/custom/aida_theme/node_modules/melody-parser/lib/index.js:1362:22)
[error]     at new TokenStream (/var/www/html/web/themes/custom/aida_theme/node_modules/melody-parser/lib/index.js:1301:18)
[error]     at createConfiguredParser (file:///var/www/html/web/themes/custom/aida_theme/node_modules/@zackad/prettier-plugin-twig/src/parser.js:46:9)
[error]     at Object.parse (file:///var/www/html/web/themes/custom/aida_theme/node_modules/@zackad/prettier-plugin-twig/src/parser.js:76:20)
[error]     at parse4 (file:///var/www/html/web/themes/custom/aida_theme/node_modules/prettier/index.mjs:20685:24)
[error]     at async coreFormat (file:///var/www/html/web/themes/custom/aida_theme/node_modules/prettier/index.mjs:21146:7)
[error]     at async formatWithCursor (file:///var/www/html/web/themes/custom/aida_theme/node_modules/prettier/index.mjs:21348:14)
[error]     at async formatFiles (file:///var/www/html/web/themes/custom/aida_theme/node_modules/prettier/internal/cli.mjs:3468:18)
[error]     at async main (file:///var/www/html/web/themes/custom/aida_theme/node_modules/prettier/internal/cli.mjs:3876:5)
[error]     at async Module.run (file:///var/www/html/web/themes/custom/aida_theme/node_modules/prettier/internal/cli.mjs:3822:5)

And other things breaks into different things too:

hanoii commented 4 months ago

I have have a rough timeline into when a new release with fixes will be released that would be awesome.

zackad commented 4 months ago

Sorry, but not eta or timeline. It will be released as soon as I deem it ready.

Parser is not something I'm familiar with. Altough I know how they works, that doesn't mean I know how to make them work. I'm not even sure where to get started.

hanoii commented 4 months ago

I'll see if I can help, any contributing guidelines always a good thing to have to make it easer to potential contributors

hanoii commented 4 months ago

I'll see if I can help, any contributing guidelines always a good thing to have to make it easer to potential contributors

@zackad it wasn't hard to get it running