Skip to content

Make exclusion list more specific for Magento template files #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.2.0
## Changed
- 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.

[#5]: https://github.com/YouweGit/coding-standard-magento2/pull/5
[#10]: https://github.com/YouweGit/coding-standard-magento2/pull/10

## 2.1.3
### Fixed
- Youwe ruleset will not check .html files any more. See also version 2.1.0.
Expand Down
26 changes: 25 additions & 1 deletion src/YouweMagento2/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
<!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing" />
<exclude-pattern>*.p?html</exclude-pattern>
</rule>

<!-- Import most rules from official Magento2 coding standard -->
Expand All @@ -49,4 +48,29 @@
<property name="spacingBeforeFirst" value="0"/>
</properties>
</rule>

<!--
These sniffs are in the Youwe standard, but should not apply to Magento2
templates.
Because the Magento2 standard tells PHP_CodeSniffer to treat all *.html
and *.phtml files as PHP files, we need to add <exclude-pattern>
directives to specifically stop these sniffs from applying to Magento
template files. We can't use a single <exclude-pattern> directive in the
<rule ref="Youwe"> block above, as that would also apply to any sniffs
which are in both standards.
And XML files are excluded here too.
-->
<rule ref="Generic.Commenting.DocComment"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Generic.PHP.DisallowAlternativePHPTags"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="PSR12.ControlStructures.ControlStructureSpacing"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="PSR12.Files.DeclareStatement"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="PSR12.Files.FileHeader"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="PSR12.Traits.UseDeclaration"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Squiz.Arrays.ArrayDeclaration"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Squiz.Commenting.FunctionComment"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Squiz.Commenting.VariableComment"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
<rule ref="Squiz.WhiteSpace.FunctionSpacing"><exclude-pattern>*.(x|p?ht)ml$</exclude-pattern></rule>
</ruleset>