diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2eef05f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,26 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.0] - Unreleased +### Added +- Added `PHPCompatibilityWP` rule. +- Added `VariableAnalysis` rule. +- Added `WordPress` rule. +- Added `WordPressVIPMinimum` rule. +- Added `WordPress-VIP-Go` rule. +- Excluded `WordPress.Files.FileName.InvalidClassFileName` sniff. +- Excluded `WordPress.Files.FileName.NotHyphenatedLowercase` sniff. +- Added relative exclude pattern `^bower_components/*` for the `bower_components` folder. +- Added relative exclude pattern `^node_modules/*` for the `node_modules` folder. +- Added relative exclude pattern `^vendor/*` for the `vendor` folder. +- Added relative exclude pattern `^vendor-bin/*` for the `vendor-bin` folder. +- Added relative exclude pattern `^wordpress/*` for the `wordpress` folder. +- Added relative exclude pattern `^wp-content/*` for the `wp-content` folder. + +[Unreleased]: https://github.com/pronamic/wp-coding-standards/compare/1.0.0...HEAD +[1.0.0]: https://github.com/pronamic/wp-coding-standards/releases/tag/1.0.0 diff --git a/PronamicWP/ruleset.xml b/PronamicWP/ruleset.xml index 6f31d95..bf9d633 100644 --- a/PronamicWP/ruleset.xml +++ b/PronamicWP/ruleset.xml @@ -7,31 +7,69 @@ > Pronamic WordPress WordPress Coding Standards - - - - + + + + + + + + + + + + + + + + + + ^bower_components/* + + + ^node_modules/* + + + ^vendor/* + + + ^vendor-bin/* + + + ^wordpress/* + + + ^wp-content/* + + + + + + + + + diff --git a/README.md b/README.md index 4668af1..2d428eb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,128 @@ # Pronamic WordPress WordPress Coding Standards Pronamic WordPress WordPress Coding Standards for PHP_CodeSniffer. + +## PHP_CodeSniffer + +https://github.com/squizlabs/PHP_CodeSniffer + +### Arguments + +https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage + +#### `colors` + +By default use colors in output. + +```xml + +``` + +#### `extensions` + +By default only check files with `php` extension: + +```xml + +``` + +#### `parallel` + +By default use `8` parallel processes. + +```xml + +``` + +https://github.com/squizlabs/PHP_CodeSniffer/issues/1732 + +#### `sp` + +By default show sniff codes in all reports. +By default show progress of the run. + +```xml + +``` + +## Rules + +### PHPCompatibilityWP + +https://github.com/PHPCompatibility/PHPCompatibilityWP + +By default this package test PHP 5.6 and higher via the following setting: + +```xml + +``` + +### PHPCompatibility + +https://github.com/PHPCompatibility/PHPCompatibility + +Required through `PHPCompatibilityWP`. + +### WordPress + +https://github.com/WordPress/WordPress-Coding-Standards + +By default the minimum WordPress version to check is set to `4.7` via the following setting: + +```xml + +``` + +https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters + +### WordPressVIPMinimum + +https://github.com/Automattic/VIP-Coding-Standards + +### WordPress-VIP-Go + +https://github.com/Automattic/VIP-Coding-Standards + +### VariableAnalysis + +https://github.com/sirbrillig/phpcs-variable-analysis + +## Exclusions + +### `WordPress.Files.FileName.InvalidClassFileName` + +According to the WordPress PHP Coding Standards: + +> Class file names should be based on the class name with `class-` prepended and the underscores in the class name replaced with hyphens, for example `WP_Error` becomes: +> +> ``` +> class-wp-error.php +> ``` + +_Source:_ https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions + +This sniff will check on this naming convention: + +``` +Class file names should be based on the class name with "class-" prepended. Expected class-test.php, but found Test.php. +``` + +We often use the [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading mechanism and therefore deviate from it. + +### `WordPress.Files.FileName.NotHyphenatedLowercase` + +According to the WordPress PHP Coding Standards: + +> Files should be named descriptively using lowercase letters. Hyphens should separate words. +> +> ``` +> my-plugin-name.php +> ``` + +_Source:_ https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions + +``` +Filenames should be all lowercase with hyphens as word separators. Expected test.php, but found Test.php. +``` + +We often use the [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading mechanism and therefore deviate from it.