Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ jobs:
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run eslint -- eslint/rules Magento2/ --ignore-pattern 'Magento2/Tests/Eslint/*Test.js'
run: npm run eslint -- eslint/rules Magento2 --ignore-pattern 'Magento2/Tests/Eslint/*Test.js'
- name: Run JSCS
run: npm run jscs eslint/rules Magento2

- name: Validate composer
run: composer validate
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,23 @@ Also, verify that the sniffer code itself is written according to the Magento Co
vendor/bin/phpcs --standard=Magento2 Magento2/ --extensions=php
```

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

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

After that, you can just execute ESLint as follows:
You can just execute ESLint as follows:
```bash
npm run eslint -- path/to/analyze
```

Run the following command to execute JSCS:
```bash
npm run jscs path/to/analyze
```
## License

Each Magento source file included in this distribution is licensed under the OSL-3.0 license.
Expand Down
119 changes: 119 additions & 0 deletions jscs/.jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"disallowKeywords": [
"with",
"continue"
],
"disallowKeywordsOnNewLine": [
"else"
],
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requirePaddingNewlinesBeforeKeywords": [
"do",
"for",
"if",
"switch",
"case",
"try",
"void",
"while",
"with",
"return"
],
"requireSpaceBeforeKeywords": [
"else",
"while",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"function",
"typeof"
],
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true,
"beforeOpeningRoundBrace": true
},
"disallowNewlineBeforeBlockStatements": true,
"disallowDanglingUnderscores": null,
"disallowEmptyBlocks": true,
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpacesInCallExpression": true,
"disallowSpacesInsideArrayBrackets": "all",
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideParentheses": true,
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"disallowYodaConditions": true,
"maxErrors": null,
"requireBlocksOnNewline": true,
"requireDotNotation": "except_snake_case",
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requireMultipleVarDecl": "onevar",
"requireOperatorBeforeLineBreak": true,
"requirePaddingNewLinesAfterUseStrict": true,
"requirePaddingNewLinesInObjects": true,
"requireParenthesesAroundIIFE": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"validateIndentation": 4,
"validateParameterSeparator": ", ",
"validateQuoteMarks": "'",
"jsDoc": {
"checkAnnotations": {
"preset": "jsdoc3",
"extra": {
"override": true,
"inheritdoc": true,
"api": true
}
},
"checkParamNames": true,
"checkRedundantParams": true,
"checkRedundantReturns": true,
"checkReturnTypes": true,
"checkTypes": "capitalizedNativeCase",
"enforceExistence": "exceptExports",
"requireHyphenBeforeDescription": true,
"requireParamTypes": true
}
}
Loading