| 1 |
<?xml version="1.0"?> |
| 2 |
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Freemius WordPress SDK" |
| 3 |
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> |
| 4 |
|
| 5 |
<description>A custom set of rules to check for a WPized WordPress project</description> |
| 6 |
|
| 7 |
<!-- |
| 8 |
############################################################################# |
| 9 |
COMMAND LINE ARGUMENTS |
| 10 |
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset |
| 11 |
############################################################################# |
| 12 |
--> |
| 13 |
|
| 14 |
<file>.</file> |
| 15 |
|
| 16 |
<!-- Exclude the Composer Vendor directory. --> |
| 17 |
<exclude-pattern>/vendor/*</exclude-pattern> |
| 18 |
|
| 19 |
<!-- Exclude the Node Modules directory. --> |
| 20 |
<exclude-pattern>/node_modules/*</exclude-pattern> |
| 21 |
|
| 22 |
<!-- Exclude front-end asset files. --> |
| 23 |
<exclude-pattern>/assets/*</exclude-pattern> |
| 24 |
|
| 25 |
<!-- Exclude language files. --> |
| 26 |
<exclude-pattern>/languages/*</exclude-pattern> |
| 27 |
<exclude-pattern>/includes/class-freemius.php</exclude-pattern> |
| 28 |
|
| 29 |
<!-- Strip the filepaths down to the relevant bit. --> |
| 30 |
<arg name="basepath" value="."/> |
| 31 |
|
| 32 |
<!-- Check up to 8 files simultaneously. --> |
| 33 |
<arg name="parallel" value="8"/> |
| 34 |
|
| 35 |
<arg name="extensions" value="php"/> |
| 36 |
|
| 37 |
<arg name="tab-width" value="4"/> |
| 38 |
|
| 39 |
<!-- |
| 40 |
############################################################################# |
| 41 |
SET UP THE RULESETS |
| 42 |
############################################################################# |
| 43 |
--> |
| 44 |
|
| 45 |
<!-- Include only the security related sniffs for now --> |
| 46 |
<rule ref="WordPress.Security.EscapeOutput"> |
| 47 |
<properties> |
| 48 |
<property name="customEscapingFunctions" type="array"> |
| 49 |
<element value="fs_html_get_attributes"/> |
| 50 |
<element value="fs_html_get_classname"/> |
| 51 |
<element value="fs_html_get_sanitized_html"/> |
| 52 |
<element value="fs_esc_attr"/> |
| 53 |
<element value="fs_esc_attr_inline"/> |
| 54 |
<element value="fs_esc_attr_x_inline"/> |
| 55 |
<element value="htmlspecialchars"/> |
| 56 |
<element value="fs_esc_html_inline"/> |
| 57 |
</property> |
| 58 |
<property name="customAutoEscapedFunctions" type="array"> |
| 59 |
<element value="fs_nonce_url" /> |
| 60 |
<element value="WP_FS__ADDRESS" /> |
| 61 |
</property> |
| 62 |
</properties> |
| 63 |
</rule> |
| 64 |
|
| 65 |
<!-- Encourage use of wp_safe_redirect() to avoid open redirect vulnerabilities. |
| 66 |
https://github.com/WordPress/WordPress-Coding-Standards/pull/1264 --> |
| 67 |
<rule ref="WordPress.Security.SafeRedirect"/> |
| 68 |
|
| 69 |
<!-- Verify that a nonce check is done before using values in superglobals. |
| 70 |
https://github.com/WordPress/WordPress-Coding-Standards/issues/73 --> |
| 71 |
<rule ref="WordPress.Security.NonceVerification"> |
| 72 |
<properties> |
| 73 |
<property name="customNonceVerificationFunctions" type="array"> |
| 74 |
<element value="check_ajax_referer"/> |
| 75 |
</property> |
| 76 |
</properties> |
| 77 |
</rule> |
| 78 |
|
| 79 |
<!-- Let's also check that everything is properly documented. --> |
| 80 |
<!-- <rule ref="WordPress-Docs"/>--> |
| 81 |
|
| 82 |
<!-- Add in some extra rules from other standards. --> |
| 83 |
<!-- <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>--> |
| 84 |
<!-- <rule ref="Generic.Commenting.Todo"/>--> |
| 85 |
|
| 86 |
<!-- Check for PHP cross-version compatibility. --> |
| 87 |
<!-- |
| 88 |
To enable this, the PHPCompatibilityWP standard needs |
| 89 |
to be installed. |
| 90 |
See the readme for installation instructions: |
| 91 |
https://github.com/PHPCompatibility/PHPCompatibilityWP |
| 92 |
For more information, also see: |
| 93 |
https://github.com/PHPCompatibility/PHPCompatibility |
| 94 |
--> |
| 95 |
<!-- <rule ref="PHPCompatibilityWP"/> --> |
| 96 |
|
| 97 |
<config name="testVersion" value="5.6-"/> |
| 98 |
<rule ref="PHPCompatibility"/> |
| 99 |
|
| 100 |
<!-- |
| 101 |
############################################################################# |
| 102 |
SNIFF SPECIFIC CONFIGURATION |
| 103 |
############################################################################# |
| 104 |
--> |
| 105 |
|
| 106 |
<!-- |
| 107 |
To get the optimal benefits of using WPCS, we should add a couple of |
| 108 |
custom properties. |
| 109 |
Adjust the values of these properties to fit our needs. |
| 110 |
|
| 111 |
For information on additional custom properties available, check out |
| 112 |
the wiki: |
| 113 |
https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties |
| 114 |
--> |
| 115 |
<config name="minimum_supported_wp_version" value="5.0"/> |
| 116 |
|
| 117 |
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"> |
| 118 |
<properties> |
| 119 |
<property name="prefixes" type="array"> |
| 120 |
<element value="fs"/> |
| 121 |
</property> |
| 122 |
</properties> |
| 123 |
</rule> |
| 124 |
|
| 125 |
</ruleset> |