Skip to content

Commit 11475d4

Browse files
committed
Add editorconfig and update phpcs rules
1 parent 50880fa commit 11475d4

File tree

3 files changed

+107
-49
lines changed

3 files changed

+107
-49
lines changed

.editorconfig

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
# WordPress Coding Standards
5+
# https://make.wordpress.org/core/handbook/best-practices/coding-standards/
6+
7+
root = true
8+
9+
[*]
10+
charset = utf-8
11+
end_of_line = lf
12+
insert_final_newline = true
13+
trim_trailing_whitespace = true
14+
indent_style = tab
15+
16+
[*.css]
17+
indent_style = tab
18+
indent_size = 4
19+
20+
[*.scss]
21+
indent_style = tab
22+
indent_size = 4
23+
24+
[*.txt]
25+
end_of_line = crlf

.phpcs.xml.dist

-49
This file was deleted.

phpcs.xml.dist

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Twenty Twenty-One Theme Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
3+
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
4+
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
5+
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki -->
6+
<!-- See https://github.com/wimg/PHPCompatibility -->
7+
8+
<exclude-pattern>node_modules</exclude-pattern>
9+
<exclude-pattern>vendor</exclude-pattern>
10+
<exclude-pattern>bin</exclude-pattern>
11+
<exclude-pattern>tests/</exclude-pattern>
12+
<exclude-pattern>acf-json</exclude-pattern>
13+
<exclude-pattern>wp-config.sample.php</exclude-pattern>
14+
<exclude-pattern>inc</exclude-pattern>
15+
<exclude-pattern>assets</exclude-pattern>
16+
17+
<!-- Set a description for this ruleset. -->
18+
<description>A custom set of code standard rules to check for WordPress themes.</description>
19+
20+
<!-- Pass some flags to PHPCS:
21+
p flag: Show progress of the run.
22+
s flag: Show sniff codes in all reports.
23+
v flag: Print verbose output.
24+
n flag: Do not print warnings.
25+
-->
26+
<arg value="psv"/>
27+
28+
<!-- Run in parallel, it's faster. -->
29+
<arg name="parallel" value="8"/>
30+
31+
<!-- Only check the PHP, CSS and SCSS files. JS files are checked separately with JSCS and JSHint. -->
32+
<arg name="extensions" value="php"/>
33+
34+
<!-- Check all files in this directory and the directories below it. -->
35+
<file>.</file>
36+
37+
<!-- Include the WordPress ruleset. -->
38+
<rule ref="WordPress">
39+
<exclude name="WPThemeReview.PluginTerritory.ForbiddenFunctions.editor_blocks_register_block_style" />
40+
<exclude name="WPThemeReview.PluginTerritory.ForbiddenFunctions.editor_blocks_register_block_pattern" />
41+
<exclude name="WPThemeReview.PluginTerritory.ForbiddenFunctions.editor_blocks_register_block_pattern_category" />
42+
<exclude name="PHPCompatibility.FunctionDeclarations.NewClosure.Found" />
43+
</rule>
44+
<rule ref="WPThemeReview" />
45+
46+
<rule ref="WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound">
47+
<exclude-pattern>inc/customizer.php</exclude-pattern>
48+
</rule>
49+
50+
<rule ref="WPThemeReview.Templates.ReservedFileNamePrefix.ReservedTemplatePrefixFound">
51+
<exclude-pattern>template-parts/post/author-bio.php</exclude-pattern>
52+
</rule>
53+
54+
<!-- Verify that the text_domain is set to the desired text-domain.
55+
Multiple valid text domains can be provided as a comma-delimited list. -->
56+
<rule ref="WordPress.WP.I18n">
57+
<properties>
58+
<property name="text_domain" type="array" value="twentytwentyone" />
59+
</properties>
60+
</rule>
61+
62+
<!-- Allow for theme specific exceptions to the file name rules based
63+
on the theme hierarchy. -->
64+
<rule ref="WordPress.Files.FileName">
65+
<properties>
66+
<property name="is_theme" value="true" />
67+
</properties>
68+
</rule>
69+
70+
<!-- Verify that no WP functions are used which are deprecated or have been removed.
71+
The minimum version set here should be in line with the minimum WP version
72+
as set in the "Requires at least" tag in the readme.txt file. -->
73+
<rule ref="WordPress.WP.DeprecatedFunctions">
74+
<properties>
75+
<property name="minimum_supported_version" value="5.3" />
76+
</properties>
77+
</rule>
78+
79+
<!-- Include sniffs for PHP cross-version compatibility. -->
80+
<config name="testVersion" value="5.6-"/>
81+
<rule ref="PHPCompatibility"/>
82+
</ruleset>

0 commit comments

Comments
 (0)