Skip to content

Instantly share code, notes, and snippets.

@pdewouters
Created May 30, 2024 12:25
Show Gist options
  • Save pdewouters/39d6b4f1c2d60e5c1538163774c8ed18 to your computer and use it in GitHub Desktop.
Save pdewouters/39d6b4f1c2d60e5c1538163774c8ed18 to your computer and use it in GitHub Desktop.
WP codesniffer config
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="MyConfig" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
<description>My Coding standards</description>
<file>.</file>
<arg name="extensions" value="php" />
<arg name="colors" />
<arg value="ps" />
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/build/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="."/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>
<rule ref="WordPress">
<exclude name="Universal.Arrays.DisallowShortArraySyntax" />
<exclude name="Universal.Operators.DisallowShortTernary" />
<exclude name="WordPress.PHP.YodaConditions" />
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_trigger_error" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent" />
<exclude name="Universal.WhiteSpace.PrecisionAlignment" />
<exclude name="Squiz.Commenting.FileComment" />
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
<property name="exact" value="true"/>
<property name="tabIndent" value="false"/>
</properties>
</rule>
<rule ref="Generic.WhiteSpace.DisallowTabIndent" />
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="indent" value="2"/>
</properties>
</rule>
<rule ref="PSR2.ControlStructures.SwitchDeclaration">
<properties>
<property name="indent" value="2"/>
</properties>
</rule>
<rule ref="WordPress.Arrays.ArrayIndentation">
<properties>
<property name="tabIndent" value="false" />
</properties>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="myprefix"/>
</property>
</properties>
</rule>
<arg name="tab-width" value="2"/>
<config name="minimum_wp_version" value="6.5.3"/>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment