-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathruleset.xml
More file actions
201 lines (160 loc) · 7.45 KB
/
ruleset.xml
File metadata and controls
201 lines (160 loc) · 7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Eightshift" namespace="EightshiftCS\Eightshift" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>Eightshift coding standards for WordPress projects</description>
<config name="encoding" value="utf-8"/>
<!-- Check code for cross-version PHP compatibility. -->
<config name="testVersion" value="7.4-"/>
<rule ref="PHPCompatibilityWP"/>
<!-- Exclude certain patterns. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>
<!-- Only check php code, linters are used for checking js and css. -->
<arg name="extensions" value="php,inc"/>
<!-- Enable colors in report. -->
<arg name="colors"/>
<!-- Add source codes in the report. -->
<arg value="sp"/>
<!-- Tabs should represent 2 spaces. -->
<arg name="tab-width" value="4"/>
<!-- Run sniffs in parallel for faster results. -->
<arg name="parallel" value="8"/>
<!-- Check against minimum WP version. -->
<config name="minimum_wp_version" value="6.0"/>
<!-- Set minimum supported version for deprecated functions. -->
<rule ref="WordPress.WP.DeprecatedFunctions">
<properties>
<property name="minimum_wp_version" value="6.0"/>
</properties>
</rule>
<!-- Use PSR-12 ruleset: https://www.php-fig.org/psr/psr-12/
Use WordPress-Docs for documentation checks. -->
<rule ref="PSR12"/>
<rule ref="WordPress-Docs">
<exclude name="Squiz.Commenting.FunctionComment"/>
</rule>
<rule ref="Eightshift.Commenting.FunctionComment">
<!-- WP prefers int and bool instead of integer and boolean -->
<exclude name="Eightshift.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- WP prefers int and bool instead of integer and boolean -->
<exclude name="Eightshift.Commenting.FunctionComment.InvalidReturn"/>
<!-- WP prefers indicating a @return null for early returns -->
<exclude name="Eightshift.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- WP states not all functions require @return -->
<exclude name="Eightshift.Commenting.FunctionComment.MissingReturn"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Eightshift.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Eightshift.Commenting.FunctionComment.SpacingAfterParamName"/>
<!-- It is too early for PHP7 features to be required -->
<exclude name="Eightshift.Commenting.FunctionComment.ScalarTypeHintMissing"/>
<!-- WP doesn't require type hints -->
<exclude name="Eightshift.Commenting.FunctionComment.TypeHintMissing"/>
<!-- EightShift specific: Don't bother with param spacing. -->
<exclude name="Eightshift.Commenting.FunctionComment.SpacingAfterParamType"/>
</rule>
<!-- Use tabs, not spaces. -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent">
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed"/>
</rule>
<!-- Warn about lines longer than 120 chars, and never error. -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="125"/>
<property name="absoluteLineLimit" value="0"/>
<property name="ignoreComments" value="true"/>
</properties>
</rule>
<!-- Disallow array() syntax. Use [] instead. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Remove extra spacing inside function declaration and call signature -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
<property name="requiredSpacesAfterOpen" value="0"/>
<property name="requiredSpacesBeforeClose" value="0"/>
</properties>
</rule>
<!-- Make this sniff more sensitive to commented out code blocks.-->
<rule ref="Squiz.PHP.CommentedOutCode">
<properties>
<property name="maxPercentage" value="55"/>
</properties>
</rule>
<!-- Enforce PSR-12 style file comments. -->
<rule ref="Squiz.Commenting.FileComment">
<exclude name="Squiz.Commenting.FileComment.SpacingAfterOpen"/>
</rule>
<!-- Enforce camelCase -->
<rule ref="Squiz.NamingConventions.ValidVariableName"/>
<!-- Disallow spacing inside arrays. -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Private methods MUST not be prefixed with an underscore -->
<rule ref="Squiz.NamingConventions.ValidFunctionName.PrivateNoUnderscore">
<severity>0</severity>
</rule>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<type>error</type>
</rule>
<!-- Private properties MUST not be prefixed with an underscore -->
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
<severity>0</severity>
</rule>
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
<type>error</type>
</rule>
<!-- Ensure proper object instantiation. -->
<rule ref="PSR12.Classes.ClassInstantiation"/>
<rule ref="Universal.Classes.RequireAnonClassParentheses"/>
<!-- Useful code analysis sniffs. -->
<rule ref="WordPress.CodeAnalysis"/>
<!-- Date Time sniffs. -->
<rule ref="WordPress.DateTime"/>
<!-- Database sniffs. -->
<rule ref="WordPress.DB"/>
<!-- We want to ensure hook name validity, this is a coding standard for WordPress. -->
<rule ref="WordPress.NamingConventions.ValidHookName"/>
<rule ref="WordPress.NamingConventions.ValidPostTypeSlug"/>
<!-- PHP sniffs are useful. Except Yoda conditions -->
<rule ref="WordPress.PHP">
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<!-- Deprecated since WordPressCS v3.3.0. Covered by PHPCompatibilityWP. -->
<exclude name="WordPress.PHP.POSIXFunctions"/>
</rule>
<!-- Exclude the WP escape output sniff, because we are overloading it. -->
<rule ref="WordPress.Security">
<exclude name="WordPress.Security.EscapeOutput"/>
</rule>
<!-- I18n sniffs. -->
<rule ref="WordPress.Utils.I18nTextDomainFixer"/>
<!-- General WP sniffs. -->
<rule ref="WordPress.WP">
<exclude name="WordPress.DateTime.RestrictedFunctions"/>
</rule>
<!-- PHPCS Extra standard.
Normalize array brace spacing. Enforce no spaces inside arrays. -->
<rule ref="NormalizedArrays.Arrays.ArrayBraceSpacing"/>
<!-- Detect duplicate array keys in array declarations. -->
<rule ref="Universal.Arrays.DuplicateArrayKey"/>
<!-- Don't use a mix of integer and numeric keys for array items. -->
<rule ref="Universal.Arrays.MixedArrayKeyTypes"/>
<!-- Don't use a mix of keyed and unkeyed array items. -->
<rule ref="Universal.Arrays.MixedKeyedUnkeyedArray"/>
<!-- Enforce uppercase when using PHP native magic constants, like __FILE__ et al. -->
<rule ref="Universal.Constants.UppercaseMagicConstants"/>
<!-- Enforce the use of the boolean && and || operators instead of the logical and/or operators. -->
<rule ref="Universal.Operators.DisallowLogicalAndOr"/>
<!-- Flag unused use statements. -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
<!-- Use fully qualified names for global functions and constants. -->
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
<!-- Use import use statements for everything else. -->
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true"/>
<property name="allowFullyQualifiedGlobalFunctions" value="true"/>
<property name="allowFullyQualifiedGlobalConstants" value="true"/>
</properties>
</rule>
</ruleset>