Skip to content

Instantly share code, notes, and snippets.

@edmundcwm
Last active December 18, 2023 00:11
Show Gist options
  • Save edmundcwm/2fa58c1736bd675676634ff782342ac6 to your computer and use it in GitHub Desktop.
Save edmundcwm/2fa58c1736bd675676634ff782342ac6 to your computer and use it in GitHub Desktop.
PHPCS Config for WordPress development
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress" namespace="WordPressCS\WordPress" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>Default WordPress Coding Standards</description>
<!-- Lint all PHP files in the project directory by default. -->
<file>.</file>
<rule ref="WordPress-Core">
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
</rule>
<!-- Force short array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found">
<type>warning</type>
</rule>
<rule ref="WordPress"/>
<!-- Enable this if VIP WPCS is installed -->
<!-- <rule ref="WordPress-VIP-Go"/> -->
<config name="testVersion" value="8.0-"/>
<rule ref="PHPCompatibilityWP"/>
<exclude-pattern>*/assets/*</exclude-pattern>
<exclude-pattern>*/tools/wordpress/*</exclude-pattern>
<exclude-pattern>*/tools/wp-content/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/*.asset.php</exclude-pattern>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment