From c340c7370179f67323cff6d8cbf0978b978e8292 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 16 Jul 2026 08:46:35 -0500 Subject: [PATCH] Hold changed lines and new files to the full WordPress standard Add phpcs-clean.xml.dist: the stock WordPress coding standard with no sniff exclusions, only the environment config (minimum_wp_version, testVersion, PHPCompatibilityWP) and the shared file/vendor exclude-patterns. Point phpcs-branch.php at this ruleset for both the changed-lines path (modified files) and the whole-file path (new files), so newly written code is held to the unmodified standard while the existing tree is only checked on the lines a branch actually touches. phpcs.xml.dist is untouched and remains the lenient baseline for the whole-repo `composer lint`. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_0178d9rQN6YbCuz5LetN7Rzi --- .github/bin/phpcs-branch.php | 6 +++--- .github/workflows/phpcs.yml | 1 + phpcs-clean.xml.dist | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 phpcs-clean.xml.dist diff --git a/.github/bin/phpcs-branch.php b/.github/bin/phpcs-branch.php index 1ce95a83cf..e1e464dd50 100644 --- a/.github/bin/phpcs-branch.php +++ b/.github/bin/phpcs-branch.php @@ -12,7 +12,7 @@ namespace WordPressOrg\Bin\PHPCS_Changed; function run_phpcs( $file, $bin_dir ) { - exec( "$bin_dir/phpcs $file -snq", $output, $exec_exit_status ); + exec( "$bin_dir/phpcs $file --standard=./phpcs-clean.xml.dist -snq", $output, $exec_exit_status ); echo implode( "\n", $output ); return $exec_exit_status; } @@ -27,10 +27,10 @@ function run_phpcs_changed( $file, $git, $base_branch, $bin_dir ) { exec( "$git diff $base_branch $file > $name.diff" ); exec( "$git show $base_branch:$file > $name.test.php" ); - exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs.xml.dist --report=json -snq > $name.orig.phpcs" ); + exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs-clean.xml.dist --report=json -snq > $name.orig.phpcs" ); exec( "cat $file > $name.test.php" ); - exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs.xml.dist --report=json -snq > $name.phpcs" ); + exec( "$bin_dir/phpcs $name.test.php --standard=./phpcs-clean.xml.dist --report=json -snq > $name.phpcs" ); $cmd = "$bin_dir/phpcs-changed --diff $name.diff --phpcs-orig $name.orig.phpcs --phpcs-new $name.phpcs"; exec( $cmd, $output, $exec_exit_status ); diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 5c461cdaab..d25f168b5a 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -5,6 +5,7 @@ on: paths: - '**.php' - phpcs.xml.dist + - phpcs-clean.xml.dist - composer.json - .github/workflows/phpcs.yml - .github/bin/phpcs-branch.php diff --git a/phpcs-clean.xml.dist b/phpcs-clean.xml.dist new file mode 100644 index 0000000000..2a2b3e5bb2 --- /dev/null +++ b/phpcs-clean.xml.dist @@ -0,0 +1,35 @@ + + + Full WordPress Coding Standards, applied to changed lines and new files only (via .github/bin/phpcs-branch.php). No sniff exclusions — new code is held to the stock standard. + + + + + + + */vendor/* + */node_modules/* + */plugins/plugin-directory/libs/* + */plugins/theme-directory/lib/* + */plugins/wpf-stripe/stripe-php/* + + + */plugins/*/build/index.asset.php + + + *.js[x]? + *.[s]?css + + + . + + + + + + + + + + +