Skip to content

Commit

Permalink
Add drupal-rector to tooling. (#77)
Browse files Browse the repository at this point in the history
Co-authored-by: Edouard Cunibil <[email protected]>
  • Loading branch information
DuaelFr and Edouard Cunibil authored May 26, 2023
1 parent baeeebe commit 2afeed5
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- apt-get install -y nodejs
- npm install --global yarn
run:
- cd /app/web && composer require drush/drush && composer install
- cd /app/web && composer require drush/drush palantirnet/drupal-rector && composer install
- mkdir -p private/browsertest_output
- yarn install --non-interactive --cwd /app/web/core
overrides:
Expand Down Expand Up @@ -43,6 +43,9 @@ tooling:
service: appserver
cmd:
web/vendor/drush/drush/drush --root=/app/web --uri=https://drupal-contributions.lndo.site
rector:
service: appserver
cmd: web/vendor/bin/rector
si:
service: appserver
description: Install Drupal
Expand Down
37 changes: 37 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

use DrupalFinder\DrupalFinder;
use DrupalRector\Set\Drupal8SetList;
use DrupalRector\Set\Drupal9SetList;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
// Adjust the set lists to be more granular to your Drupal requirements.
// @todo find out how to only load the relevant rector rules.
// Should we try and load \Drupal::VERSION and check?
$rectorConfig->sets([
Drupal8SetList::DRUPAL_8,
Drupal9SetList::DRUPAL_9,
]);

$parameters = $rectorConfig->parameters();

$drupalFinder = new DrupalFinder();
// Use the appropriate folder so DrupalFinder knows what to do.
$drupalFinder->locateRoot(__DIR__ . '/web');
$drupalRoot = $drupalFinder->getDrupalRoot();
$rectorConfig->autoloadPaths([
$drupalRoot . '/core',
$drupalRoot . '/modules',
$drupalRoot . '/profiles',
$drupalRoot . '/themes'
]);

$rectorConfig->skip(['*/upgrade_status/tests/modules/*']);
$rectorConfig->fileExtensions(['php', 'module', 'theme', 'install', 'profile', 'inc', 'engine']);
$rectorConfig->importNames(true, false);
$rectorConfig->importShortClasses(false);
$parameters->set('drupal_rector_notices_as_comments', true);
};

0 comments on commit 2afeed5

Please sign in to comment.