Skip to content

Commit

Permalink
Conform project to ESLint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerkrewson committed Jul 27, 2016
1 parent a804b4a commit 5516583
Show file tree
Hide file tree
Showing 10 changed files with 1,298 additions and 1,266 deletions.
30 changes: 30 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": "off"
}
}
42 changes: 22 additions & 20 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var express = require('express');
var socketio = require('socket.io');
var path = require('path');
var favicon = require('serve-favicon');
//var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
Expand All @@ -25,43 +25,45 @@ app.set('view engine', 'jade');
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));

if (devModeEnabled) {
app.use(logger('dev'));
app.use(logger('dev'));
}

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (devModeEnabled) {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
app.use(function (err, req, res) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
app.use(function (err, req, res) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});


Expand Down
76 changes: 38 additions & 38 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ var server = http.createServer(app);
* Attach Socket.IO to the Express server.
*/

var io = app.io;
io.attach(server);
var io = app.io;
io.attach(server);

/**
* Listen on provided port, on all network interfaces.
Expand All @@ -42,57 +42,57 @@ server.on('listening', onListening);
*/

function normalizePort(val) {
var port = parseInt(val, 10);
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}
if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}
if (port >= 0) {
// port number
return port;
}

return false;
return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string' ?
'Pipe ' + port :
'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
var addr = server.address();
var bind = typeof addr === 'string' ?
'pipe ' + addr :
'port ' + addr.port;
debug('Listening on ' + bind);
}
Loading

0 comments on commit 5516583

Please sign in to comment.