-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
phpcs.xml.dist
185 lines (168 loc) · 7.98 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
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Gutenberg Plugin">
<description>Sniffs for WordPress plugins, with minor modifications for Gutenberg</description>
<!-- Check for cross-version support for PHP 7.2 and higher. -->
<config name="testVersion" value="7.2-"/>
<rule ref="PHPCompatibilityWP">
<include-pattern>*\.php$</include-pattern>
</rule>
<rule ref="WordPress-Core"/>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="gutenberg"/>
<element value="default"/>
</property>
</properties>
</rule>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<properties>
<property name="allowUnusedParametersBeforeUsed" value="true"/>
</properties>
</rule>
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="allowMultipleArguments" value="false"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n.MissingArgDomainDefault">
<exclude-pattern>/lib/compat/*</exclude-pattern>
<exclude-pattern>/packages/block-library/src/*</exclude-pattern>
<exclude-pattern>/build/block-library/*</exclude-pattern>
</rule>
<arg value="ps"/>
<arg name="extensions" value="php"/>
<!-- Cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache" value=".cache/phpcs.json"/>
<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20"/>
<file>./bin</file>
<file>./gutenberg.php</file>
<file>./lib</file>
<file>./packages</file>
<file>./phpunit</file>
<file>./post-content.php</file>
<!-- Exclude generated files -->
<exclude-pattern>/packages/block-serialization-spec-parser/parser\.php$</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/build/*</exclude-pattern>
<!-- Exclude third party libraries -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/test/php/gutenberg-coding-standards/*</exclude-pattern>
<!-- Exclude files maintained in WordPress Core and backported to Gutenberg
DO NOT REMOVE these rules; these files are "built" artifacts from Core
and when they are removed it prevents keeping the repos in sync. -->
<exclude-pattern>/lib/compat/wordpress-*/html-api/*\.php$</exclude-pattern>
<!-- Ignore filename error since it requires WP core build process change -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>/phpunit/*</exclude-pattern>
<exclude-pattern>/packages/block-library/src/navigation/index\.php$</exclude-pattern>
</rule>
<!-- Ignore empty files in tests/gutenberg-test-themes -->
<rule ref="Internal.NoCodeFound">
<exclude-pattern>/test/gutenberg-test-themes/*</exclude-pattern>
</rule>
<!-- Exclude PHPUnit tests from file and class name sniffs (for Core parity). -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>/phpunit/*</exclude-pattern>
<exclude-pattern>*\.asset\.php$</exclude-pattern>
</rule>
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
<exclude-pattern>/phpunit/*</exclude-pattern>
</rule>
<!-- Enforce checks against redeclaration for functions and classes. -->
<rule ref="Gutenberg.CodeAnalysis.GuardedFunctionAndClassNames">
<exclude-pattern>/phpunit/*</exclude-pattern>
<exclude-pattern>/packages/*</exclude-pattern>
<exclude-pattern>/bin/generate-gutenberg-php\.php$</exclude-pattern>
<properties>
<property name="functionsWhiteList" type="array">
<element value="/^_?gutenberg.+/"/>
</property>
<property name="classesWhiteList" type="array">
<element value="/^Gutenberg.+/"/>
<element value="/^.+_Gutenberg$/"/>
</property>
</properties>
</rule>
<rule ref="Gutenberg.NamingConventions.ValidBlockLibraryFunctionName">
<include-pattern>/packages/block-library/src/*/*\.php$</include-pattern>
<properties>
<property name="prefixes" type="array">
<element value="block_core_"/>
<element value="render_block_core_"/>
<element value="register_block_core_"/>
</property>
<!--
The following list of functions is final and must not be extended.
It includes functions that cannot be renamed due to backward compatibility concerns.
-->
<property name="allowed_functions" type="array">
<element value="_delete_custom_logo_on_remove_site_logo"/>
<element value="_delete_site_logo_on_remove_custom_logo"/>
<element value="_delete_site_logo_on_remove_custom_logo_on_setup_theme"/>
<element value="_delete_site_logo_on_remove_theme_mods"/>
<element value="_override_custom_logo_theme_mod"/>
<element value="_sync_custom_logo_to_site_logo"/>
<element value="_wp_rest_api_autosave_meta"/>
<element value="_wp_rest_api_force_autosave_difference"/>
<element value="apply_block_core_search_border_style"/>
<element value="apply_block_core_search_border_styles"/>
<element value="build_dropdown_script_block_core_categories"/>
<element value="build_template_part_block_area_variations"/>
<element value="build_template_part_block_instance_variations"/>
<element value="build_template_part_block_variations"/>
<element value="build_variation_for_navigation_link"/>
<element value="classnames_for_block_core_search"/>
<element value="comments_block_form_defaults"/>
<element value="enqueue_legacy_post_comments_block_styles"/>
<element value="get_block_core_avatar_border_attributes"/>
<element value="get_block_core_post_featured_image_border_attributes"/>
<element value="get_block_core_post_featured_image_overlay_element_markup"/>
<element value="get_border_color_classes_for_block_core_search"/>
<element value="get_color_classes_for_block_core_search"/>
<element value="get_typography_classes_for_block_core_search"/>
<element value="get_typography_styles_for_block_core_search"/>
<element value="gutenberg_block_core_file_update_interactive_view_script"/>
<element value="gutenberg_block_core_navigation_update_interactive_view_script"/>
<element value="post_comments_form_block_form_defaults"/>
<element value="register_block_core_site_icon_setting"/>
<element value="register_legacy_post_comments_block"/>
<element value="styles_for_block_core_search"/>
<element value="wp_add_footnotes_revisions_to_post_meta"/>
<element value="wp_add_footnotes_to_revision"/>
<element value="wp_get_footnotes_from_revision"/>
<element value="wp_keep_footnotes_revision_id"/>
<element value="wp_latest_comments_draft_or_post_title"/>
<element value="wp_restore_footnotes_from_revision"/>
<element value="wp_save_footnotes_meta"/>
</property>
</properties>
</rule>
<rule ref="Gutenberg.CodeAnalysis.ForbiddenFunctionsAndClasses">
<include-pattern>/packages/block-library/src/.+/*\.php$</include-pattern>
<!--
Refactoring required: the functions and classes prefixed with 'Gutenberg_' in the files that are being excluded
through the 'exclude-pattern' statements below must be guarded, as they are available only in the Gutenberg context,
not in Core.
-->
<exclude-pattern>/packages/block-library/src/form-input/index\.php$</exclude-pattern>
<exclude-pattern>/packages/block-library/src/form-submission-notification/index\.php$</exclude-pattern>
<exclude-pattern>/packages/block-library/src/form/index\.php$</exclude-pattern>
<properties>
<property name="forbidden_functions" type="array">
<element value="[Gg]utenberg.*"/>
</property>
<property name="forbidden_classes" type="array">
<element value="[Gg]utenberg.*"/>
</property>
</properties>
</rule>
<rule ref="Gutenberg.Commenting.SinceTag">
<!-- The sniff ensures that functions have a valid @since tag but skips checking experimental blocks. -->
<include-pattern>/packages/block-library/src/.+/*\.php$</include-pattern>
<include-pattern>/packages/block-serialization-default-parser/.+/*\.php$</include-pattern>
<include-pattern>/packages/widgets/src/blocks/legacy-widget/index\.php$</include-pattern>
<include-pattern>/packages/widgets/src/blocks/widget-group/index\.php$</include-pattern>
</rule>
</ruleset>