Skip to content

Code quality

This module uses several code quality tools to maintain standards. Run these commands from the module root directory.

Running all checks at once

composer lint

Individual checks:

composer lint:cspell    # Spell checking only
composer lint:phpcs     # PHP code style only
composer lint:phpstan   # Static analysis only
composer lint:eslint    # JavaScript linting only
composer lint:stylelint # CSS linting only

Option 2: Shell script

./lint.sh

The script provides colored output and a summary of results. Exits with code 1 if any check fails.

Individual tools

Spell checking (cspell)

npx cspell "**/*.{php,js,yml,md}" --config .cspell.json

PHP Code Sniffer (phpcs)

phpcs --standard=Drupal,DrupalPractice \
  --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml \
  src/ tests/

PHPStan

# From Drupal root
vendor/bin/phpstan analyze web/modules/contrib/ai_context

# Or from module directory with custom config
phpstan analyze --configuration=phpstan.neon.dist

ESLint

npx eslint js/**/*.js

Stylelint

npx stylelint "css/**/*.css"

Prerequisites

  • PHP CodeSniffer: composer require --dev drupal/coder
  • PHPStan: included with Drupal 11 core dev dependencies
  • Node tools (cspell, eslint, stylelint): installed via npm/npx (no installation needed with npx)

Notes

Running the full lint on the entire module may show pre-existing warnings in other files. To check only specific files you are working on, use the individual tool commands with specific file paths.