Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 35 additions & 30 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
<?xml version="1.0"?>
<ruleset name="Jetpack">
<config name="minimum_supported_wp_version" value="5.3" />
<config name="testVersion" value="5.6-"/>

<rule ref="PHPCompatibilityWP"/>
<rule ref="WordPress-Core" />
<rule ref="WordPress-Docs" />
<rule ref="WordPress-Extra" />
<rule ref="VariableAnalysis" />

<!-- Elevate undefined variables to an Error instead of a Warning. -->
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable">
<type>error</type>
</rule>
<ruleset name="Jetpack-Plugin">
<rule ref="Jetpack"/>

<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<properties>
<property name="allowWordPressPassByRefFunctions" value="true" />
</properties>

<!-- Template files use extracted variables. -->
<exclude-pattern>/extensions/blocks/podcast-player/templates/*</exclude-pattern>
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="jetpack" />
<property name="text_domain" type="array">
<element value="jetpack"/>
</property>
</properties>
</rule>

<!-- Check all PHP files in directory tree by default. -->
<arg name="extensions" value="php"/>
<file>.</file>

<!-- Show sniff codes in all reports -->
<arg value="s"/>

<arg name="colors"/>

<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<rule ref="Jetpack.Commenting.HooksInlineDocs">
<properties>
<property name="allowed_extra_versions" type="array" value="0.71"/>
<property name="allowed_extra_versions" type="array" value="MU"/>
</properties>
</rule>

<rule ref="Jetpack.Commenting.HooksRequireTags">
<properties>
<property name="required_tags" type="array" value="module"/>
</properties>
<include-pattern>/modules/*</include-pattern>
</rule>

<!-- For the coding-standards package, we are borrowing from the WPCS' phpcs.xml.dist. -->
<rule ref="WordPress.Files.FileName">
<exclude-pattern>/packages/coding-standards/*</exclude-pattern>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<exclude-pattern>/packages/coding-standards/*</exclude-pattern>
</rule>
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
<exclude-pattern>/packages/coding-standards/*</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration">
<include-pattern>/packages/coding-standards/*</include-pattern>
</rule>
<rule ref="PSR2.Methods.FunctionClosingBrace">
<include-pattern>/packages/coding-standards/*</include-pattern>
</rule>
</ruleset>
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
"automattic/jetpack-tracking": "@dev"
},
"require-dev": {
"automattic/jetpack-coding-standards": "@dev",
"dealerdirect/phpcodesniffer-composer-installer": "0.6.2",
"phpcompatibility/phpcompatibility-wp": "2.1.0",
"sirbrillig/phpcs-changed": "2.4.0",
"sirbrillig/phpcs-variable-analysis": "2.8.1",
"wp-coding-standards/wpcs": "2.2.1"
"sirbrillig/phpcs-changed": "2.4.0"
},
"scripts": {
"php:compatibility": "vendor/bin/phpcs -p -s --runtime-set testVersion '5.6-' --standard=PHPCompatibilityWP --ignore=docker,tools,tests,node_modules,vendor --extensions=php",
Expand Down
51 changes: 44 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions packages/coding-standards/.phpcs.xml.dist-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<ruleset name="Jetpack-Plugin">
<rule ref="Jetpack"/>

<rule ref="Jetpack.Commenting.HooksRequireTags">
<properties>
<property name="required_tags" type="array" value="module"/>
</properties>
<include-pattern>/modules/*</include-pattern>
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="jetpack"/>
</property>
</properties>
</rule>
</ruleset>
Loading