Hold changed lines and new files to the full WordPress standard - #714
Hold changed lines and new files to the full WordPress standard#714obenland wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0178d9rQN6YbCuz5LetN7Rzi
c340c73 to
000b0a5
Compare
CI only enforces the ruleset on lines a branch touches and on new files, so sniff exclusions only ever shield newly written code. Remove them all, keeping just the deliberate deviations: direct/meta DB queries (custom tables are the architecture here), the I18nTextDomainFixer utility, short array syntax, and unknown capabilities pending the allowlist in PR WordPress#583. Supersedes PR WordPress#714, which proposed the same standard via a second config file; a single config can't drift apart from what CI enforces and keeps local lint results identical to CI. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Superseded by #771: since CI only enforces the ruleset on changed lines and new files, stripping the exclusions from the single |
Let's use
WordPressas our coding standard. With AI writing most of our code now, it's trivial to have it conform new and updated code to the full standard, and everyone reading the code get to benefit from it.What
Adds
phpcs-clean.xml.dist— the stock WordPress coding standard with no sniff exclusions — and points the branch linter (.github/bin/phpcs-branch.php) at it. Newly written code is now held to the unmodified standard, while the existing tree is only ever checked on the lines a branch actually touches.How it works
The linter already scopes itself to changed lines + new files:
phpcs-changed, reporting only on lines the branch changed.phpcson the whole file.Both paths now pass
--standard=./phpcs-clean.xml.dist. Existing code is untouched until someone edits it.Scope of each ruleset
phpcs.xml.distcomposer lint(whole repo) — unchangedphpcs-clean.xml.distWordPress, no exclusionsphpcs-branch.php(changed lines + new files)phpcs-clean.xml.distkeeps only the environment config (minimum_wp_version,testVersion,PHPCompatibilityWP) and the shared file/vendorexclude-patterns.Note
The stock
WordPress.WP.Capabilitiessniff is now active on changed code and will flag wporg-specific custom capabilities as unknown. When that happens, the cap gets documented in place rather than silenced:Because this only fires on changed lines and new files, the list grows only with caps that actually touch new code.
🤖 Generated with Claude Code
https://claude.ai/code/session_0178d9rQN6YbCuz5LetN7Rzi