-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpcs.xml
237 lines (168 loc) · 9.35 KB
/
phpcs.xml
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards">
<!-- ルールの参考:https://gist.github.com/kkkw/d926a930a99485214925f22621d56230 -->
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress/WordPress-Coding-Standards -->
<!-- See https://github.com/WPTRT/WPThemeReview -->
<!-- See https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<!-- Set a description for this ruleset. -->
<description>A custom set of code standard rules to check for WordPress themes.</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<!-- Pass some flags to PHPCS:
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
-->
<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"/>
<!-- Only check the PHP files. JS, and CSS files are checked separately with @wordpress/scripts package. -->
<arg name="extensions" value="php"/>
<!-- Check all files in this directory and the directories below it. -->
<file>.</file>
<!-- Exclude patterns. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>
<!-- <exclude-pattern>/_test.php</exclude-pattern> -->
<!--
#############################################################################
USE THE WordPress AND THE Theme Review RULESET
#############################################################################
-->
<rule ref="WordPress">
<!-- This rule does not apply here since the _s prefix should be changed by the theme author. -->
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.ShortPrefixPassed"/>
<!-- ファイル冒頭のコメントを必要とするルールを除外 -->
<exclude name="Squiz.Commenting.FileComment.Missing" />
<!-- ファイルコメントのあとに空行いれないといけないルールを除外 -->
<exclude name="Squiz.Commenting.FileComment.SpacingAfterComment" />
<!-- ファイルコメントに @package なくても許す -->
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
<!-- コメント分の末尾をフルストップ、ビックリマークやはてなで終わらせる必要があるルールを除外する -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop" />
<!-- コードをコメントアウトした時の警告を除去 -->
<exclude name="Squiz.PHP.CommentedOutCode.Found" />
<!-- コメント文は大文字で始める制約を除外 -->
<exclude name="Generic.Commenting.DocComment.ShortNotCapital" />
<!-- ifなどは1行で書いてはいけないルールを除外 -->
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
<!-- クラスのファイル名を "class-" 出始めないといけないルールを除外 -->
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<!-- 関数へのコメント強制を除外 -->
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
<!-- 関数へのコメントを /** で始めないといけない制限を除外 -->
<exclude name="Squiz.Commenting.FunctionComment.WrongStyle" />
<!-- 関数の引数へのコメント強制を除外 -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
<!-- クラスへのコメント強制を除外 -->
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<!-- クラス変数へのコメント強制を除外 -->
<exclude name="Squiz.Commenting.VariableComment.Missing" />
<!-- クラス変数へのコメントに @var がなくても許す -->
<exclude name="Squiz.Commenting.VariableComment.MissingVar" />
<!-- クラスメソッドのコメントで @param の説明がなくても許す -->
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<!-- クラスコメントが短くても許す -->
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<!-- クラス内のコメントが // から始まっても許す -->
<exclude name="Squiz.Commenting.VariableComment.WrongStyle" />
<!-- オブジェクトプロパティの snake_case ルールを除外 ( ->$Version などに影響) -->
<exclude name="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase" />
<!-- 変数の snake_case ルールを除外 ( $SETTING などに影響) -->
<exclude name="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase" />
<exclude name="WordPress.NamingConventions.ValidVariableName.InterpolatedVariableNotSnakeCase" />
<!-- 関数の snake_case ルールを除外 -->
<exclude name="WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid" />
<!-- ファイル名を_から始めた時に出るエラーを除外 -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<!-- インデント -->
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact" />
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
<exclude name="Squiz.Commenting.InlineComment.SpacingBefore" />
<!-- 参考演算子を許可 -->
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />
<!-- "translation:" コメントがなくても許す -->
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment" />
<!-- $_REQUEST などにエラー出さない -->
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized" />
<exclude name="WordPress.Security.ValidatedSanitizedInput.MissingUnslash" />
<!-- $post_id などの変数名にエラーをださない -->
<!-- <exclude name="WordPress.WP.GlobalVariablesOverride.OverrideProhibited" /> -->
<!-- PHP省略タグを許可 -->
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound" />
<!-- array() の強制を解除 -->
<!-- <exclude name="Generic.Arrays.DisallowLongArraySyntax" /> -->
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceAfterArrayOpener" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<!-- 無名関数 のフックが改行されないように -->
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
</rule>
<!-- array()禁止して []を使う こと -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found"/>
<!-- <rule ref="WPThemeReview"/> -->
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<!-- Verify that the text_domain is set to the desired text-domain.
Multiple valid text domains can be provided as a comma-delimited list. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="fecss-editor"/>
</properties>
</rule>
<!-- Allow for theme specific exceptions to the file name rules based
on the theme hierarchy. -->
<rule ref="WordPress.Files.FileName">
<properties>
<property name="is_theme" value="true"/>
</properties>
</rule>
<!-- Set the minimum supported WP version. This is used by several sniffs.
The minimum version set here should be in line with the minimum WP version
as set in the "Requires at least" tag in the readme.txt file. -->
<config name="minimum_supported_wp_version" value="5.0"/>
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<properties>
<!-- No need to adjust alignment of large arrays when the item with the largest key is removed. -->
<property name="exact" value="false"/>
<!-- Don't align multi-line items if ALL items in the array are multi-line. -->
<property name="alignMultilineItems" value="!=100"/>
<!-- Array assignment operator should always be on the same line as the array key. -->
<property name="ignoreNewlines" value="false"/>
</properties>
</rule>
<!-- Verify that everything in the global namespace is prefixed with a theme specific prefix.
Multiple valid prefixes can be provided as a comma-delimited list. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array" value="_s" />
</properties>
</rule>
<!--
#############################################################################
USE THE PHPCompatibility RULESET
#############################################################################
-->
<config name="testVersion" value="5.6-"/>
<rule ref="PHPCompatibilityWP">
<!-- 無名関数を許可 -->
<exclude name="PHPCompatibility.FunctionDeclarations.NewClosure.Found" />
<!-- namespace を許可 -->
<exclude name="PHPCompatibility.Keywords.NewKeywords.t_namespaceFound" />
<!-- / 始まりの関数を許可 -->
<exclude name="PHPCompatibility.LanguageConstructs.NewLanguageConstructs.t_ns_separatorFound" />
<!-- ?? 演算子を許可-->
<exclude name="PHPCompatibility.Operators.NewOperators.t_coalesceFound" />
</rule>
</ruleset>