forked from mediact/coding-standard-magento2
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from YouweGit/youwe-magento2
Added magento/magento-coding-standard to keep closer to Magento standards
- Loading branch information
Showing
8 changed files
with
146 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
{ | ||
"name": "youwe/coding-standard-magento2", | ||
"description": "Youwe PHP Coding Standard for Magento2", | ||
"type": "phpcs-sniffs", | ||
"homepage": "https://github.com/YouweGit/coding-standard-magento2", | ||
"license": "proprietary", | ||
"type": "phpcodesniffer-standard", | ||
"authors": [ | ||
{ | ||
"name": "Youwe B.V.", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"homepage": "https://github.com/YouweGit/coding-standard-magento2", | ||
"require": { | ||
"youwe/coding-standard": ">=3.3.0" | ||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", | ||
"magento/magento-coding-standard": ">= 9", | ||
"youwe/coding-standard": "^3.5.0" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"MediactMagento2": "src/MediactMagento2", | ||
"Magento2": "src/Magento2" | ||
"YouweMagento2": "src/YouweMagento2" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
}, | ||
"sort-packages": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright Youwe. All rights reserved. | ||
* https://www.youweagency.com | ||
* | ||
* TODO:: Create a separate ruleset for phtml files, since a lot of exceptions need to be made just for adding phtml to code sniffer. | ||
*/ | ||
--> | ||
<ruleset name="YouweMagento2"> | ||
<description>Youwe coding standards for Magento2 websites and modules</description> | ||
<!-- TODO:: Check if these values are correct. Did not see anything about how to configure this in documentation --> | ||
<arg name="extensions" value="php/PHP,phtml/PHP,js/JS,css/CSS,xml/XML,less/CSS" /> | ||
|
||
<!-- Base rules on Youwe --> | ||
<rule ref="Youwe"> | ||
<!-- Magento 2 does not use return types everywhere in the code base yet. So we cannot make this mandatory. --> | ||
<exclude name="GlobalCommon.Php7.ReturnType" /> | ||
<!-- Magento 2 still uses $_ to tell if it's protected, so we cannot mandate this. --> | ||
<exclude name="GlobalCommon.NamingConventions.ValidVariableName" /> | ||
<!-- TODO:: Check if this rule still needs to be excluded. Seems logical that all classes should start with camelcase --> | ||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" /> | ||
<!--TODO:: Check if this should not be excluded. Seems logical to add throws in function comment. --> | ||
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows" /> | ||
<!-- Magento 2 still does not strict type arguments of functions. This is why this rule is excluded. --> | ||
<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" /> | ||
</rule> | ||
|
||
<!-- Import most rules from official Magento2 coding standard --> | ||
<rule ref="Magento2"> | ||
<!-- Excluded because short descriptions are not mandatory in Youwe for a method. --> | ||
<exclude name="Magento2.Annotation" /> | ||
<!-- | ||
Excluded because in PHP 8.1 it's already possible to declare what type it is. | ||
Also most class properties are self-explanatory. | ||
--> | ||
<exclude name="Magento2.Commenting.ClassPropertyPHPDocFormatting" /> | ||
</rule> | ||
|
||
<!-- Detects function that use a for-loops call in their function. --> | ||
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Generic.Commenting.DocComment"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed"> | ||
<!-- Magento 2 templates do not cohere to this rule. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Generic.Files.LineLength.TooLong"> | ||
<!-- Magento 2 phtml & xml both have long lines think of checkout_index_index.xml --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
<exclude-pattern>*.xml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PEAR.Functions.FunctionCallSignature"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore"> | ||
<!-- In some cases Magento 2 still uses underscores for their properties. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR2.ControlStructures.ControlStructureSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR12.ControlStructures.ControlStructureSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR12.Files.FileHeader.SpacingAfterBlock"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="PSR12.Operators.OperatorSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Squiz.ControlStructures.ControlSignature"> | ||
<!-- Magento 2 uses a different notation for patterns like do { / if { for phtml that's why this was excluded. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"> | ||
<!-- default Magento 2 templates also not cohere to this. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.MemberVarSpacing" > | ||
<properties> | ||
<property name="spacingBeforeFirst" value="0"/> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"> | ||
<!-- Magento 2 phptml files end differently and use endif; for example. --> | ||
<exclude-pattern>*.phtml</exclude-pattern> | ||
</rule> | ||
</ruleset> |