Skip to content

Commit d77dd43

Browse files
authored
Merge pull request #5 from fredden/youwe-magento2
Create Youwe coding standard
2 parents bd41fad + 8f3b6e7 commit d77dd43

File tree

5 files changed

+232
-9
lines changed

5 files changed

+232
-9
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ composer global require youwe/coding-standard
1515
First configure PHPStorm to use the right phpcs command.
1616

1717
Go to __Settings > Languages & Frameworks > PHP > Code Sniffer__. Choose
18-
"Local" for the path and fill in the full path to
18+
"Local" for the path and fill in the full path to
1919
`~/.config/composer/vendor/bin/phpcs`
2020

2121
Then go to __Settings > Editor > Inspections__ and search for PHP Code Sniffer
22-
Validation. Select Custom and the add the path to
23-
`~/.config/composer/vendor/youwe/coding-standard/src/Global`
22+
Validation. Select Custom and the add the path to
23+
`~/.config/composer/vendor/youwe/coding-standard/src/Youwe`
2424

2525
# Using the coding standard in a project
2626

@@ -39,7 +39,7 @@ project.
3939
```xml
4040
<?xml version="1.0"?>
4141
<ruleset>
42-
<rule ref="./vendor/youwe/coding-standard/src/Global"/>
42+
<rule ref="./vendor/youwe/coding-standard/src/Youwe"/>
4343
</ruleset>
4444
```
4545

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"name": "youwe/coding-standard",
33
"description": "Youwe PHP Coding Standard",
4-
"type": "phpcs-sniffs",
54
"license": "MIT",
6-
"prefer-stable": true,
7-
"minimum-stability": "stable",
5+
"type": "phpcs-sniffs",
86
"authors": [
97
{
108
"name": "Youwe B.V.",
@@ -14,8 +12,10 @@
1412
"require": {
1513
"php": "^7.0 || ^8.0",
1614
"phpmd/phpmd": "^2.0",
17-
"squizlabs/php_codesniffer": "~3.5.4 || ~3.6.0"
15+
"squizlabs/php_codesniffer": "^3.5.4"
1816
},
17+
"minimum-stability": "stable",
18+
"prefer-stable": true,
1919
"autoload": {
2020
"psr-4": {
2121
"Youwe\\CodingStandard\\": "src"

src/GlobalCommon/ruleset.xml

+15-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@
6565
<!-- Files -->
6666
<rule ref="Generic.Files.ByteOrderMark"/>
6767
<rule ref="Generic.Files.LineEndings"/>
68-
<rule ref="Generic.Files.LineLength"/>
68+
<rule ref="Generic.Files.LineLength">
69+
<exclude-pattern>*.xml</exclude-pattern>
70+
<properties>
71+
<property name="lineLimit" value="200" />
72+
<property name="absoluteLineLimit" value="800" />
73+
<property name="ignoreComments" value="true" />
74+
</properties>
75+
</rule>
6976

7077
<!-- Formatting -->
7178
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
@@ -96,4 +103,11 @@
96103

97104
<!-- Whitespace -->
98105
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
106+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
107+
<properties>
108+
<property name="spacing" value="1" />
109+
<property name="spacingBeforeFirst" value="0" />
110+
<property name="spacingAfterLast" value="0" />
111+
</properties>
112+
</rule>
99113
</ruleset>

src/Youwe/eslintrc.json

+192
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
{
2+
"env": {
3+
"amd": true,
4+
"browser": true,
5+
"es6": true,
6+
"es2016": true,
7+
"es2017": true,
8+
"es2018": true,
9+
"es2019": true,
10+
"es2020": true,
11+
"es2021": true,
12+
"es2022": true,
13+
"jquery": true,
14+
"prototypejs": true
15+
},
16+
"rules": {
17+
"array-bracket-spacing": [2, "never"],
18+
"arrow-parens": 2,
19+
"arrow-spacing": [2, {"after": true, "before": true}],
20+
"block-spacing": [2, "always"],
21+
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
22+
"comma-dangle": [ 2, "always-multiline" ],
23+
"comma-spacing": [2, {"after": true, "before": false}],
24+
"comma-style": [2, "last"],
25+
"consistent-return": 2,
26+
"constructor-super": 2,
27+
"curly": [2, "all"],
28+
"dot-location": [2, "property"],
29+
"dot-notation": [2, {"allowKeywords": true}],
30+
"eol-last": 2,
31+
"eqeqeq": [2, "smart"],
32+
"func-call-spacing": [2, "never"],
33+
"func-style": [2, "expression"],
34+
"generator-star-spacing": [2, {"after": true, "before": true}],
35+
"guard-for-in": 2,
36+
"indent": [2, 4],
37+
"key-spacing": [2, {"afterColon": true, "beforeColon": false}],
38+
"keyword-spacing": [2, {"after": true, "before": true}],
39+
"linebreak-style": [2, "unix"],
40+
"lines-around-comment": [
41+
2,
42+
{
43+
"beforeBlockComment": true,
44+
"allowBlockStart": true,
45+
"allowObjectStart": true
46+
}
47+
],
48+
"lines-between-class-members": [2, "always", {"exceptAfterSingleLine": true}],
49+
"max-depth": [2, 2],
50+
"max-len": [2, 120, 4],
51+
"max-nested-callbacks": [2, 3],
52+
"multiline-ternary": [2, "always-multiline"],
53+
"new-cap": [2, {"capIsNew": false, "newIsCap": true, "properties": true}],
54+
"new-parens": 2,
55+
"newline-after-var": 2,
56+
"no-alert": 2,
57+
"no-array-constructor": 2,
58+
"no-caller": 2,
59+
"no-case-declarations": 2,
60+
"no-catch-shadow": 2,
61+
"no-class-assign": 2,
62+
"no-compare-neg-zero": 2,
63+
"no-cond-assign": 2,
64+
"no-console": 2,
65+
"no-const-assign": 2,
66+
"no-constant-condition": 2,
67+
"no-control-regex": 2,
68+
"no-debugger": 2,
69+
"no-delete-var": 2,
70+
"no-dupe-args": 2,
71+
"no-dupe-class-members": 2,
72+
"no-dupe-keys": 2,
73+
"no-duplicate-case": 2,
74+
"no-else-return": 2,
75+
"no-empty-character-class": 2,
76+
"no-empty-pattern": 2,
77+
"no-empty": [2, {"allowEmptyCatch": true}],
78+
"no-eval": 2,
79+
"no-ex-assign": 2,
80+
"no-extend-native": 2,
81+
"no-extra-bind": 2,
82+
"no-extra-boolean-cast": 2,
83+
"no-extra-parens": 2,
84+
"no-extra-semi": 2,
85+
"no-fallthrough": 2,
86+
"no-floating-decimal": 2,
87+
"no-func-assign": 2,
88+
"no-global-assign": 2,
89+
"no-implied-eval": 2,
90+
"no-inner-declarations": 2,
91+
"no-invalid-regexp": 2,
92+
"no-irregular-whitespace": 2,
93+
"no-iterator": 2,
94+
"no-labels": [2, {"allowLoop": false, "allowSwitch": false}],
95+
"no-lone-blocks": 2,
96+
"no-lonely-if": 2,
97+
"no-loop-func": 2,
98+
"no-mixed-operators": [2, {"allowSamePrecedence": true, "groups": [["==", "!=", "===", "!==", ">", ">=", "<", "<="], ["&&", "||"], ["in", "instanceof"]]}],
99+
"no-mixed-spaces-and-tabs": 2,
100+
"no-multi-spaces": 2,
101+
"no-multi-str": 2,
102+
"no-multiple-empty-lines": [2, {"max": 1, "maxEOF": 0}],
103+
"no-native-reassign": 2,
104+
"no-negated-in-lhs": 2,
105+
"no-new-func": 2,
106+
"no-new-object": 2,
107+
"no-new-symbol": 2,
108+
"no-new-wrappers": 2,
109+
"no-new": 2,
110+
"no-obj-calls": 2,
111+
"no-octal-escape": 2,
112+
"no-octal": 2,
113+
"no-proto": 2,
114+
"no-prototype-builtins": 2,
115+
"no-redeclare": 2,
116+
"no-regex-spaces": 2,
117+
"no-return-assign": 2,
118+
"no-self-assign": [2, {"props": true}],
119+
"no-self-compare": 2,
120+
"no-sequences": 2,
121+
"no-shadow": 2,
122+
"no-shadow-restricted-names": 2,
123+
"no-sparse-arrays": 2,
124+
"no-tabs": 2,
125+
"no-template-curly-in-string": 2,
126+
"no-this-before-super": 2,
127+
"no-throw-literal": 2,
128+
"no-trailing-spaces": 2,
129+
"no-undef": 2,
130+
"no-undef-init": 2,
131+
"no-unexpected-multiline": 2,
132+
"no-unmodified-loop-condition": 2,
133+
"no-unneeded-ternary": [2, {"defaultAssignment": false}],
134+
"no-unreachable": 2,
135+
"no-unsafe-finally": 2,
136+
"no-unsafe-negation": 2,
137+
"no-unused-expressions": [2, {"allowShortCircuit": true, "allowTaggedTemplates": true, "allowTernary": true}],
138+
"no-unused-labels": 2,
139+
"no-unused-vars": [
140+
2,
141+
{
142+
"args": "after-used",
143+
"vars": "all",
144+
"varsIgnorePattern": "^config$"
145+
}
146+
],
147+
"no-use-before-define": 2,
148+
"no-useless-call": 2,
149+
"no-useless-computed-key": 2,
150+
"no-useless-constructor": 2,
151+
"no-useless-escape": 2,
152+
"no-useless-rename": 2,
153+
"no-useless-return": 2,
154+
"no-var": 2,
155+
"no-void": 2,
156+
"no-whitespace-before-property": 2,
157+
"no-with": 2,
158+
"object-curly-newline": [2, {"consistent": true, "multiline": true}],
159+
"object-curly-spacing": [2, "always"],
160+
"object-property-newline": [2, {"allowMultiplePropertiesPerLine": true}],
161+
"one-var": [2, {"initialized": "never"}],
162+
"operator-assignment": [2, "always"],
163+
"operator-linebreak": [2, "after", {"overrides": {":": "before", "?": "before", "|>": "before"}}],
164+
"padded-blocks": [2, {"blocks": "never", "classes": "never", "switches": "never"}],
165+
"prefer-const": [2, {"destructuring": "all"}],
166+
"prefer-promise-reject-errors": 2,
167+
"quote-props": [2, "as-needed"],
168+
"quotes": [2, "single", {"allowTemplateLiterals": true, "avoidEscape": true}],
169+
"radix": 2,
170+
"require-yield": 2,
171+
"rest-spread-spacing": [2, "never"],
172+
"semi": [2, "always"],
173+
"semi-spacing": 2,
174+
"space-before-blocks": [2, "always"],
175+
"space-before-function-paren": [2, "always"],
176+
"space-in-parens": [2, "never"],
177+
"space-infix-ops": 2,
178+
"space-unary-ops": [2, {"nonwords": false, "words": true}],
179+
"spaced-comment": [2, "always", {"block": {"balanced": true, "exceptions": ["*"], "markers": ["*package", "!", ",", ":", "::", "flow-include"]}, "line": {"markers": ["*package", "!", "/", ",", "="]}}],
180+
"strict": ["error", "function"],
181+
"symbol-description": 2,
182+
"template-curly-spacing": [2, "never"],
183+
"template-tag-spacing": [2, "never"],
184+
"unicode-bom": [2, "never"],
185+
"use-isnan": 2,
186+
"valid-typeof": 2,
187+
"vars-on-top": 2,
188+
"wrap-iife": [2, "any", {"functionPrototypeMethods": true}],
189+
"yield-star-spacing": [2, "both"],
190+
"yoda": [2, "never"]
191+
}
192+
}

src/Youwe/ruleset.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright Youwe. All rights reserved.
5+
* https://www.youweagency.com
6+
*/
7+
-->
8+
<ruleset name="Youwe">
9+
<description>Youwe coding standards</description>
10+
11+
<rule ref="../GlobalCommon"/>
12+
<rule ref="../GlobalPhpUnit"/>
13+
14+
<rule ref="Generic.Classes.DuplicateClassName" />
15+
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
16+
<rule ref="Squiz.PHP.Eval" />
17+
</ruleset>

0 commit comments

Comments
 (0)