Check Drupal coding standard by phpcs in git pre-commit hook | TO THE NEW Blog

General News

Summary

In this tutorial, you will learn how to improve the custom code, theme and module, and general code development by using the pre-commit hook on git. Git pre-commit validates Drupal coding standards on files before committing them and returns a message to fix each line of code on the files having errors. Follow the next steps to set up the pre-commit git hook with Drupal coding standards: • Add the below pre-commit code to the hooks/pre-commit file. composer require drupal/coder" echo exit 1 fi # Retrieve staged files FILES=$(git diff --cached --name-only --diff-filter=ACMR HEAD) # Run the sniffer echo "Running Drupal Coder." Now execute Composer install in your project directory How to use it This is going to execute Drupal Coder on each file and returns messages on the terminal in case of finding errors on files.

Classifications

industries
No industries detected
applications
Web and Content Management

AskAI Classifications

Labels
No AI classifications detected

Linked Companies