Skip to content

Commit

Permalink
Fixes to lint commands and add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
justafish committed Oct 7, 2024
1 parent 6cea035 commit aa497f7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,20 @@ a11y test for a custom admin theme
```
ddev nightwatch --tag a11y:admin --adminTheme seven
```

## Core Linting

This will run static tests against core standards.

```
ddev drupal lint:phpstan
ddev drupal lint:phpcs
ddev drupal lint:js
ddev drupal lint:css
ddev drupal lint:cspell
# CSpell against only modified files
ddev drupal lint:cspell --modified-only
```

You can run all linting with `ddev drupal lint`, or with fail-fast turned on:
`ddev drupal lint --stop-on-failure`
3 changes: 2 additions & 1 deletion core-dev/phpunit-chrome.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
# cspell:ignore ddev
#ddev-generated
-->
<!-- For how to customize PHPUnit configuration, see core/tests/README.md. -->
Expand Down Expand Up @@ -35,7 +36,7 @@

<!-- Deprecation testing is managed through Symfony's PHPUnit Bridge.
The environment variable SYMFONY_DEPRECATIONS_HELPER is used to configure
the behaviour of the deprecation tests.
the behavior of the deprecation tests.
See https://symfony.com/doc/current/components/phpunit_bridge.html#configuration
Drupal core's testing framework is setting this variable to its defaults.
Projects with their own requirements need to manage this variable
Expand Down
3 changes: 2 additions & 1 deletion core-dev/phpunit-firefox.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
# cspell:ignore ddev
#ddev-generated
-->
<!-- For how to customize PHPUnit configuration, see core/tests/README.md. -->
Expand Down Expand Up @@ -35,7 +36,7 @@

<!-- Deprecation testing is managed through Symfony's PHPUnit Bridge.
The environment variable SYMFONY_DEPRECATIONS_HELPER is used to configure
the behaviour of the deprecation tests.
the behavior of the deprecation tests.
See https://symfony.com/doc/current/components/phpunit_bridge.html#configuration
Drupal core's testing framework is setting this variable to its defaults.
Projects with their own requirements need to manage this variable
Expand Down
2 changes: 1 addition & 1 deletion core-dev/src/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LintCommand extends Command {
protected function configure(): void {
$this->setName('lint')
->setDescription('Run lint tests.')
->addOption('stop-on-failure', null, InputOption::VALUE_NONE, 'Tail the completion debug log');
->addOption('stop-on-failure', null, InputOption::VALUE_NONE, 'Stop all test execution once a failure is found.');
}

/**
Expand Down
10 changes: 8 additions & 2 deletions core-dev/src/Command/LintCspellCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;

Expand All @@ -14,14 +15,19 @@ class LintCspellCommand extends Command {
*/
protected function configure(): void {
$this->setName('lint:cspell')
->setDescription('Run CSpell analysis against modified files.');
->setDescription('Run CSpell analysis.')
->addOption('modified-only', null, InputOption::VALUE_NONE, 'Only run cspell on modified files.');
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$command = "cd core && git diff --name-only | sed \"s_^_../_\" | yarn run spellcheck:core --no-must-find-files --file-list stdin";
$modified_only = $input->getOption('modified-only');
$command = "cd core && yarn run spellcheck:core --no-must-find-files";
if ($modified_only) {
$command = "cd core && git diff --name-only | sed \"s_^_../_\" | yarn run spellcheck:core --no-must-find-files --file-list stdin";
}
$phpcs = Process::fromShellCommandline($command);
$output->writeln($command);
$phpcs->setTimeout(0);
Expand Down

0 comments on commit aa497f7

Please sign in to comment.