From 2e031f3759e6751d04170a218122ad73b91b5a09 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Sat, 18 Feb 2017 01:31:47 -0700
Subject: [PATCH] ESlint comma-spacing
---
.eslintrc | 21 +++++++++++++--------
app.js | 4 ++--
install/web.js | 2 +-
public/src/admin/appearance/skins.js | 2 +-
public/src/admin/general/dashboard.js | 8 ++++----
public/src/client/topic/votes.js | 2 +-
public/src/modules/helpers.js | 2 +-
public/src/modules/postSelect.js | 2 +-
public/src/utils.js | 2 +-
src/controllers/admin/plugins.js | 2 +-
src/database/mongo/sets.js | 2 +-
src/database/mongo/sorted.js | 2 +-
src/groups/search.js | 2 +-
src/logger.js | 6 +++---
src/messaging.js | 4 ++--
src/privileges/categories.js | 4 ++--
src/routes/index.js | 2 +-
src/user/notifications.js | 2 +-
test/categories.js | 2 +-
test/database/sets.js | 8 ++++----
test/database/sorted.js | 10 +++++-----
test/mocks/databasemock.js | 2 +-
test/topics.js | 6 +++---
test/user.js | 4 ++--
24 files changed, 54 insertions(+), 49 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index cea249bb96..7fc8f5ecf8 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -2,6 +2,7 @@
"extends": "airbnb",
"rules": {
+ // Customized
"handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
"comma-dangle": ["error", {
"arrays": "always-multiline",
@@ -10,17 +11,22 @@
"exports": "always-multiline",
"functions": "never"
}],
+ "no-empty": ["error", { "allowEmptyCatch": true }],
+ "no-underscore-dangle": "off",
+ "newline-per-chained-call": "off",
+ "no-console": "off",
+
+ // ES6
+ "prefer-rest-params": "off",
+ "prefer-spread": "off",
+
+ // TODO
"import/no-unresolved": "off",
"import/no-extraneous-dependencies": "off",
"import/no-dynamic-require": "off",
"import/newline-after-import": "off",
"no-bitwise": "off",
- "newline-per-chained-call": "off",
- "no-console": "off",
- "no-empty": ["error", { "allowEmptyCatch": true }],
- "prefer-rest-params": "off",
- "prefer-spread": "off",
- "no-underscore-dangle": "off",
+ "global-require": "off",
// "linebreak-style": "off",
// "one-var": "off",
@@ -94,8 +100,7 @@
"quotes": "off",
"keyword-spacing": "off",
"no-mixed-operators": "off",
- "comma-spacing": "off",
- "global-require": "off",
+ // "comma-spacing": "off",
// "no-trailing-spaces": "off",
// "key-spacing": "off",
// "no-multiple-empty-lines": "off",
diff --git a/app.js b/app.js
index c85e30ef0a..5a88f999b1 100644
--- a/app.js
+++ b/app.js
@@ -36,7 +36,7 @@ winston.add(winston.transports.Console, {
colorize: true,
timestamp: function () {
var date = new Date();
- return (!!nconf.get('json-logging')) ? date.toJSON() : date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,8) + ' [' + global.process.pid + ']';
+ return (!!nconf.get('json-logging')) ? date.toJSON() : date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0, 8) + ' [' + global.process.pid + ']';
},
level: nconf.get('log-level') || (global.env === 'production' ? 'info' : 'verbose'),
json: (!!nconf.get('json-logging')),
@@ -155,7 +155,7 @@ function setup() {
var separator = ' ';
if (process.stdout.columns > 10) {
- for(var x = 0,cols = process.stdout.columns - 10; x < cols; x += 1) {
+ for(var x = 0, cols = process.stdout.columns - 10; x < cols; x += 1) {
separator += '=';
}
}
diff --git a/install/web.js b/install/web.js
index 2b086dc890..86dbd18013 100644
--- a/install/web.js
+++ b/install/web.js
@@ -17,7 +17,7 @@ winston.add(winston.transports.File, {
colorize: true,
timestamp: function () {
var date = new Date();
- return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']';
+ return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0, 5) + ' [' + global.process.pid + ']';
},
level: 'verbose',
});
diff --git a/public/src/admin/appearance/skins.js b/public/src/admin/appearance/skins.js
index f7de9997a7..d6cc31ea8a 100644
--- a/public/src/admin/appearance/skins.js
+++ b/public/src/admin/appearance/skins.js
@@ -73,7 +73,7 @@ define('admin/appearance/skins', ['translator'], function (translator) {
if (config['theme:src']) {
var skin = config['theme:src']
.match(/latest\/(\S+)\/bootstrap.min.css/)[1]
- .replace(/(^|\s)([a-z])/g , function (m,p1,p2) { return p1 + p2.toUpperCase(); });
+ .replace(/(^|\s)([a-z])/g, function (m, p1, p2) { return p1 + p2.toUpperCase(); });
highlightSelectedTheme(skin);
}
diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js
index b598618d58..1c10cc4df4 100644
--- a/public/src/admin/general/dashboard.js
+++ b/public/src/admin/general/dashboard.js
@@ -126,7 +126,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
topics: null,
};
- var topicColors = ["#bf616a","#5B90BF","#d08770","#ebcb8b","#a3be8c","#96b5b4","#8fa1b3","#b48ead","#ab7967","#46BFBD"];
+ var topicColors = ["#bf616a", "#5B90BF", "#d08770", "#ebcb8b", "#a3be8c", "#96b5b4", "#8fa1b3", "#b48ead", "#ab7967", "#46BFBD"];
var usedTopicColors = [];
// from chartjs.org
@@ -138,7 +138,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
usePound = true;
}
- var num = parseInt(col,16);
+ var num = parseInt(col, 16);
var r = (num >> 16) + amt;
@@ -196,7 +196,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
pointHoverBackgroundColor: "#fff",
pointBorderColor: "#fff",
pointHoverBorderColor: "rgba(220,220,220,1)",
- data: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
},
{
label: translations[1],
@@ -206,7 +206,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
pointHoverBackgroundColor: "#fff",
pointBorderColor: "#fff",
pointHoverBorderColor: "rgba(151,187,205,1)",
- data: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
+ data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
},
],
};
diff --git a/public/src/client/topic/votes.js b/public/src/client/topic/votes.js
index 53b898ee67..ea0ad4291e 100644
--- a/public/src/client/topic/votes.js
+++ b/public/src/client/topic/votes.js
@@ -66,7 +66,7 @@ define('forum/topic/votes', ['components', 'translator'], function (components,
var post = button.parents('[data-pid]');
var currentState = post.find(className).length;
- socket.emit(currentState ? 'posts.unvote' : method , {
+ socket.emit(currentState ? 'posts.unvote' : method, {
pid: post.attr('data-pid'),
room_id: app.currentRoom,
}, function (err) {
diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js
index 0fcde40a07..fb56e904f6 100644
--- a/public/src/modules/helpers.js
+++ b/public/src/modules/helpers.js
@@ -56,7 +56,7 @@
helpers.stringify = function (obj) {
// Turns the incoming object into a JSON string
- return JSON.stringify(obj).replace(/&/gm,"&").replace(//gm,">").replace(/"/g, '"');
+ return JSON.stringify(obj).replace(/&/gm, "&").replace(//gm, ">").replace(/"/g, '"');
};
helpers.escape = function (str) {
diff --git a/public/src/modules/postSelect.js b/public/src/modules/postSelect.js
index 59cb6a3043..21629786a7 100644
--- a/public/src/modules/postSelect.js
+++ b/public/src/modules/postSelect.js
@@ -33,7 +33,7 @@ define('postSelect', ['components'], function (components) {
}
if (PostSelect.pids.length) {
- PostSelect.pids.sort(function (a,b) { return a - b; });
+ PostSelect.pids.sort(function (a, b) { return a - b; });
}
callback();
}
diff --git a/public/src/utils.js b/public/src/utils.js
index 96c2dcd310..93b67dff5c 100644
--- a/public/src/utils.js
+++ b/public/src/utils.js
@@ -258,7 +258,7 @@
},
escapeHTML: function (raw) {
- return raw.replace(/&/gm,"&").replace(//gm,">");
+ return raw.replace(/&/gm, "&").replace(//gm, ">");
},
isAndroidBrowser: function () {
diff --git a/src/controllers/admin/plugins.js b/src/controllers/admin/plugins.js
index d339276286..84d0335059 100644
--- a/src/controllers/admin/plugins.js
+++ b/src/controllers/admin/plugins.js
@@ -33,7 +33,7 @@ pluginsController.get = function (req, res, next) {
return pkgData.name;
});
- res.render('admin/extend/plugins' , {
+ res.render('admin/extend/plugins', {
installed: payload.compatible.filter(function (plugin) {
return plugin.installed;
}),
diff --git a/src/database/mongo/sets.js b/src/database/mongo/sets.js
index 51c0070e3d..b10682e8d5 100644
--- a/src/database/mongo/sets.js
+++ b/src/database/mongo/sets.js
@@ -100,7 +100,7 @@ module.exports = function (db, module) {
}
value = helpers.valueToString(value);
- db.collection('objects').findOne({_key: key, members: value}, {_id: 0, members: 0},function (err, item) {
+ db.collection('objects').findOne({_key: key, members: value}, {_id: 0, members: 0}, function (err, item) {
callback(err, item !== null && item !== undefined);
});
};
diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js
index 23105bd44a..fb7815be68 100644
--- a/src/database/mongo/sorted.js
+++ b/src/database/mongo/sorted.js
@@ -157,7 +157,7 @@ module.exports = function (db, module) {
return callback();
}
var pipeline = [
- { $match: { _key: { $in: keys } } } ,
+ { $match: { _key: { $in: keys } } },
{ $group: { _id: {_key: '$_key'}, count: { $sum: 1 } } },
{ $project: { _id: 1, count: '$count' } },
];
diff --git a/src/groups/search.js b/src/groups/search.js
index 893b687b68..0b7f672d0c 100644
--- a/src/groups/search.js
+++ b/src/groups/search.js
@@ -119,7 +119,7 @@ module.exports = function (Groups) {
}
});
- results.users.sort(function (a,b) {
+ results.users.sort(function (a, b) {
if (a.isOwner && !b.isOwner) {
return -1;
} else if (!a.isOwner && b.isOwner) {
diff --git a/src/logger.js b/src/logger.js
index 823c0599db..ef908c5883 100644
--- a/src/logger.js
+++ b/src/logger.js
@@ -111,7 +111,7 @@ var opts = {
/*
* This monitor's when a user clicks "save" in the Logger section of the admin panel
*/
- Logger.setup_one(data.key,data.value);
+ Logger.setup_one(data.key, data.value);
Logger.io_close(socket);
Logger.io(socket);
};
@@ -127,14 +127,14 @@ var opts = {
opts.express.ofn = morgan('combined', {stream: opts.streams.log.f});
};
- Logger.expressLogger = function (req,res,next) {
+ Logger.expressLogger = function (req, res, next) {
/*
* The new express.logger
*
* This hijack allows us to turn logger on/off dynamically within express
*/
if(meta.config.loggerStatus > 0) {
- return opts.express.ofn(req,res,next);
+ return opts.express.ofn(req, res, next);
} else {
return next();
}
diff --git a/src/messaging.js b/src/messaging.js
index 5078370b98..7e74f0bb3b 100644
--- a/src/messaging.js
+++ b/src/messaging.js
@@ -139,7 +139,7 @@ Messaging.getRecentChats = function (callerUid, uid, start, stop, callback) {
uids = uids.filter(function (value) {
return value && parseInt(value, 10) !== parseInt(uid, 10);
});
- user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'lastonline'] , next);
+ user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'lastonline'], next);
});
}, next);
},
@@ -206,7 +206,7 @@ Messaging.getTeaser = function (uid, roomId, callback) {
}
teaser.timestampISO = utils.toISOString(teaser.timestamp);
- user.getUserFields(teaser.fromuid, ['uid', 'username', 'userslug', 'picture', 'status', 'lastonline'] , next);
+ user.getUserFields(teaser.fromuid, ['uid', 'username', 'userslug', 'picture', 'status', 'lastonline'], next);
},
function (user, next) {
teaser.user = user;
diff --git a/src/privileges/categories.js b/src/privileges/categories.js
index bc95e4b528..3b3649ddf9 100644
--- a/src/privileges/categories.js
+++ b/src/privileges/categories.js
@@ -66,7 +66,7 @@ module.exports = function (privileges) {
memberData.forEach(function (member) {
member.privileges = {};
- for(var x = 0,numPrivs = userPrivileges.length; x < numPrivs; x += 1) {
+ for(var x = 0, numPrivs = userPrivileges.length; x < numPrivs; x += 1) {
member.privileges[userPrivileges[x]] = memberSets[x].indexOf(parseInt(member.uid, 10)) !== -1;
}
});
@@ -117,7 +117,7 @@ module.exports = function (privileges) {
var memberData = groupNames.map(function (member) {
memberPrivs = {};
- for(var x = 0,numPrivs = groupPrivileges.length; x < numPrivs; x += 1) {
+ for(var x = 0, numPrivs = groupPrivileges.length; x < numPrivs; x += 1) {
memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1;
}
return {
diff --git a/src/routes/index.js b/src/routes/index.js
index 80079b5e91..4d3eef927e 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -98,7 +98,7 @@ module.exports = function (app, middleware, hotswapIds) {
var ensureLoggedIn = require('connect-ensure-login');
if (Array.isArray(hotswapIds) && hotswapIds.length) {
- for(var idx,x = 0; x < hotswapIds.length; x += 1) {
+ for(var idx, x = 0; x < hotswapIds.length; x += 1) {
idx = routers.push(express.Router()) - 1;
routers[idx].hotswapId = hotswapIds[x];
}
diff --git a/src/user/notifications.js b/src/user/notifications.js
index 6c8f3a85c3..61dfc50f50 100644
--- a/src/user/notifications.js
+++ b/src/user/notifications.js
@@ -14,7 +14,7 @@ var privileges = require('../privileges');
UserNotifications.get = function (uid, callback) {
if (!parseInt(uid, 10)) {
- return callback(null , {read: [], unread: []});
+ return callback(null, {read: [], unread: []});
}
getNotifications(uid, 0, 9, function (err, notifications) {
if (err) {
diff --git a/test/categories.js b/test/categories.js
index b1553df264..a2b699f7c1 100644
--- a/test/categories.js
+++ b/test/categories.js
@@ -299,7 +299,7 @@ describe('Categories', function () {
});
});
- it('should get category data' , function (done) {
+ it('should get category data', function (done) {
socketCategories.getCategory({uid: posterUid}, categoryObj.cid, function (err, data) {
assert.ifError(err);
assert.equal(categoryObj.cid, data.cid);
diff --git a/test/database/sets.js b/test/database/sets.js
index 7400fea70e..594af8d061 100644
--- a/test/database/sets.js
+++ b/test/database/sets.js
@@ -27,7 +27,7 @@ describe('Set methods', function () {
describe('getSetMembers()', function () {
before(function (done) {
- db.setAdd('testSet2', [1,2,3,4,5], done);
+ db.setAdd('testSet2', [1, 2, 3, 4, 5], done);
});
it('should return an empty set', function (done) {
@@ -139,7 +139,7 @@ describe('Set methods', function () {
describe('setCount()', function () {
before(function (done) {
- db.setAdd('testSet5', [1,2,3,4,5], done);
+ db.setAdd('testSet5', [1, 2, 3, 4, 5], done);
});
it('should return the element count of set', function (done) {
@@ -155,7 +155,7 @@ describe('Set methods', function () {
describe('setsCount()', function () {
before(function (done) {
async.parallel([
- async.apply(db.setAdd, 'set5', [1,2,3,4,5]),
+ async.apply(db.setAdd, 'set5', [1, 2, 3, 4, 5]),
async.apply(db.setAdd, 'set6', 1),
async.apply(db.setAdd, 'set7', 2),
], done);
@@ -211,7 +211,7 @@ describe('Set methods', function () {
describe('setRemoveRandom()', function () {
before(function (done) {
- db.setAdd('testSet7', [1,2,3,4,5], done);
+ db.setAdd('testSet7', [1, 2, 3, 4, 5], done);
});
it('should remove a random element from set', function (done) {
diff --git a/test/database/sorted.js b/test/database/sorted.js
index c38820f7fb..25830671d6 100644
--- a/test/database/sorted.js
+++ b/test/database/sorted.js
@@ -521,8 +521,8 @@ describe('Sorted Set methods', function () {
describe('sortedSetsRemove()', function () {
before(function (done) {
async.parallel([
- async.apply(db.sortedSetAdd, 'sorted4', [1,2], ['value1', 'value2']),
- async.apply(db.sortedSetAdd, 'sorted5', [1,2], ['value1', 'value3']),
+ async.apply(db.sortedSetAdd, 'sorted4', [1, 2], ['value1', 'value2']),
+ async.apply(db.sortedSetAdd, 'sorted5', [1, 2], ['value1', 'value3']),
], done);
});
@@ -541,7 +541,7 @@ describe('Sorted Set methods', function () {
describe('sortedSetsRemoveRangeByScore()', function () {
before(function (done) {
- db.sortedSetAdd('sorted6', [1,2,3,4,5], ['value1','value2','value3','value4','value5'], done);
+ db.sortedSetAdd('sorted6', [1, 2, 3, 4, 5], ['value1', 'value2', 'value3', 'value4', 'value5'], done);
});
it('should remove elements with scores between min max inclusive', function (done) {
@@ -561,10 +561,10 @@ describe('Sorted Set methods', function () {
before(function (done) {
async.parallel([
function (next) {
- db.sortedSetAdd('interSet1', [1,2,3], ['value1', 'value2', 'value3'], next);
+ db.sortedSetAdd('interSet1', [1, 2, 3], ['value1', 'value2', 'value3'], next);
},
function (next) {
- db.sortedSetAdd('interSet2', [4,5,6], ['value2', 'value3', 'value5'], next);
+ db.sortedSetAdd('interSet2', [4, 5, 6], ['value2', 'value3', 'value5'], next);
},
], done);
});
diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js
index 5a87ab69f3..39b88a5c5a 100644
--- a/test/mocks/databasemock.js
+++ b/test/mocks/databasemock.js
@@ -17,7 +17,7 @@
nconf.file({ file: path.join(__dirname, '../../config.json') });
nconf.defaults({
- base_dir: path.join(__dirname,'../..'),
+ base_dir: path.join(__dirname, '../..'),
themes_path: path.join(__dirname, '../../node_modules'),
upload_path: 'public/uploads',
views_dir: path.join(__dirname, '../../build/public/templates'),
diff --git a/test/topics.js b/test/topics.js
index 15db5d1668..77ef54f5b7 100644
--- a/test/topics.js
+++ b/test/topics.js
@@ -473,7 +473,7 @@ describe('Topic\'s', function () {
function (done) {
topics.markUnread(newTid, uid, done);
},
- ],done);
+ ], done);
});
it('should not appear in the unread list', function (done) {
@@ -626,7 +626,7 @@ describe('Topic\'s', function () {
assert.equal(originalBookmark, bookmark);
next();
},
- ],done);
+ ], done);
});
it('should update the user\'s bookmark ', function (done) {
@@ -646,7 +646,7 @@ describe('Topic\'s', function () {
assert.equal(originalBookmark - 2, bookmark);
next();
},
- ],done);
+ ], done);
});
});
diff --git a/test/user.js b/test/user.js
index 958f300113..9db04d8a74 100644
--- a/test/user.js
+++ b/test/user.js
@@ -52,7 +52,7 @@ describe('User', function () {
describe('.create(), when created', function () {
it('should be created properly', function (done) {
- User.create({username: userData.username, password: userData.password, email: userData.email}, function (error,userId) {
+ User.create({username: userData.username, password: userData.password, email: userData.email}, function (error, userId) {
assert.equal(error, null, 'was created with error');
assert.ok(userId);
@@ -62,7 +62,7 @@ describe('User', function () {
});
it('should have a valid email, if using an email', function (done) {
- User.create({username: userData.username, password: userData.password, email: 'fakeMail'},function (err) {
+ User.create({username: userData.username, password: userData.password, email: 'fakeMail'}, function (err) {
assert(err);
assert.equal(err.message, '[[error:invalid-email]]');
done();