1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-17 06:08:19 +01:00

Merge pull request #5543 from hanakin/ticket/15515

[ticket/15515] Overhaul JS linting/testing with xo/eslint
This commit is contained in:
Marc Alexander 2021-03-27 08:42:43 +01:00 committed by GitHub
commit 8a87d2bd5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 107 deletions

78
.jscsrc
View File

@ -1,78 +0,0 @@
{
"excludeFiles": ["node_modules/**", "**/build/**"],
"requireCurlyBraces": [
"if", "else", "for", "while", "do", "try", "catch"
],
"requireSpaceBeforeKeywords": [
"else", "while", "catch"
],
"requireSpaceAfterKeywords": [
"do", "for", "if", "else", "switch", "case", "try", "catch", "while", "return", "typeof"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": {
"afterTest": true,
"beforeConsequent": true,
"afterConsequent": true,
"beforeAlternate": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInCallExpression": true,
"requireBlocksOnNewline": true,
"requirePaddingNewlinesBeforeKeywords": ["case"],
"disallowEmptyBlocks": true,
"disallowSpacesInsideArrayBrackets": "nested",
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowQuotedKeysInObjects": "allButReserved",
"disallowSpaceAfterObjectKeys": true,
"requireSpaceBeforeObjectValues": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": [
"?", "=", "+", "-", "/", "*", "===", "!==", ">", ">=", "<", "<="
],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": [
"=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">="
],
"requireSpaceAfterBinaryOperators": [
"=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">="
],
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": "smart",
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": {
"value": 120,
"tabSize": 4,
"allowUrlComments": true,
"allowRegex": true
},
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"disallowYodaConditions": true,
"requireSpaceAfterLineComment": {
"allExcept": ["#", "="]
},
"disallowNewlineBeforeBlockStatements": true,
"validateQuoteMarks": {
"mark": "'",
"escape": true
},
"validateParameterSeparator": ", ",
"safeContextKeyword": ["that"]
}

View File

@ -1,25 +0,0 @@
{
"bitwise": true,
"curly": true,
"eqeqeq": true,
"es3": true,
"forin": false,
"freeze": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"undef": true,
"unused": true,
"strict": true,
"browser": true,
"devel": true,
"jquery": true,
"globals": {
"JSON": true,
"phpbb": true
}
}

View File

@ -7,12 +7,12 @@
/**
* Parse document block
*/
function parse_document(container)
function parse_document(container)
{
var test = document.createElement('div'),
oldBrowser = (typeof test.style.borderRadius == 'undefined');
delete test;
test.remove();
/**
* Navigation
@ -92,7 +92,7 @@ function parse_document(container)
}
});
}
headersLength = headers.length;
// Add header text to each cell as <dfn>
@ -159,7 +159,7 @@ function parse_document(container)
if ($this.html() == '&nbsp;') {
$this.addClass('responsive-hide');
}
});
/**

25
travis/check-js.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# This file is part of the phpBB Forum Software package.
#
# @copyright (c) phpBB Limited <https://www.phpbb.com>
# @license GNU General Public License, version 2 (GPL-2.0)
#
# For full copyright and license information, please see
# the docs/CREDITS.txt file.
#
set -e
set +x
NOTESTS=$1
if [ "$NOTESTS" == '1' ]
then
npm install -g > /dev/null
npm install > /dev/null
set -x
node_modules/xo/cli.js "phpBB/adm/style/*.js"
node_modules/xo/cli.js "phpBB/assets/javascript/*.js"
node_modules/xo/cli.js "phpBB/style/all/js/*.js"
node_modules/xo/cli.js "phpBB/style/prosilver/template/*.js"
fi