You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.9 KiB

<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Yoast SEO AMP"
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Yoast SEO AMP rules for PHP_CodeSniffer</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<file>.</file>
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 8 files simultanously. -->
<arg name="parallel" value="8"/>
<!--
#############################################################################
USE THE YoastCS RULESET
#############################################################################
-->
<rule ref="Yoast"/>
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<!-- Set the minimum supported WP version. This is used by several sniffs. -->
<config name="minimum_supported_wp_version" value="4.8"/>
<!-- Verify that all gettext calls use the correct text domain. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="yoastseo-amp"/>
</property>
</properties>
</rule>
<rule ref="Yoast.Files.FileName">
<properties>
<!-- Don't trigger on the main file as renaming it would deactivate the plugin. -->
<property name="exclude" type="array">
<element value="yoastseo-amp.php"/>
</property>
<!-- Remove the following prefixes from the names of object structures. -->
<property name="prefixes" type="array">
<element value="yoastseo_amp"/>
<element value="yoast_amp"/>
</property>
</properties>
</rule>
<!-- Verify that everything in the global namespace is prefixed with a plugin specific prefix. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Provide the prefixes to look for. -->
<property name="prefixes" type="array">
<!-- Temporarily allowed until the prefixes are fixed. -->
<element value="yoastseo_amp"/>
<element value="yoast_seo_amp"/>
<element value="wpseo_amp"/>
<!-- These are the new prefixes which all code should comply with in the future. -->
<element value="yoast_amp"/>
<element value="Yoast\WP\AMP"/>
</property>
</properties>
</rule>
<!-- Whitelist camelCase variable property name. -->
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" type="array">
<element value="childNodes"/>
<element value="nodeName"/>
<element value="nodeType"/>
<element value="parentNode"/>
</property>
</properties>
</rule>
<!--
#############################################################################
TEMPORARY ADJUSTMENTS
Adjustments which should be removed once the associated issue has been resolved.
#############################################################################
-->
<!-- The below exclusion has to do with appropriate sanitization and escaping
of CSS and JS data for which no standard functionality exists in WP.
A further review of this is needed and this needs to be tested extensively.
Ticket: https://github.com/Yoast/yoastseo-amp/issues/96
-->
<rule ref="WordPress.Security.EscapeOutput.OutputNotEscaped">
<exclude-pattern>/classes/frontend\.php$</exclude-pattern>
</rule>
</ruleset>