Skip to content

Commit 415b18f

Browse files
authored
Merge pull request #88 from magento-commerce/jscs
AC-1355: Move JSCS into magento-coding-standards repo
2 parents ad59de1 + a635424 commit 415b18f

File tree

5 files changed

+5721
-533
lines changed

5 files changed

+5721
-533
lines changed

.github/workflows/php.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ jobs:
4242
- name: Install dependencies
4343
run: npm install
4444
- name: Run ESLint
45-
run: npm run eslint -- eslint/rules Magento2/ --ignore-pattern 'Magento2/Tests/Eslint/*Test.js'
45+
run: npm run eslint -- eslint/rules Magento2 --ignore-pattern 'Magento2/Tests/Eslint/*Test.js'
46+
- name: Run JSCS
47+
run: npm run jscs eslint/rules Magento2
4648

4749
- name: Validate composer
4850
run: composer validate

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,23 @@ Also, verify that the sniffer code itself is written according to the Magento Co
9999
vendor/bin/phpcs --standard=Magento2 Magento2/ --extensions=php
100100
```
101101

102-
### ESLint testing
102+
### ESLint and JSCS
103103
Prerequisites: [Node.js](https://nodejs.org/) (`^12.22.0`, `^14.17.0`, or `>=16.0.0`).
104104

105105
You need to run the following command to install all the necessary packages described in the `package.json` file:
106106
```bash
107107
npm install
108108
```
109109

110-
After that, you can just execute ESLint as follows:
110+
You can just execute ESLint as follows:
111111
```bash
112112
npm run eslint -- path/to/analyze
113113
```
114+
115+
Run the following command to execute JSCS:
116+
```bash
117+
npm run jscs path/to/analyze
118+
```
114119
## License
115120

116121
Each Magento source file included in this distribution is licensed under the OSL-3.0 license.

jscs/.jscsrc

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"disallowKeywords": [
3+
"with",
4+
"continue"
5+
],
6+
"disallowKeywordsOnNewLine": [
7+
"else"
8+
],
9+
"disallowSpaceBeforeBinaryOperators": [
10+
","
11+
],
12+
"disallowSpacesInFunctionDeclaration": {
13+
"beforeOpeningRoundBrace": true
14+
},
15+
"disallowSpacesInNamedFunctionExpression": {
16+
"beforeOpeningRoundBrace": true
17+
},
18+
"requireCurlyBraces": [
19+
"if",
20+
"else",
21+
"for",
22+
"while",
23+
"do",
24+
"try",
25+
"catch"
26+
],
27+
"requirePaddingNewlinesBeforeKeywords": [
28+
"do",
29+
"for",
30+
"if",
31+
"switch",
32+
"case",
33+
"try",
34+
"void",
35+
"while",
36+
"with",
37+
"return"
38+
],
39+
"requireSpaceBeforeKeywords": [
40+
"else",
41+
"while",
42+
"catch"
43+
],
44+
"requireSpaceAfterKeywords": [
45+
"if",
46+
"else",
47+
"for",
48+
"while",
49+
"do",
50+
"switch",
51+
"case",
52+
"return",
53+
"try",
54+
"catch",
55+
"function",
56+
"typeof"
57+
],
58+
"requireSpacesInAnonymousFunctionExpression": {
59+
"beforeOpeningCurlyBrace": true,
60+
"beforeOpeningRoundBrace": true
61+
},
62+
"disallowNewlineBeforeBlockStatements": true,
63+
"disallowDanglingUnderscores": null,
64+
"disallowEmptyBlocks": true,
65+
"disallowMixedSpacesAndTabs": true,
66+
"disallowMultipleLineBreaks": true,
67+
"disallowMultipleLineStrings": true,
68+
"disallowSpaceAfterObjectKeys": true,
69+
"disallowSpaceAfterPrefixUnaryOperators": true,
70+
"disallowSpaceBeforePostfixUnaryOperators": true,
71+
"disallowSpacesInCallExpression": true,
72+
"disallowSpacesInsideArrayBrackets": "all",
73+
"disallowSpacesInsideObjectBrackets": "all",
74+
"disallowSpacesInsideParentheses": true,
75+
"disallowTrailingComma": true,
76+
"disallowTrailingWhitespace": true,
77+
"disallowYodaConditions": true,
78+
"maxErrors": null,
79+
"requireBlocksOnNewline": true,
80+
"requireDotNotation": "except_snake_case",
81+
"requireCamelCaseOrUpperCaseIdentifiers": true,
82+
"requireCapitalizedConstructors": true,
83+
"requireCommaBeforeLineBreak": true,
84+
"requireLineBreakAfterVariableAssignment": true,
85+
"requireLineFeedAtFileEnd": true,
86+
"requireMultipleVarDecl": "onevar",
87+
"requireOperatorBeforeLineBreak": true,
88+
"requirePaddingNewLinesAfterUseStrict": true,
89+
"requirePaddingNewLinesInObjects": true,
90+
"requireParenthesesAroundIIFE": true,
91+
"requireSpaceAfterBinaryOperators": true,
92+
"requireSpaceBeforeBinaryOperators": true,
93+
"requireSpaceBeforeBlockStatements": true,
94+
"requireSpaceBeforeObjectValues": true,
95+
"requireSpaceBetweenArguments": true,
96+
"requireSpacesInConditionalExpression": true,
97+
"requireSpacesInForStatement": true,
98+
"validateIndentation": 4,
99+
"validateParameterSeparator": ", ",
100+
"validateQuoteMarks": "'",
101+
"jsDoc": {
102+
"checkAnnotations": {
103+
"preset": "jsdoc3",
104+
"extra": {
105+
"override": true,
106+
"inheritdoc": true,
107+
"api": true
108+
}
109+
},
110+
"checkParamNames": true,
111+
"checkRedundantParams": true,
112+
"checkRedundantReturns": true,
113+
"checkReturnTypes": true,
114+
"checkTypes": "capitalizedNativeCase",
115+
"enforceExistence": "exceptExports",
116+
"requireHyphenBeforeDescription": true,
117+
"requireParamTypes": true
118+
}
119+
}

0 commit comments

Comments
 (0)