brainsum / drupal-dev-tools
Dev tools for Drupal development.
Installs: 6 746
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 5
Forks: 2
Open Issues: 5
Type:composer-plugin
Requires
- php: >=8.1
- composer-plugin-api: ^1.1 || ^2
- drupal/core-dev: ^10.0.0 || ^11.0.0
- drupal/devel: ^5.0
- ergebnis/composer-normalize: ^2.28
- johnatas-x/grumphp-drupal-check: ^2.2
- laravel/serializable-closure: ^1.3
- mxr576/ddqg: dev-no-insecure-versions
- mxr576/ddqg-composer-audit: ^1.2
- php-parallel-lint/php-parallel-lint: ^1.3
- roave/security-advisories: dev-latest
- vincentlanglet/twig-cs-fixer: ^3.0
Suggests
- drupal/examples: ^4.0
README
About
Package / Composer plugin for standardizing development tools.
Setup
Preparation
If you already have a grumphp.yml
and/or phpcs.xml
file in your project, you should rename them. E.g. mv grumphp.yml grumphp.yml.backup
If you want to add new tasks and rules on a case-by-case basis, check the files in the distfiles
folder of this package.
Note: This package is not going to overwrite existing ones, but it might not work with them either.
Installation
In your project, simply use
composer require --dev brainsum/drupal-dev-tools:^6.0.0
Settings
Extend
In the grumphp.yml
file in your project, add the following:
imports:
- { resource: vendor/brainsum/drupal-dev-tools/convention/grumphp.yml }
This will signal grumphp to import everything from this package.
You can customize the rules when needed, too:
parameters:
convention.git_commit_message_whitelist: ['/^([A-Z]+-[\d]+ )+\| [A-Za-z\d\s\.]+([^.])+\.{1}$/s']
For more information, see:
Override
The files grumphp.yml
and phpcs.xml
should now be created in your project root.
They should be good to go, but you should take a look at them and customize them for the current project as necessary.
E.g, phpcs.xml descriptions, namings, checked folders, etc.; grumphp.yml php version, etc.
If they, for some reason, don't get created, you can copy their contents from the files from vendor/brainsum/drupal-dev-tools/distfiles
as needed.
If you just want to use some settings from grumphp.yml
, not the whole thing, see convention/grumphp.yml
,
as distfiles/grumphp.yml
is only an import file and doesn't contain any other directives.
GrumPHP
Settings
For the pre-defined settings see distfiles/grumphp.yml
and convention/grumphp.yml
.
Note, we are also trying to create a phpcs.xml
file in the project root. The source for that file is also in the distfiles
folder.
Twig Cs Fixer
The .twig-cs-fixer.php
file is also created in the project root copy of distfiles/.twig-cs-fixer.php
.
Twig CS Fixer will run on web/modules/custom, web/themes/custom, and web/profiles/custom directories by default.
We are using custom rules for Twig CS Fixer:
NoRawFilterRule
This rule disallows the use of the raw
filter for variables, as it can lead to security vulnerabilities if not used carefully.
{{ variable|raw }}
You can disable this rule (before the line with raw
filter) by adding the following comment in your Twig template:
{# @TwigCsIgnoreNoRawFilterRule #}
NoQuotationMarkAttributeRule
This rule disallows the use of attributes without quotes, as it can lead to XSS vulnerabilities.
<div class="wrapper" id={{ item.label }}></div>
ForbiddenFunctionRule
This rule disallows the use of certain Twig functions that are considered as debugging functions.
- dump, dpm, kint, print_r, var_dump, var_export, vardumper
{{ dump() }}
For more information, see the Twig CS Fixer documentation.