forked from external-repos/pa11y-dashboard
Fix JSCS errors
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
// This file is part of pa11y-dashboard.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with pa11y-dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -19,20 +19,20 @@ var moment = require('moment');
|
||||
|
||||
module.exports = helper;
|
||||
|
||||
function helper (register) {
|
||||
function helper(register) {
|
||||
|
||||
// Format a date with Moment
|
||||
register('date-format', function (context, block) {
|
||||
register('date-format', function(context, block) {
|
||||
var format = block.hash.format || 'YYYY-MM-DD HH:mm:ss';
|
||||
return moment(context).format(format);
|
||||
});
|
||||
|
||||
// Get a relative date
|
||||
register('date-relative', function (context) {
|
||||
register('date-relative', function(context) {
|
||||
return moment(context).fromNow();
|
||||
});
|
||||
|
||||
register('date-timestamp', function (context) {
|
||||
register('date-timestamp', function(context) {
|
||||
return moment(context).valueOf();
|
||||
});
|
||||
|
||||
|
@@ -2,10 +2,10 @@
|
||||
|
||||
module.exports = helper;
|
||||
|
||||
function helper (register) {
|
||||
function helper(register) {
|
||||
|
||||
// Convert a string to lower-case
|
||||
register('lowercase', function (context) {
|
||||
register('lowercase', function(context) {
|
||||
return context.toLowerCase();
|
||||
});
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
// This file is part of pa11y-dashboard.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with pa11y-dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
module.exports = helper;
|
||||
|
||||
function helper (register) {
|
||||
function helper(register) {
|
||||
|
||||
// Simplify url by removing (eg http://, https://, trailing slashes) from url
|
||||
register('simplify-url', function (context) {
|
||||
register('simplify-url', function(context) {
|
||||
return context.replace(/^https?:\/\//i, '').replace(/\/$/, '').toLowerCase();
|
||||
});
|
||||
|
||||
|
@@ -1,15 +1,15 @@
|
||||
// This file is part of pa11y-dashboard.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with pa11y-dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -20,21 +20,21 @@ var rules = createStandardDescriptionMap(standardsArray);
|
||||
|
||||
module.exports = presentIgnoreRules;
|
||||
|
||||
function presentIgnoreRules (ignore) {
|
||||
return ignore.map(function (name) {
|
||||
return {
|
||||
name: name,
|
||||
description: rules[name]
|
||||
};
|
||||
});
|
||||
function presentIgnoreRules(ignore) {
|
||||
return ignore.map(function(name) {
|
||||
return {
|
||||
name: name,
|
||||
description: rules[name]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createStandardDescriptionMap (standards) {
|
||||
var map = {};
|
||||
standards.forEach(function (standard) {
|
||||
standard.rules.forEach(function (rule) {
|
||||
map[rule.name] = rule.description;
|
||||
});
|
||||
});
|
||||
return map;
|
||||
function createStandardDescriptionMap(standards) {
|
||||
var map = {};
|
||||
standards.forEach(function(standard) {
|
||||
standard.rules.forEach(function(rule) {
|
||||
map[rule.name] = rule.description;
|
||||
});
|
||||
});
|
||||
return map;
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
// This file is part of pa11y-dashboard.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with pa11y-dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -20,13 +20,13 @@ var moment = require('moment');
|
||||
|
||||
module.exports = presentResultList;
|
||||
|
||||
function presentResultList (results) {
|
||||
var resultsByDay = _.groupBy(results, function (result) {
|
||||
return moment(result.date).format('YYYY-MM-DD');
|
||||
});
|
||||
var uniqueDayResults = [];
|
||||
_.keys(resultsByDay).forEach(function (day) {
|
||||
uniqueDayResults.push(resultsByDay[day][0]);
|
||||
});
|
||||
return uniqueDayResults;
|
||||
function presentResultList(results) {
|
||||
var resultsByDay = _.groupBy(results, function(result) {
|
||||
return moment(result.date).format('YYYY-MM-DD');
|
||||
});
|
||||
var uniqueDayResults = [];
|
||||
_.keys(resultsByDay).forEach(function(day) {
|
||||
uniqueDayResults.push(resultsByDay[day][0]);
|
||||
});
|
||||
return uniqueDayResults;
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
// This file is part of pa11y-dashboard.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// pa11y-dashboard is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with pa11y-dashboard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -20,33 +20,33 @@ var presentIgnoreRules = require('./ignore');
|
||||
|
||||
module.exports = presentResult;
|
||||
|
||||
function presentResult (result) {
|
||||
function presentResult(result) {
|
||||
|
||||
// Add additional info
|
||||
result.href = '/' + result.task + '/' + result.id;
|
||||
result.hrefCsv = '/' + result.task + '/' + result.id + '.csv';
|
||||
result.hrefJson = '/' + result.task + '/' + result.id + '.json';
|
||||
// Add additional info
|
||||
result.href = '/' + result.task + '/' + result.id;
|
||||
result.hrefCsv = '/' + result.task + '/' + result.id + '.csv';
|
||||
result.hrefJson = '/' + result.task + '/' + result.id + '.json';
|
||||
|
||||
// Parse date
|
||||
result.date = new Date(result.date);
|
||||
// Parse date
|
||||
result.date = new Date(result.date);
|
||||
|
||||
// Enhance the ignored rules
|
||||
result.ignore = presentIgnoreRules(result.ignore);
|
||||
// Enhance the ignored rules
|
||||
result.ignore = presentIgnoreRules(result.ignore);
|
||||
|
||||
// Split out message types
|
||||
if (result.results) {
|
||||
var groupedByType = _.groupBy(result.results, 'type');
|
||||
['error', 'warning', 'notice'].forEach(function (type) {
|
||||
var pluralType = type + 's';
|
||||
var results = groupedByType[type] || [];
|
||||
var groupedByCode = _.groupBy(results, 'code');
|
||||
result[pluralType] = _.keys(groupedByCode).map(function (group) {
|
||||
var firstMessage = groupedByCode[group][0];
|
||||
firstMessage.count = groupedByCode[group].length;
|
||||
return firstMessage;
|
||||
});
|
||||
});
|
||||
}
|
||||
// Split out message types
|
||||
if (result.results) {
|
||||
var groupedByType = _.groupBy(result.results, 'type');
|
||||
['error', 'warning', 'notice'].forEach(function(type) {
|
||||
var pluralType = type + 's';
|
||||
var results = groupedByType[type] || [];
|
||||
var groupedByCode = _.groupBy(results, 'code');
|
||||
result[pluralType] = _.keys(groupedByCode).map(function(group) {
|
||||
var firstMessage = groupedByCode[group][0];
|
||||
firstMessage.count = groupedByCode[group].length;
|
||||
return firstMessage;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
@@ -20,25 +20,25 @@ var presentResult = require('./result');
|
||||
|
||||
module.exports = presentTask;
|
||||
|
||||
function presentTask (task) {
|
||||
function presentTask(task) {
|
||||
|
||||
// Add additional info
|
||||
task.href = '/' + task.id;
|
||||
task.hrefDelete = '/' + task.id + '/delete';
|
||||
task.hrefRun = '/' + task.id + '/run';
|
||||
task.hrefJson = '/' + task.id + '.json';
|
||||
task.hrefEdit = '/' + task.id + '/edit';
|
||||
task.hrefIgnore = '/' + task.id + '/ignore';
|
||||
task.hrefUnignore = '/' + task.id + '/unignore';
|
||||
// Add additional info
|
||||
task.href = '/' + task.id;
|
||||
task.hrefDelete = '/' + task.id + '/delete';
|
||||
task.hrefRun = '/' + task.id + '/run';
|
||||
task.hrefJson = '/' + task.id + '.json';
|
||||
task.hrefEdit = '/' + task.id + '/edit';
|
||||
task.hrefIgnore = '/' + task.id + '/ignore';
|
||||
task.hrefUnignore = '/' + task.id + '/unignore';
|
||||
|
||||
// Enhance the ignored rules
|
||||
task.ignore = presentIgnoreRules(task.ignore);
|
||||
// Enhance the ignored rules
|
||||
task.ignore = presentIgnoreRules(task.ignore);
|
||||
|
||||
// Present the last result if present
|
||||
if (task.last_result) {
|
||||
task.lastResult = presentResult(task.last_result);
|
||||
delete task.last_result;
|
||||
}
|
||||
// Present the last result if present
|
||||
if (task.last_result) {
|
||||
task.lastResult = presentResult(task.last_result);
|
||||
delete task.last_result;
|
||||
}
|
||||
|
||||
return task;
|
||||
return task;
|
||||
}
|
||||
|
Reference in New Issue
Block a user