| 1 |
<?xml version="1.0"?> |
| 2 |
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Example Project" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> |
| 3 |
|
| 4 |
<description>A custom set of rules to check for a WPized WordPress project</description> |
| 5 |
|
| 6 |
|
| 7 |
<!-- Exclude the Composer Vendor directory. --> |
| 8 |
<exclude-pattern>/vendor/*</exclude-pattern> |
| 9 |
|
| 10 |
<!-- Exclude the Node Modules directory. --> |
| 11 |
<exclude-pattern>/node_modules/*</exclude-pattern> |
| 12 |
|
| 13 |
<!-- Exclude the build directory. --> |
| 14 |
<exclude-pattern>/build/*</exclude-pattern> |
| 15 |
|
| 16 |
<!-- Exclude minified Javascript files. --> |
| 17 |
<exclude-pattern>*.min.js</exclude-pattern> |
| 18 |
|
| 19 |
<!-- ... --> |
| 20 |
<arg value="ps"/> |
| 21 |
<arg name="colors"/> |
| 22 |
<arg name="parallel" value="100"/> |
| 23 |
<arg name="extensions" value="php"/> |
| 24 |
<!-- ... --> |
| 25 |
|
| 26 |
|
| 27 |
<!-- Include the WordPress-Extra standard. --> |
| 28 |
<rule ref="WordPress-Extra"> |
| 29 |
<!-- |
| 30 |
We may want a middle ground though. The best way to do this is add the |
| 31 |
entire ruleset, then rule by rule, remove ones that don't suit a project. |
| 32 |
We can do this by running `phpcs` with the '-s' flag, which allows us to |
| 33 |
see the names of the sniffs reporting errors. |
| 34 |
Once we know the sniff names, we can opt to exclude sniffs which don't |
| 35 |
suit our project like so. |
| 36 |
|
| 37 |
The below two examples just show how you can exclude rules. |
| 38 |
They are not intended as advice about which sniffs to exclude. |
| 39 |
--> |
| 40 |
|
| 41 |
<!-- |
| 42 |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing"/> |
| 43 |
<exclude name="WordPress.Security.EscapeOutput"/> |
| 44 |
--> |
| 45 |
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" /> |
| 46 |
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" /> |
| 47 |
<exclude name="Generic.Files.LineEndings.InvalidEOLChar" /> |
| 48 |
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" /> |
| 49 |
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace" /> |
| 50 |
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword" /> |
| 51 |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterStructureOpen" /> |
| 52 |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeOpenParenthesis" /> |
| 53 |
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma" /> |
| 54 |
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" /> |
| 55 |
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" /> |
| 56 |
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" /> |
| 57 |
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine" /> |
| 58 |
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" /> |
| 59 |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterCloseParenthesis" /> |
| 60 |
<exclude name="Generic.Arrays.DisallowLongArraySyntax.Found" /> |
| 61 |
<exclude name="Squiz.Strings.ConcatenationSpacing.PaddingFound" /> |
| 62 |
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose" /> |
| 63 |
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceAfterArrayOpener" /> |
| 64 |
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter" /> |
| 65 |
<exclude name="WordPress.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed" /> |
| 66 |
<exclude name="WordPress.Arrays.CommaAfterArrayItem.NoComma" /> |
| 67 |
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralDomain" /> |
| 68 |
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" /> |
| 69 |
<exclude name="Squiz.Strings.DoubleQuoteUsage.NotRequired" /> |
| 70 |
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma" /> |
| 71 |
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.SpaceBeforeArrayCloser" /> |
| 72 |
<exclude name="Generic.Files.EndFileNewline.NotFound" /> |
| 73 |
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound" /> |
| 74 |
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" /> |
| 75 |
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" /> |
| 76 |
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" /> |
| 77 |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" /> |
| 78 |
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis" /> |
| 79 |
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" /> |
| 80 |
<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions.NoSpacesAroundArrayKeys" /> |
| 81 |
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceBeforeArrayCloser" /> |
| 82 |
<exclude name="WordPress.Classes.ClassInstantiation.MissingParenthesis" /> |
| 83 |
<exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned" /> |
| 84 |
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma" /> |
| 85 |
<exclude name="WordPress.Arrays.CommaAfterArrayItem.SpaceBeforeComma" /> |
| 86 |
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.ArrayItemNoNewLine" /> |
| 87 |
<exclude name="WordPress.PHP.DontExtract.extract_extract" /> |
| 88 |
<exclude name="WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned" /> |
| 89 |
|
| 90 |
<exclude name="Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure" /> |
| 91 |
<exclude name="WordPress.PHP.YodaConditions.NotYoda" /> |
| 92 |
</rule> |
| 93 |
|
| 94 |
<!-- Let's also check that everything is properly documented. --> |
| 95 |
<!-- <rule ref="WordPress-Docs"/> --> |
| 96 |
|
| 97 |
<!-- Add in some extra rules from other standards. --> |
| 98 |
<!-- <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/> |
| 99 |
<rule ref="Generic.Commenting.Todo"/> --> |
| 100 |
|
| 101 |
<!-- Check for PHP cross-version compatibility. --> |
| 102 |
<!-- |
| 103 |
To enable this, the PHPCompatibilityWP standard needs |
| 104 |
to be installed. |
| 105 |
See the readme for installation instructions: |
| 106 |
https://github.com/PHPCompatibility/PHPCompatibilityWP |
| 107 |
For more information, also see: |
| 108 |
https://github.com/PHPCompatibility/PHPCompatibility |
| 109 |
--> |
| 110 |
<!-- |
| 111 |
<config name="testVersion" value="5.2-"/> |
| 112 |
<rule ref="PHPCompatibilityWP"/> |
| 113 |
--> |
| 114 |
|
| 115 |
<!-- |
| 116 |
To get the optimal benefits of using WPCS, we should add a couple of |
| 117 |
custom properties. |
| 118 |
Adjust the values of these properties to fit our needs. |
| 119 |
|
| 120 |
For information on additional custom properties available, check out |
| 121 |
the wiki: |
| 122 |
https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties |
| 123 |
--> |
| 124 |
<config name="minimum_supported_wp_version" value="4.6"/> |
| 125 |
|
| 126 |
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"> |
| 127 |
<properties> |
| 128 |
<property name="prefixes" type="array"> |
| 129 |
<element value="auxin"/> |
| 130 |
<element value="auxels"/> |
| 131 |
</property> |
| 132 |
</properties> |
| 133 |
</rule> |
| 134 |
|
| 135 |
<!-- ... --> |
| 136 |
<!-- Allow short array syntax --> |
| 137 |
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found"> |
| 138 |
<severity>0</severity> |
| 139 |
</rule> |
| 140 |
<!-- ... --> |
| 141 |
</ruleset> |
| 142 |
|