Tooling update (#184)

* Use a common Makefile/build process

* Use ESLint with the pa11y lint config
This commit is contained in:
Rowan Manning
2017-03-21 13:41:46 +00:00
committed by GitHub
parent e27e129677
commit b24076abf1
39 changed files with 370 additions and 375 deletions

View File

@@ -12,7 +12,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
'use strict';
const presentTask = require('../../view/presenter/task');
@@ -22,24 +21,24 @@ module.exports = route;
// Route definition
function route(app) {
app.express.get('/:id/delete', (req, res, next) => {
app.webservice.task(req.params.id).get({}, (err, task) => {
if (err) {
app.express.get('/:id/delete', (request, response, next) => {
app.webservice.task(request.params.id).get({}, (error, task) => {
if (error) {
return next();
}
res.render('task/delete', {
response.render('task/delete', {
task: presentTask(task),
isTaskSubPage: true
});
});
});
app.express.post('/:id/delete', (req, res, next) => {
app.webservice.task(req.params.id).remove(err => {
if (err) {
app.express.post('/:id/delete', (request, response, next) => {
app.webservice.task(request.params.id).remove(error => {
if (error) {
return next();
}
res.redirect('/?deleted');
response.redirect('/?deleted');
});
});

View File

@@ -12,9 +12,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
/*jshint maxcomplexity:12*/
'use strict';
const presentTask = require('../../view/presenter/task');
@@ -26,9 +23,9 @@ module.exports = route;
// Route definition
function route(app) {
app.express.get('/:id/edit', (req, res, next) => {
app.webservice.task(req.params.id).get({}, (err, task) => {
if (err) {
app.express.get('/:id/edit', (request, response, next) => {
app.webservice.task(request.params.id).get({}, (error, task) => {
if (error) {
return next();
}
const standards = getStandards().map(standard => {
@@ -44,8 +41,8 @@ function route(app) {
return standard;
});
task.actions = (task.actions ? task.actions.join('\n') : '');
res.render('task/edit', {
edited: (typeof req.query.edited !== 'undefined'),
response.render('task/edit', {
edited: (typeof request.query.edited !== 'undefined'),
standards: standards,
task: presentTask(task),
isTaskSubPage: true
@@ -53,18 +50,18 @@ function route(app) {
});
});
app.express.post('/:id/edit', (req, res, next) => {
app.webservice.task(req.params.id).get({}, (err, task) => {
if (err) {
app.express.post('/:id/edit', (request, response, next) => {
app.webservice.task(request.params.id).get({}, (error, task) => {
if (error) {
return next();
}
const originalActions = req.body.actions;
const originalHeaders = req.body.headers;
req.body.ignore = req.body.ignore || [];
req.body.timeout = req.body.timeout || undefined;
req.body.wait = req.body.wait || undefined;
if (req.body.actions) {
req.body.actions = req.body.actions.split(/[\r\n]+/)
const originalActions = request.body.actions;
const originalHeaders = request.body.headers;
request.body.ignore = request.body.ignore || [];
request.body.timeout = request.body.timeout || undefined;
request.body.wait = request.body.wait || undefined;
if (request.body.actions) {
request.body.actions = request.body.actions.split(/[\r\n]+/)
.map(action => {
return action.trim();
})
@@ -72,24 +69,24 @@ function route(app) {
return Boolean(action);
});
}
if (!req.body.actions) {
req.body.actions = [];
if (!request.body.actions) {
request.body.actions = [];
}
req.body.username = req.body.username || undefined;
req.body.password = req.body.password || undefined;
req.body.hideElements = req.body.hideElements || undefined;
req.body.headers = httpHeaders(req.body.headers || '', true);
app.webservice.task(req.params.id).edit(req.body, err => {
if (err) {
task.name = req.body.name;
task.ignore = req.body.ignore;
task.timeout = req.body.timeout;
task.wait = req.body.wait;
request.body.username = request.body.username || undefined;
request.body.password = request.body.password || undefined;
request.body.hideElements = request.body.hideElements || undefined;
request.body.headers = httpHeaders(request.body.headers || '', true);
app.webservice.task(request.params.id).edit(request.body, error => {
if (error) {
task.name = request.body.name;
task.ignore = request.body.ignore;
task.timeout = request.body.timeout;
task.wait = request.body.wait;
task.actions = originalActions;
task.username = req.body.username;
task.password = req.body.password;
task.username = request.body.username;
task.password = request.body.password;
task.headers = originalHeaders;
task.hideElements = req.body.hideElements;
task.hideElements = request.body.hideElements;
const standards = getStandards().map(standard => {
if (standard.title === task.standard) {
standard.selected = true;
@@ -102,14 +99,14 @@ function route(app) {
});
return standard;
});
return res.render('task/edit', {
error: err,
return response.render('task/edit', {
error: error,
standards: standards,
task: task,
isTaskSubPage: true
});
}
res.redirect(`/${req.params.id}/edit?edited`);
response.redirect(`/${request.params.id}/edit?edited`);
});
});
});

View File

@@ -5,20 +5,20 @@ module.exports = route;
// Route definition
function route(app) {
app.express.post('/:id/ignore', (req, res, next) => {
app.webservice.task(req.params.id).get({}, (err, task) => {
if (err) {
app.express.post('/:id/ignore', (request, response, next) => {
app.webservice.task(request.params.id).get({}, (error, task) => {
if (error) {
return next();
}
const edit = {
name: task.name,
ignore: task.ignore
};
if (typeof req.body.rule === 'string') {
edit.ignore.push(req.body.rule);
if (typeof request.body.rule === 'string') {
edit.ignore.push(request.body.rule);
}
app.webservice.task(req.params.id).edit(edit, () => {
res.redirect(`/${req.params.id}?rule-ignored`);
app.webservice.task(request.params.id).edit(edit, () => {
response.redirect(`/${request.params.id}?rule-ignored`);
});
});
});

View File

@@ -12,7 +12,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
'use strict';
const presentTask = require('../../view/presenter/task');
@@ -24,24 +23,24 @@ module.exports = route;
// Route definition
function route(app) {
app.express.get('/:id', (req, res, next) => {
app.webservice.task(req.params.id).get({lastres: true}, (err, task) => {
if (err) {
app.express.get('/:id', (request, response, next) => {
app.webservice.task(request.params.id).get({lastres: true}, (error, task) => {
if (error) {
return next();
}
app.webservice.task(req.params.id).results({}, (err, results) => {
if (err) {
return next(err);
app.webservice.task(request.params.id).results({}, (error, results) => {
if (error) {
return next(error);
}
const presentedResults = presentResultList(results.map(presentResult));
res.render('task', {
response.render('task', {
task: presentTask(task),
results: presentedResults,
mainResult: task.lastResult || null,
added: (typeof req.query.added !== 'undefined'),
running: (typeof req.query.running !== 'undefined'),
ruleIgnored: (typeof req.query['rule-ignored'] !== 'undefined'),
ruleUnignored: (typeof req.query['rule-unignored'] !== 'undefined'),
added: (typeof request.query.added !== 'undefined'),
running: (typeof request.query.running !== 'undefined'),
ruleIgnored: (typeof request.query['rule-ignored'] !== 'undefined'),
ruleUnignored: (typeof request.query['rule-unignored'] !== 'undefined'),
hasOneResult: (presentedResults.length < 2),
isTaskPage: true
});

View File

@@ -12,7 +12,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
'use strict';
module.exports = route;
@@ -20,12 +19,12 @@ module.exports = route;
// Route definition
function route(app) {
app.express.get('/:id/run', (req, res, next) => {
app.webservice.task(req.params.id).run(err => {
if (err) {
app.express.get('/:id/run', (request, response, next) => {
app.webservice.task(request.params.id).run(error => {
if (error) {
return next();
}
res.redirect(`/${req.params.id}?running`);
response.redirect(`/${request.params.id}?running`);
});
});

View File

@@ -5,21 +5,21 @@ module.exports = route;
// Route definition
function route(app) {
app.express.post('/:id/unignore', (req, res, next) => {
app.webservice.task(req.params.id).get({}, (err, task) => {
if (err) {
app.express.post('/:id/unignore', (request, response, next) => {
app.webservice.task(request.params.id).get({}, (error, task) => {
if (error) {
return next();
}
const edit = {
name: task.name,
ignore: task.ignore
};
const indexOfRule = edit.ignore.indexOf(req.body.rule);
if (typeof req.body.rule === 'string' && indexOfRule !== -1) {
const indexOfRule = edit.ignore.indexOf(request.body.rule);
if (typeof request.body.rule === 'string' && indexOfRule !== -1) {
edit.ignore.splice(indexOfRule, 1);
}
app.webservice.task(req.params.id).edit(edit, () => {
res.redirect(`/${req.params.id}?rule-unignored`);
app.webservice.task(request.params.id).edit(edit, () => {
response.redirect(`/${request.params.id}?rule-unignored`);
});
});
});