.phpcs.xml.dist (9243B)
1 <?xml version="1.0"?> 2 <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="extendify-sdk" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> 3 4 <description>WP Plugin checks</description> 5 6 <!-- Exclude the Composer Vendor directory. --> 7 <exclude-pattern>/vendor/*</exclude-pattern> 8 9 <exclude-pattern>/cypress/*</exclude-pattern> 10 <exclude-pattern>/.github/*</exclude-pattern> 11 <exclude-pattern>/tests/*</exclude-pattern> 12 <exclude-pattern>/public/*</exclude-pattern> 13 <exclude-pattern>/wpcs/*</exclude-pattern> 14 15 <!-- Exclude the Node Modules directory. --> 16 <exclude-pattern>/node_modules/*</exclude-pattern> 17 18 <!-- Exclude CSS and Javascript files. --> 19 <exclude-pattern>*.css</exclude-pattern> 20 <exclude-pattern>*.js</exclude-pattern> 21 22 <!-- Include the WordPress-Extra standard. --> 23 <rule ref="WordPress-Extra"> 24 <!-- 25 We may want a middle ground though. The best way to do this is add the 26 entire ruleset, then rule by rule, remove ones that don't suit a project. 27 We can do this by running `phpcs` with the '-s' flag, which allows us to 28 see the names of the sniffs reporting errors. 29 Once we know the sniff names, we can opt to exclude sniffs which don't 30 suit our project like so. 31 32 The below two examples just show how you can exclude rules. 33 They are not intended as advice about which sniffs to exclude. 34 --> 35 36 <!-- 37 <exclude name="WordPress.WhiteSpace.ControlStructureSpacing"/> 38 <exclude name="WordPress.Security.EscapeOutput"/> 39 --> 40 </rule> 41 42 <rule ref="WordPress"> 43 <exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" /> 44 <exclude name="WordPress.Files.FileName.InvalidClassFileName" /> 45 <exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound" /> 46 <exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" /> 47 <exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis" /> 48 <exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore" /> 49 <exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter" /> 50 <exclude name="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterCloseParenthesis" /> 51 <exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceAfterArrayOpener" /> 52 <exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceBeforeArrayCloser" /> 53 <exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" /> 54 <exclude name="WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase" /> 55 <exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid" /> 56 <exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" /> 57 <exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase" /> 58 <exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions.NoSpacesAroundArrayKeys" /> 59 <exclude name="WordPress.PHP.YodaConditions.NotYoda" /> 60 <exclude name="WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid" /> 61 <exclude name="WordPress.NamingConventions.ValidVariableName.InterpolatedVariableNotSnakeCase" /> 62 </rule> 63 64 <rule ref="Generic"> 65 <exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" /> 66 <exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" /> 67 <exclude name="Generic.PHP.ClosingPHPTag.NotFound" /> 68 <exclude name="Generic.Files.LowercasedFilename.NotFound" /> 69 <exclude name="Generic.Formatting.SpaceAfterNot.Incorrect" /> 70 <exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine" /> 71 <exclude name="Generic.Files.EndFileNoNewline.Found" /> 72 <exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine" /> 73 <exclude name="Generic.Files.LineLength.TooLong" /> 74 <exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" /> 75 <exclude name="Generic.Commenting.Todo.TaskFound" /> 76 <exclude name="Generic.Formatting.NoSpaceAfterCast.SpaceFound" /> 77 <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame" /> 78 <exclude name="Generic.PHP.RequireStrictTypes.MissingDeclaration" /> 79 <exclude name="Generic.PHP.UpperCaseConstant.Found" /> 80 <exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeOpen" /> 81 <exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose" /> 82 <exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen" /> 83 <exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterClose" /> 84 <exclude name="Generic.PHP.ForbiddenFunctions.Found" /> 85 <exclude name="Generic.Files.InlineHTML.Found" /> 86 </rule> 87 <rule ref="Squiz"> 88 <exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpen" /> 89 <exclude name="Squiz.ControlStructures.ElseIfDeclaration.NotAllowed" /> 90 <exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose" /> 91 <exclude name="Squiz.WhiteSpace.FunctionSpacing.AfterLast" /> 92 <exclude name="Squiz.Files.FileExtension.ClassFound" /> 93 <exclude name="Squiz.Commenting.FileComment.MissingPackageTag" /> 94 <exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed" /> 95 <exclude name="Squiz.WhiteSpace.FunctionSpacing.BeforeFirst" /> 96 <exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue" /> 97 <exclude name="Squiz.WhiteSpace.FunctionSpacing.After" /> 98 <exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned" /> 99 <exclude name="Squiz.WhiteSpace.FunctionSpacing.Before" /> 100 <exclude name="Squiz.PHP.DisallowBooleanStatement.Found" /> 101 <exclude name="Squiz.ControlStructures.InlineIfDeclaration.NoBrackets" /> 102 <exclude name="Squiz.PHP.DisallowInlineIf.Found" /> 103 <exclude name="Squiz.PHP.DisallowComparisonAssignment.AssignedComparison" /> 104 <exclude name="Squiz.PHP.DiscouragedFunctions.Discouraged" /> 105 <exclude name="Squiz.Functions.GlobalFunction.Found" /> 106 <exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd" /> 107 </rule> 108 <rule ref="PEAR"> 109 <exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" /> 110 <exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket" /> 111 <exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket" /> 112 <exclude name="PEAR.Commenting.FileComment.MissingPackageTag" /> 113 <exclude name="PEAR.Commenting.FileComment.MissingAuthorTag" /> 114 <exclude name="PEAR.Commenting.FileComment.MissingCategoryTag" /> 115 <exclude name="PEAR.Commenting.FileComment.MissingLinkTag" /> 116 <exclude name="PEAR.Commenting.FileComment.MissingLicenseTag" /> 117 <exclude name="PEAR.Commenting.FileComment.MissingVersion" /> 118 <exclude name="PEAR.Commenting.ClassComment.MissingPackageTag" /> 119 <exclude name="PEAR.Commenting.ClassComment.MissingAuthorTag" /> 120 <exclude name="PEAR.Commenting.ClassComment.MissingCategoryTag" /> 121 <exclude name="PEAR.Commenting.ClassComment.MissingLinkTag" /> 122 <exclude name="PEAR.Commenting.ClassComment.MissingLicenseTag" /> 123 <exclude name="PEAR.Commenting.ClassComment.MissingVersion" /> 124 <exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore" /> 125 <exclude name="PEAR.Commenting.FileComment.WrongStyle" /> 126 <exclude name="PEAR.Commenting.FileComment.Missing" /> 127 <exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact" /> 128 </rule> 129 130 <!-- Let's also check that everything is properly documented. --> 131 <rule ref="WordPress-Docs"/> 132 133 <!-- Add in some extra rules from other standards. --> 134 <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/> 135 <!-- <rule ref="Generic.Commenting.Todo"/> --> 136 137 <!-- Check for PHP cross-version compatibility. --> 138 <!-- 139 To enable this, the PHPCompatibilityWP standard needs 140 to be installed. 141 See the readme for installation instructions: 142 https://github.com/PHPCompatibility/PHPCompatibilityWP 143 For more information, also see: 144 https://github.com/PHPCompatibility/PHPCompatibility 145 --> 146 147 <config name="testVersion" value="5.6-"/> 148 <rule ref="PHPCompatibilityWP"/> 149 150 151 <!-- 152 To get the optimal benefits of using WPCS, we should add a couple of 153 custom properties. 154 Adjust the values of these properties to fit our needs. 155 156 For information on additional custom properties available, check out 157 the wiki: 158 https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties 159 --> 160 <config name="minimum_supported_wp_version" value="5.4"/> 161 162 <rule ref="WordPress.WP.I18n"> 163 <properties> 164 <property name="text_domain" type="array"> 165 <element value="extendify-sdk"/> 166 </property> 167 </properties> 168 </rule> 169 170 <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> 171 <properties> 172 <property name="prefixes" type="array"> 173 <element value="extendifysdk"/> 174 </property> 175 </properties> 176 </rule> 177 178 179 </ruleset>