Last active
March 8, 2024 17:09
-
-
Save IlanVivanco/323801486fc6987b6132acbc4a8f802c to your computer and use it in GitHub Desktop.
PHPCS WordPress coding standards config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<ruleset name="WordPress Theme Coding Standards" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> | |
<description>A custom set of rules to check for a WPized WordPress project</description> | |
<!-- General PHPCS config. --> | |
<file>.</file> | |
<arg value="sp"/> | |
<arg name="extensions" value="php"/> | |
<arg name="basepath" value="."/> | |
<arg name="parallel" value="8"/> | |
<!-- Exclude patterns. --> | |
<exclude-pattern>/vendor/*</exclude-pattern> | |
<exclude-pattern>/node_modules/*</exclude-pattern> | |
<!-- WordPress Rules --> | |
<!-- See https://github.com/WordPress/WordPress-Coding-Standards --> | |
<rule ref="WordPress"> | |
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/> | |
<exclude name="PHPCompatibility.FunctionDeclarations"/> | |
<exclude name="PHPCompatibility.Syntax"/> | |
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/> | |
<exclude name="Squiz.Commenting.InlineComment"/> | |
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/> | |
<exclude name="Squiz.Commenting.FileComment"/> | |
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/> | |
<exclude name="Squiz.PHP.CommentedOutCode"/> | |
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"/> | |
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/> | |
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query"/> | |
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_tax_query"/> | |
<exclude name="WordPress.Files.FileName"/> | |
<exclude name="WordPress.NamingConventions.ValidVariableName"/> | |
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound"/> | |
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound"/> | |
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound"/> | |
<exclude name="WordPress.PHP.YodaConditions"/> | |
<exclude name="WordPress.PHP.StrictInArray"/> | |
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped"/> | |
<exclude name="WordPress.Security.NonceVerification.Recommended"/> | |
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/> | |
</rule> | |
<!-- WordPress I18n config. --> | |
<config name="minimum_supported_wp_version" value="6.0"/> | |
<rule ref="WordPress.WP.I18n"> | |
<properties> | |
<property name="text_domain" type="array"> | |
<element value="ntmatter"/> | |
<element value="epicdevs"/> | |
<element value="ilanvivanco"/> | |
</property> | |
</properties> | |
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/> | |
</rule> | |
<!-- WordPress naming config. --> | |
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"> | |
<properties> | |
<property name="prefixes" type="array"> | |
<element value="ntm_"/> | |
<element value="epic_"/> | |
<element value="epicd_"/> | |
<element value="ilan_"/> | |
<element value="iv_"/> | |
</property> | |
</properties> | |
</rule> | |
<!-- WordPress arrays config. --> | |
<rule ref="WordPress.Arrays.MultipleStatementAlignment"> | |
<properties> | |
<property name="alignMultilineItems" value="!=100"/> | |
<property name="exact" value="false" phpcs-only="true"/> | |
</properties> | |
</rule> | |
<!-- Allow for theme specific exceptions to the file name rules based on the theme hierarchy. --> | |
<rule ref="WordPress.Files.FileName"> | |
<properties> | |
<property name="is_theme" value="true"/> | |
</properties> | |
</rule> | |
<!-- PHP Compatibility --> | |
<!-- See https://github.com/PHPCompatibility/PHPCompatibilityWP --> | |
<config name="testVersion" value="7.4-"/> | |
<rule ref="PHPCompatibility"> | |
<!-- Exclude PHP constants back-filled by PHPCS. --> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_finallyFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_yieldFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_ellipsisFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_powFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_pow_equalFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_spaceshipFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesceFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/> | |
<exclude name="PHPCompatibility.Constants.NewConstants.t_yield_fromFound"/> | |
</rule> | |
<!-- Let's also check that everything is properly documented. --> | |
<rule ref="WordPress-Docs"/> | |
<!-- Add in some extra rules from other standards. --> | |
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/> | |
<rule ref="Generic.Commenting.Todo"/> | |
</ruleset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment