VincentLanglet / Twig-CS-Fixer

A tool to automatically fix Twig Coding Standards issues
MIT License
234 stars 25 forks source link

Integration with Symfony/UX #135

Closed smnandre closed 1 year ago

smnandre commented 1 year ago

Hi @VincentLanglet ! Love your tool!

We are currently considering integrating Twig-CS-Fixer into the SymfonyUX CI. There are some issues related to custom Twig components tags today (props tag/comment at least)

I know you worked on it, what are the blocking points you see today ? How can we help ? Do you see a "most praactical way" to ensure a great compatibility in the future ?

VincentLanglet commented 1 year ago

Hi, I never really used symfonyUx.

But if it works like any other twig-tag, they are correctly understood by twig engine thanks to TwigExtension and TokenParser. There is a small section about how it can be added to the config: https://github.com/VincentLanglet/Twig-CS-Fixer?tab=readme-ov-file#token-parser

I also automatically add some token parser here: https://github.com/VincentLanglet/Twig-CS-Fixer?tab=readme-ov-file#token-parser

I already made a PR for the component parser here: https://github.com/VincentLanglet/Twig-CS-Fixer/pull/124

An easy PR could be done for the props token parser since it has no constructor so I can add https://github.com/symfony/ux/blob/2.x/src/TwigComponent/src/Twig/PropsTokenParser.php so

if (class_exists(PropsTokenParser::class)) {
     $this->addTokenParser(new PropsTokenParser());
}

Can be added.

Can you do the PR with a test similar of the component one @smnandre ?

I know you worked on it, what are the blocking points you see today ? How can we help ? Do you see a "most praactical way" to ensure a great compatibility in the future ?

Currently the issue I have is:

If you find a way to automatically simulate the work done by the TwigEnvironmentPass this would be great.

smnandre commented 1 year ago

Thank you for this detailed response. I will indeed look into the 'props' tag, and then we can consider a more sustainable/smooth solution for the future!

smnandre commented 1 year ago

PR for the props tag done: https://github.com/VincentLanglet/Twig-CS-Fixer/pull/136

I'll try to play next week with the configurator and see what can be done to ease the integration.

VincentLanglet commented 1 year ago

Released in 1.5.0