Coder covers PHP, JS and CSS.

Are there plans to add the new Twig coding standards review as part of Coder?

Comments

andrewsuth created an issue. See original summary.

markdorison’s picture

Version: 8.x-2.x-dev » 8.x-3.x-dev

Is this on anyone's radar these days? What are people doing to check even simple rules like tabs/spaces in twig templates?

adamzimmermann’s picture

It seems that we might not want to duplicate existing open-source work in this area.

I have found several tools.

friendsoftwig/twigcs

  • "Twigcs aims to be what phpcs is to php. It checks your codebase for violations on coding standards."
  • This quote is promising.
  • More community support.
  • "At the moment the only available standard is the official one from twig."
  • This link is broken in their README, so that makes it hard to evaluate it fully.
  • The Drupal.org documentation for Twig points to this same broken site. More details below.
  • No automated code fixing, which could be a real pain if it finds a lot of issues.
  • Required via Composer
  • Rules: https://github.com/friendsoftwig/twigcs/tree/master/src/Rule
  • The output isn't nearly as nice.

VincentLanglet/Twig-CS-Fixer

trivago/prettier-plugin-twig-melody

  • Has an option to follow the Symfony Twig 2.x Coding Standard.
  • Required via Yarn instead of Composer.

FWIW the Symfony Twig coding standards are identical from 2.x to 3.x:

  • twig.symfony.com/doc/2.x/coding_standards.html
  • twig.symfony.com/doc/3.x/coding_standards.html

The Twig coding standards page on Drupal.org references the broken Sensio Labs website standard.

I have chosen to use VincentLanglet/Twig-CS-Fixer for the time being, as it offered automated code style fixes.

I'm interested to see what others think and how we might move this forward. The answer might be that this is not a coder issue and should be moved to a core issue for further discussion.

Chi’s picture

quietone’s picture