Ensuring coding standards
We will write a lot of code to implement the requested layout and we will use different languages (Twig, HTML, CSS, and JavaScript). To avoid every developer using their own style, we must define a set of rules that everyone in the team has to adhere to. This will greatly simplify the task of reading the code for other developers, and also help when reviewing code changes.
Drupal defines a set of tools and rules for its own files, and we should use the same standards too.
We’ll use different tools for different languages:
- Stylelint for CSS files
- ESLint for JavaScript files
- PHPCS for PHP files
Stylelint
To add Stylelint (https://stylelint.io/) to our theme, follow these steps:
- Open a shell into the web container:
ddev ssh
- Then go to the theme folder:
cd web/themes/custom/alps_trips
- Install the required packages:
yarn add –D stylelint stylelint-config-standard stylelint-config-tailwindcss stylelint-order...