Skip to content

Commit

Permalink
Add phpcs.xml to root as a part of devpackages, 2.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ronilaukkarinen committed Apr 18, 2024
1 parent 700f926 commit 91b2c74
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.5.5: 2024-04-18

* Add phpcs.xml to root as a part of devpackages

### 2.5.4: 2023-06-01

* Add rule `"number-leading-zero": "never",`
Expand Down
133 changes: 133 additions & 0 deletions gulp/tasks/phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki -->
<!-- See https://github.com/wimg/PHPCompatibility -->

<!-- Set a description for this ruleset. -->
<description>A custom set of code standard rules to check for WordPress themes.</description>

<!-- Pass some flags to PHPCS:
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
v flag: Print verbose output.
n flag: Do not print warnings.
-->
<arg value="psvn"/>

<!-- Only check the PHP, CSS and SCSS files. JS files are checked separately with JSCS and JSHint. -->
<arg name="extensions" value="php,css,scss/css"/>

<!-- Check all files in this directory and the directories below it. -->
<file>.</file>

<!-- Include the WordPress ruleset, with exclusions. -->
<rule ref="WordPress">

<!-- Strict intendation rules we want to exclude -->
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed" />
<exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
<exclude name="WordPress.Arrays.ArrayIndentation.ItemNotAligned" />
<exclude name="WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned" />
<exclude name="Universal.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed" />
<exclude name="WordPress.Arrays.ArrayIndentation.CloseBraceNotAligned" />
<exclude name="PEAR.Functions.FunctionCallSignature.OpeningIndent" />

<!-- Don't require too strict inline commenting, it's a good thing to documentate, let's not make it frustrating -->
<exclude name="Squiz.Commenting.FunctionComment.WrongStyle" />
<exclude name="Squiz.Commenting.ClassComment.WrongStyle" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
<exclude name="Squiz.Commenting.InlineComment.SpacingAfter" />
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.LongConditionClosingComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" />

<!-- General code style related excludes -->
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
<exclude name="Squiz.PHP.EmbeddedPhp.MultipleStatements" />
<exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterOpen" />
<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd" />
<exclude name="Generic.Formatting.DisallowMultipleStatements.SameLine" />
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.AssociativeKeyFound" />
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound" />
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace" />
<exclude name="PHPCompatibility.PHP.NewFunctionArrayDereferencing.Found" />

<!-- General WordPress stuff we like to overrule -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />

<!-- Very strict VIP/discouraged rules that are not needed -->
<exclude name="WordPress.XSS.EscapeOutput.OutputNotEscaped" />
<exclude name="WordPress.Functions.DontExtract.extract_extract" />
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Generic.Commenting.DocComment.SpacingBeforeTags" />
<exclude name="Squiz.PHP.EmbeddedPhp.NoSemicolon" />
<exclude name="PHPCompatibility.PHP.NewClosure.Found" />
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<exclude name="WordPress.PHP.DontExtract.extract_extract" />

<!-- Translations related, not always necessary, too strict -->
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment" />

<!-- EditorConfig makes sure this happens anyway & false positives happen with this -->
<exclude name="Generic.Files.EndFileNewline.NotFound" />

<!-- Many times when developing a customer case we have placeholders for SVG includes, so unnecessary error reports happen with this rule -->
<exclude name="Squiz.PHP.EmbeddedPhp.Empty" />

<!-- Other useful excludes -->
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited" />
<exclude name="PEAR.NamingConventions.ValidClassName.StartWithCapital" />
<exclude name="WordPress.Security.ValidatedSanitizedInput.MissingUnslash" />
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
<exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeOpen" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning" />
<exclude name="PEAR.Files.IncludingFile.UseRequire" />
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned" />
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode" />
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_tax_query" />
<exclude name="Universal.Operators.DisallowShortTernary.Found" />
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />

<!-- Whitespace rules -->
<exclude name="WordPress.WhiteSpace.PrecisionAlignment.Found" />
<exclude name="WordPress.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed" />
<exclude name="Universal.WhiteSpace.PrecisionAlignment.Found" />

<!-- Project based -->
<exclude name="Squiz.PHP.CommentedOutCode.Found" />
</rule>

<!-- Verify that the text_domain is set to the desired text-domain.
Multiple valid text domains can be provided as a comma-delimited list. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="air-light" />
</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>

<!-- Include sniffs for PHP cross-version compatibility. -->
<config name="testVersion" value="8.3"/>
<rule ref="PHPCompatibility"/>
</ruleset>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "PROJECTNAME",
"version": "2.5.4",
"version": "2.5.5",
"description": "PROJECTNAME powered by dudestack + devpackages",
"author": "Digitoimisto Dude Oy (moro@dude.fi)",
"devDependencies": {
Expand Down

0 comments on commit 91b2c74

Please sign in to comment.