summaryrefslogtreecommitdiffstats
path: root/core/scripts
diff options
context:
space:
mode:
authorLauri Eskola2017-10-08 10:01:20 (GMT)
committerLauri Eskola2017-10-08 10:01:20 (GMT)
commitd0fa5b72395ddde8a636fb4a2e394c9be42528f5 (patch)
tree3e4b58ee7206487be0855946e89f0d2b1a114e85 /core/scripts
parente9b77163056bfc130268b55c76ec06e6a31f04ee (diff)
Issue #2912961 by dawehner, droplet, drpal: Step 0 JS codestyle: Exclude non passing eslint rules
Diffstat (limited to 'core/scripts')
-rw-r--r--core/scripts/js/eslint-stats-by-type.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/core/scripts/js/eslint-stats-by-type.js b/core/scripts/js/eslint-stats-by-type.js
new file mode 100644
index 0000000..7ca6a13
--- /dev/null
+++ b/core/scripts/js/eslint-stats-by-type.js
@@ -0,0 +1,35 @@
+module.exports = function (results) {
+ results = results || [];
+
+ const errorType = {
+ warnings: {},
+ errors: {},
+ };
+
+ results.reduce((result, current) => {
+ current.messages.forEach((msg) => {
+ if (msg.severity === 1) {
+ errorType.warnings[msg.ruleId] = errorType.warnings[msg.ruleId] + 1 || 1
+ }
+ if (msg.severity === 2) {
+ errorType.errors[msg.ruleId] = errorType.errors[msg.ruleId] + 1 || 1
+ }
+ });
+ return result;
+ });
+
+ const reduceErrorCounts = (errorType) => Object.entries(errorType).sort((a, b) => b[1] - a[1])
+ .reduce((result, current) => result.concat([`${current[0]}: ${current[1]}`]), []).join('\n');
+
+ const warnings = reduceErrorCounts(errorType.warnings);
+ const errors = reduceErrorCounts(errorType.errors);
+
+ return `
+Errors:
+${'='.repeat(30)}
+${errors}
+${'\n'.repeat(4)}
+Warnings:
+${'='.repeat(30)}
+${warnings}`;
+};