Skip to main content

Code quality

Vortex ships pre-configured linters for PHP, Twig, JavaScript, CSS, Gherkin, Docker Compose files and Dockerfiles. Each tool has its own configuration file with defaults that work for Drupal projects out of the box.

ToolChecksCommand
DCLintDocker Compose filesdclint .
ESLintJavaScript in custom modulesahoy lint-fe
Gherkin LintBehat feature filesahoy lint-tests
HadolintDockerfileshadolint .docker/*.dockerfile
PHPCSPHP coding standardsahoy lint-be
PHPStanPHP static analysisahoy lint-be
RectorDeprecated PHP and Drupal code, automated refactoringahoy lint-be
SDC DevelSingle Directory Componentsahoy lint-sdc
StylelintCSS in custom modules, SCSS in the custom themeahoy lint-fe
Twig CS FixerTwig templatesahoy lint-fe

Running

ahoy lint runs all the code quality checks: back-end (PHPCS, PHPStan, Rector), front-end (Twig CS Fixer, ESLint, Stylelint) and test linting (Gherkin Lint).

The checks are grouped into Ahoy commands, each with a matching fix command where the tools support automatic fixes:

CommandToolsFix command
ahoy lintEverything below except ahoy lint-sdcahoy lint-fix
ahoy lint-bePHPCS, PHPStan, Rectorahoy lint-be-fix
ahoy lint-feTwig CS Fixer, ESLint, Stylelint (custom modules and the custom theme)ahoy lint-fe-fix
ahoy lint-testsGherkin Lint-
ahoy lint-sdcSDC Devel (requires a provisioned site)-

ahoy lint-be-fix runs Rector and then PHPCBF; ahoy lint-fe-fix runs Twig CS Fixer, ESLint and Stylelint with their fix flags. PHPStan and Gherkin Lint only report problems.

DCLint and Hadolint are not installed locally and have no Ahoy commands. Install them on your system to run them by hand; in continuous integration they run from their official Docker images.

Continuous integration

The linters run in the lint job of the continuous integration pipeline and fail the build on violations. SDC Devel runs in the build job instead, after the site is provisioned.

Set the tool's VORTEX_CI_*_IGNORE_FAILURE variable to 1 to let the build pass while the tool still runs and reports violations - see Ignore tool failures.