Skip to content

Commit 30e96bb

Browse files
author
Dan Wallis
authored
Make exclusion list more specific for Magento template files (#11)
1 parent e187a54 commit 30e96bb

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 2.2.0
8+
## Changed
9+
- Apply more rules to .html and .phtml files. In previous updates (see pull requests [#5] and [#10]), we excluded these files very widely; this change makes the exclusion more specific and intentional.
10+
11+
[#5]: https://github.com/YouweGit/coding-standard-magento2/pull/5
12+
[#10]: https://github.com/YouweGit/coding-standard-magento2/pull/10
13+
714
## 2.1.3
815
### Fixed
916
- Youwe ruleset will not check .html files any more. See also version 2.1.0.

src/YouweMagento2/ruleset.xml

+25-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
2727
<!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. -->
2828
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing" />
29-
<exclude-pattern>*.p?html</exclude-pattern>
3029
</rule>
3130

3231
<!-- Import most rules from official Magento2 coding standard -->
@@ -49,4 +48,29 @@
4948
<property name="spacingBeforeFirst" value="0"/>
5049
</properties>
5150
</rule>
51+
52+
<!--
53+
These sniffs are in the Youwe standard, but should not apply to Magento2
54+
templates.
55+
Because the Magento2 standard tells PHP_CodeSniffer to treat all *.html
56+
and *.phtml files as PHP files, we need to add <exclude-pattern>
57+
directives to specifically stop these sniffs from applying to Magento
58+
template files. We can't use a single <exclude-pattern> directive in the
59+
<rule ref="Youwe"> block above, as that would also apply to any sniffs
60+
which are in both standards.
61+
And XML files are excluded here too.
62+
-->
63+
<rule ref="Generic.Commenting.DocComment"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
64+
<rule ref="Generic.PHP.DisallowAlternativePHPTags"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
65+
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
66+
<rule ref="PSR12.ControlStructures.ControlStructureSpacing"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
67+
<rule ref="PSR12.Files.DeclareStatement"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
68+
<rule ref="PSR12.Files.FileHeader"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
69+
<rule ref="PSR12.Traits.UseDeclaration"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
70+
<rule ref="Squiz.Arrays.ArrayDeclaration"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
71+
<rule ref="Squiz.Commenting.FunctionComment"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
72+
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
73+
<rule ref="Squiz.Commenting.VariableComment"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
74+
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
75+
<rule ref="Squiz.WhiteSpace.FunctionSpacing"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
5276
</ruleset>

0 commit comments

Comments
 (0)