Thank you for your interest in contributing to WPTechnix Coding Standards! This document provides guidelines and instructions for contributing.
By participating in this project, you agree to maintain a respectful and inclusive environment for all contributors.
If you find a bug or have a suggestion for improvement:
- Check if the issue already exists in the GitHub Issues
- If not, create a new issue with a clear title and description
- Include relevant details such as:
- PHP version (must be 8.0+)
- PHP_CodeSniffer version
- Example code that demonstrates the issue
- Expected vs actual behavior
- Fork the repository
- Create a new branch from
main:git checkout -b feat/your-feature-name
- Make your changes
- Commit your changes using Conventional Commits:
git commit -m "feat: add new rule for..." - Push to your fork:
git push origin feat/your-feature-name
- Open a Pull Request against the
mainbranch
This project uses Conventional Commits for automated versioning and changelog generation.
<type>(<scope>): <subject>
<body>
<footer>
feat: A new feature (triggers minor version bump)fix: A bug fix (triggers patch version bump)docs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testsbuild: Changes to build system or dependenciesci: Changes to CI configurationchore: Other changes that don't modify src or test filesrevert: Reverting a previous commit
To indicate a breaking change (triggers major version bump), add BREAKING CHANGE: in the commit footer:
feat: change default line length
BREAKING CHANGE: The default line length has been changed from 120 to 100 characters.
Or use ! after the type:
feat!: change default line length
# Feature addition
git commit -m "feat: add rule for enforcing final classes"
# Bug fix
git commit -m "fix: correct regex pattern in naming convention rule"
# Documentation
git commit -m "docs: update installation instructions in README"
# Breaking change
git commit -m "feat!: require PHP 8.0 as minimum version"- PHP 8.0 or higher
- Composer 2.x
- Node.js 18.0 or higher
- npm 9.0 or higher
-
Clone the repository:
git clone https://github.com/wptechnix/coding-standards.git cd coding-standards -
Install Composer dependencies:
composer install
-
Install Node.js dependencies (for commitlint and git hooks):
npm install
This will automatically:
- Install commitlint for commit message validation
- Set up Husky git hooks
- Configure the commit-msg hook to validate commits locally
This project uses Husky to enforce commit message standards locally:
- commit-msg hook: Automatically validates your commit messages against conventional commit format
- All commits must follow the Conventional Commits specification
- Invalid commits will be rejected before they reach the repository
If your commit is rejected, check that it follows this format:
type(optional-scope): description
[optional body]
[optional footer]
Before submitting a pull request, test your ruleset changes:
- Create a test PHP file with code samples
- Run PHP_CodeSniffer with your modified ruleset:
vendor/bin/phpcs --standard=WPTechnix path/to/test/file.php
- Verify the output matches your expectations
When adding or modifying rules in WPTechnix/ruleset.xml:
- Document why the rule is being added or changed
- Ensure the rule doesn't conflict with existing rules
- Test with real-world code examples
- Update documentation if necessary
<!-- Add a new rule -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<!-- Customize a rule -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="150"/>
</properties>
</rule>
<!-- Exclude a specific rule -->
<rule ref="PSR12">
<exclude name="PSR12.Files.FileHeader"/>
</rule>Releases are fully automated using release-please:
- When commits are pushed to the
mainbranch, release-please analyzes commit messages - A release PR is automatically created/updated with:
- Updated CHANGELOG.md with all changes since last release, organized by commit type
- Release notes with version number and all changes
- Release PR title indicating the new version (e.g., "chore(main): release 1.0.0")
- When the release PR is merged:
- A new Git tag is created (e.g.,
v1.0.0) - A new GitHub release is published with release notes
- Packagist automatically detects the new tag and publishes the release
- A new Git tag is created (e.g.,
Release-please follows Semantic Versioning:
fix:commits trigger a PATCH version bump (1.0.0 → 1.0.1)feat:commits trigger a MINOR version bump (1.0.0 → 1.1.0)feat!:or commits withBREAKING CHANGE:trigger a MAJOR version bump (1.0.0 → 2.0.0)
- CHANGELOG.md is auto-generated - Do not manually edit it
- Version comes from Git tags - composer.json does not contain a version field (this is correct for Packagist packages)
- Packagist uses Git tags - When a tag is created, Packagist automatically publishes the new version
- Only merge the release PR when you're ready to publish a new version to Packagist
If you have questions about contributing, please open an issue or reach out to the maintainers.
By contributing, you agree that your contributions will be licensed under the MIT License.