Tools Overview

ToolLanguagePurpose
ESLintJavaScriptLinting and static analysis
stylelintCSSCSS linting and standards
PHPCSPHPPHP coding standards enforcement
PrettierJS/CSS/JSONCode formatting (via @wordpress/scripts)
EditorConfigAllConsistent editor settings

ESLint (JavaScript)

ESLint enforces the WordPress JavaScript coding standards with Aegis-specific rules.

Running ESLint

Copied!
Shell
# Lint all JavaScript filesnpm run lint:js# Lint with auto-fixnpm run lint:js -- --fix

Configuration

ESLint uses the @wordpress/eslint-plugin configuration as its base:

Copied!
JSON
{ "extends": ["plugin:@wordpress/eslint-plugin/recommended"], "rules": { // Aegis-specific overrides }}

Key Rules

RuleEnforcement
No unused variablesError
No console.log in productionWarning
WordPress i18n usageRequired for user-facing strings
React hooks rulesEnforced for block editor components
Import orderAlphabetical, grouped by type
No var declarationsMust use const/let

Auto-Fixing

Many ESLint issues can be fixed automatically:

Copied!
Shell
npm run lint:js -- --fix

Issues that require manual intervention will remain as errors in the output.

stylelint (CSS)

stylelint enforces the WordPress CSS coding standards.

Running stylelint

Copied!
Shell
# Lint all CSS filesnpm run lint:css# Lint with auto-fixnpm run lint:css -- --fix

Configuration

stylelint uses the @wordpress/stylelint-config as its base:

Copied!
JSON
{ "extends": ["@wordpress/stylelint-config"], "rules": { // Aegis-specific overrides }}

Key Rules

RuleEnforcement
Property orderGrouped by type (position, display, box model, typography)
Color formatHex values must be lowercase
No duplicate propertiesError
Selector specificityMax specificity enforced
Custom property namingMust follow theme token conventions
No !importantWarning (avoid unless necessary)
Unit usagePrefer rem/em for typography, px for borders

PHPCS (PHP)

PHPCS enforces the WordPress PHP coding standards using the WordPress Coding Standards ruleset.

Running PHPCS

Copied!
Shell
# Check all PHP filescomposer standards:check# (also available as: composer lint, or npm run lint:php)# Or directly./vendor/bin/phpcs# Auto-fix with PHPCBFcomposer standards:fix# Or directly./vendor/bin/phpcbf

Configuration

PHPCS is configured via phpcs.xml.dist:

Copied!
XML
<?xml version="1.0"?><ruleset name="Aegis Theme"> <description>Coding standards for Aegis theme</description> <rule ref="WordPress"/> <rule ref="WordPress-Extra"/> <rule ref="WordPress-Docs"/> <config name="text_domain" value="aegis"/> <config name="minimum_wp_version" value="7.0"/> <config name="prefixes" value="aegis,Aegis"/> <file>./inc</file> <file>./functions.php</file> <exclude-pattern>/vendor/*</exclude-pattern> <exclude-pattern>/node_modules/*</exclude-pattern> <exclude-pattern>/build/*</exclude-pattern></ruleset>

Key Standards

StandardEnforcement
WordPress naming conventionsFunctions: snake_case, Classes: PascalCase
Function prefixingAll functions prefixed with aegis_
Hook documentationInline documentation for all hooks
Escaping outputAll output must be escaped
Sanitizing inputAll input must be sanitized
Nonce verificationRequired for form processing
Text domainMust use aegis for all translatable strings

Running All Linters

To run all linting tools in a single command:

Copied!
Shell
npm run lint

This runs ESLint, stylelint, and PHPCS in sequence.

Pre-Commit Hooks

Linting runs automatically before each commit via Git hooks (configured with husky or similar):

  1. Staged JavaScript files are checked with ESLint.
  2. Staged CSS files are checked with stylelint.
  3. Staged PHP files are checked with PHPCS.
  4. If any linter reports errors, the commit is blocked.

EditorConfig

The .editorconfig file ensures consistent formatting across editors:

Copied!
INI
root = true[*]charset = utf-8end_of_line = lfindent_style = tabindent_size = 4insert_final_newline = truetrim_trailing_whitespace = true[*.{json,yml,yaml}]indent_style = spaceindent_size = 2[*.md]trim_trailing_whitespace = false

IDE Integration

Most editors can run these tools automatically on save:

VS Code Settings

Copied!
JSON
{ "editor.formatOnSave": true, "eslint.validate": ["javascript", "javascriptreact"], "stylelint.validate": ["css"], "phpcs.enable": true}

Ignoring Rules

When you need to suppress a linting rule (use sparingly):

ESLint

Copied!
JavaScript
// eslint-disable-next-line no-consoleconsole.log( 'Debug output' );

stylelint

Copied!
CSS
/* stylelint-disable-next-line declaration-no-important */color: red !important;

PHPCS

Copied!
PHP
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscapedecho $already_escaped_html;

Always include a comment explaining why the rule is being suppressed.

Continuous Integration

Linting runs as part of the CI/CD pipeline on every pull request. A PR cannot be merged if linting fails. See Contributing for the full pull request workflow.

Next Steps