-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpcs.xml.dist
190 lines (164 loc) Β· 8.15 KB
/
phpcs.xml.dist
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
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WPGraphQL" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>Coding standards for the WPGraphQL plugin</description>
<!-- What to scan: include any root-level PHP files, and the /src folder -->
<file>./wpgraphql-ide.php</file>
<exclude-pattern>./phpstan/*</exclude-pattern>
<exclude-pattern>*/**/tests/</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<!--
Prevent errors caused by WordPress Coding Standards not supporting PHP 8.0+.
See: https://github.com/WordPress/WordPress-Coding-Standards/issues/2035
See: https://github.com/WordPress/WordPress-Coding-Standards/issues/2035#issuecomment-1325532520
-->
<ini name="error_reporting" value="E_ALL & ~E_DEPRECATED" />
<!--How to scan: include CLI args so you don't need to pass them manually -->
<!--Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
<!--
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
-->
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="./"/>
<!-- Enable colors in report -->
<arg name="colors" />
<!-- Only lint php files by default -->
<arg name="extensions" value="php" />
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache" value="tests/_output/cache.json" />
<!-- Check 20 files in parallel. -->
<arg name="parallel" value="20" />
<!-- Set severity to 1 to see everything that isn't effectively turned off. -->
<arg name="severity" value="1" />
<!-- Ruleset Config: set these to match your project constraints-->
<!--
Tests for PHP version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#Recomended-additional-rulesets
-->
<config name="testVersion" value="7.4-"/>
<!--
Tests for WordPress version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
-->
<config name="minimum_wp_version" value="5.0"/>
<!-- Individual rule configuration -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="wpgraphql-ide" />
</property>
</properties>
</rule>
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
<properties>
<property name="blank_line_check" value="true"/>
</properties>
</rule>
<rule ref="Squiz.Commenting.FunctionComment">
<properties>
<property name="skipIfInheritdoc" value="true" />
</properties>
</rule>
<!-- Rules -->
<!-- Load PHPCompatibilityWP standards -->
<rule ref="PHPCompatibilityWP" />
<!-- Load WordPress VIP Go standards - for use with projects on the (newer) VIP Go platform. -->
<rule ref="WordPress-VIP-Go" />
<!-- Load WordPress Coding standards -->
<rule ref="WordPress">
<!-- Definitely should not be added back -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>
<exclude name="WordPress.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="WordPress.WP.Capabilities.Undetermined" />
<!-- This would be a breaking change to fix-->
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
</rule>
<rule ref="WordPress.WP.Capabilities">
<properties>
<property name="custom_capabilities" type="array">
<element value="manage_graphql_ide" />
</property>
</properties>
</rule>
<!-- Tests for inline documentation of code -->
<rule ref="WordPress-Docs">
<!-- Conflicts with FQCN -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint" />
<!-- Conflicts with b/c in AbstractConnectionResolver -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidNoReturn" />
<!-- Should probably be added back -->
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
</rule>
<!-- Enforce short array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Slevomat Coding Standards-->
<rule ref="SlevomatCodingStandard.Arrays">
<!-- Conflicts with WPCS -->
<exclude name="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Semantic sorting is a valid pattern -->
<exclude name="SlevomatCodingStandard.Arrays.AlphabeticallySortedByKeys"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference">
<properties>
<!-- Doesn't use PHPCompatibility-->
<property name="enableOnObjects" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireSelfReference" />
<rule ref="SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants" />
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition" />
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition" />
<rule ref="SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch" />
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" />
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
<rule ref="SlevomatCodingStandard.Exceptions.DisallowNonCapturingCatch" />
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="caseSensitive" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses" />
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
<rule ref="SlevomatCodingStandard.TypeHints">
<!-- Array syntax is preferred -->
<exclude name="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax.DisallowedArrayTypeHintSyntax" />
<!-- WP dependencies are too loosely typed to implement these safely. Breaking change. -->
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint" />
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint" />
<!-- Depends on Squiz.Commenting.FunctionComment.MissingParamComment -->
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" />
<!-- Should probably be added back. -->
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing" />
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing" />
</rule>
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" />
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable" >
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />
</ruleset>