ESlint keyword-spacing, no-multi-spaces

This commit is contained in:
Peter Jaszkowiak
2017-02-18 01:52:56 -07:00
parent a5a3f3089a
commit 604358ecc4
116 changed files with 210 additions and 210 deletions

View File

@@ -97,9 +97,9 @@
"consistent-return": "off",
"strict": "off",
// "comma-dangle": "off",
"no-multi-spaces": "off",
// "no-multi-spaces": "off",
"quotes": "off",
"keyword-spacing": "off",
// "keyword-spacing": "off",
// "no-mixed-operators": "off",
// "comma-spacing": "off",
// "no-trailing-spaces": "off",

2
app.js
View File

@@ -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 += '=';
}
}

View File

@@ -138,7 +138,7 @@ function compileLess(callback) {
}
less.render(style.toString(), function (err, css) {
if(err) {
if (err) {
return winston.error('Unable to compile LESS: ', err);
}

View File

@@ -106,7 +106,7 @@ function forkWorker(index, isPrimary) {
var ports = getPorts();
var args = [];
if(!ports[index]) {
if (!ports[index]) {
return console.log('[cluster] invalid port for worker : ' + index + ' ports: ' + ports.length);
}

View File

@@ -33,7 +33,7 @@ Minifier.js.minify = function (scripts, minify, callback) {
};
process.on('message', function (payload) {
switch(payload.action) {
switch (payload.action) {
case 'js':
Minifier.js.minify(payload.scripts, payload.minify, function (minified/* , sourceMap*/) {
process.send({
@@ -56,7 +56,7 @@ function minifyScripts(scripts, callback) {
});
callback(minified.code/* , minified.map*/);
} catch(err) {
} catch (err) {
process.send({
type: 'error',
message: err.message,

View File

@@ -33,7 +33,7 @@
$(document).ready(function () {
setupKeybindings();
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
require(['admin/modules/search'], function (search) {
search.init();
});

View File

@@ -14,7 +14,7 @@ define('admin/advanced/logs', function () {
var btnEl = $(this);
var action = btnEl.attr('data-action');
switch(action) {
switch (action) {
case 'reload':
socket.emit('admin.logs.get', function (err, logs) {
if (!err) {

View File

@@ -64,7 +64,7 @@ define('admin/appearance/themes', ['translator'], function (translator) {
});
socket.emit('admin.themes.getInstalled', function (err, themes) {
if(err) {
if (err) {
return app.alertError(err.message);
}

View File

@@ -93,13 +93,13 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
if (data.hasOwnProperty(d)) {
if (data[d].name) {
if (widgetData[data[d].name]) {
if(!Array.isArray(widgetData[data[d].name])) {
if (!Array.isArray(widgetData[data[d].name])) {
widgetData[data[d].name] = [
widgetData[data[d].name],
];
}
widgetData[data[d].name].push(data[d].value);
}else{
} else {
widgetData[data[d].name] = data[d].value;
}
}
@@ -209,7 +209,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
$.get(RELATIVE_PATH + '/api/admin/extend/widgets', function (data) {
var areas = data.areas;
for(var i = 0; i < areas.length; i += 1) {
for (var i = 0; i < areas.length; i += 1) {
var area = areas[i];
var widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');

View File

@@ -143,12 +143,12 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
var r = (num >> 16) + amt;
if (r > 255) r = 255;
else if (r < 0) r = 0;
else if (r < 0) r = 0;
var b = ((num >> 8) & 0x00FF) + amt;
if (b > 255) b = 255;
else if (b < 0) b = 0;
else if (b < 0) b = 0;
var g = (num & 0x0000FF) + amt;
@@ -291,7 +291,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
$('[data-action="updateGraph"]').on('click', function () {
var until;
switch($(this).attr('data-until')) {
switch ($(this).attr('data-until')) {
case 'last-month':
var lastMonth = new Date();
lastMonth.setDate(lastMonth.getDate() - 30);

View File

@@ -6,7 +6,7 @@ define('admin/general/homepage', ['admin/settings'], function (Settings) {
function toggleCustomRoute() {
if ($('[data-field="homePageRoute"]').val()) {
$('#homePageCustom').hide();
}else{
} else {
$('#homePageCustom').show();
}
}

View File

@@ -8,7 +8,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
Categories.init = function () {
socket.emit('admin.categories.getAll', function (error, payload) {
if(error) {
if (error) {
return app.alertError(error.message);
}
@@ -128,14 +128,14 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
var isCategoryUpdate = (newCategoryId != -1);
// Update needed?
if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) {
if ((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) {
var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid];
var modified = {};
var i = 0;
var list = parentCategory.toArray();
var len = list.length;
for(i; i < len; i += 1) {
for (i; i < len; i += 1) {
modified[list[i]] = {
order: (i + 1),
};
@@ -187,7 +187,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
container.append(html);
// Handle and children categories in this level have
for(var x = 0, numCategories = categories.length; x < numCategories; x += 1) {
for (var x = 0, numCategories = categories.length; x < numCategories; x += 1) {
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
}

View File

@@ -29,7 +29,7 @@ define('admin/manage/category', [
function save(e) {
e.preventDefault();
if(Object.keys(modified_categories).length) {
if (Object.keys(modified_categories).length) {
socket.emit('admin.categories.update', modified_categories, function (err, results) {
if (err) {
return app.alertError(err.message);
@@ -295,7 +295,7 @@ define('admin/manage/category', [
privs.push(el.getAttribute('data-privilege'));
}
});
for(var x = 0, numPrivs = privs.length; x < numPrivs; x += 1) {
for (var x = 0, numPrivs = privs.length; x < numPrivs; x += 1) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
inputs.each(function (idx, el) {
if (!el.checked) {

View File

@@ -147,7 +147,7 @@ define('admin/manage/flags', [
el = $(el);
if (source[pid]) {
for(var prop in source[pid]) {
for (var prop in source[pid]) {
if (source[pid].hasOwnProperty(prop)) {
el.find('[name="' + prop + '"]').val(source[pid][prop]);
}

View File

@@ -113,7 +113,7 @@ define('admin/manage/group', [
var uid = userRow.attr('data-uid');
var action = btnEl.attr('data-action');
switch(action) {
switch (action) {
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,

View File

@@ -63,7 +63,7 @@ define('admin/manage/groups', ['translator'], function (translator) {
socket.emit('groups.delete', {
groupName: groupName,
}, function (err, data) {
if(err) {
if (err) {
return app.alertError(err.message);
}

View File

@@ -301,7 +301,7 @@ define('admin/manage/users', ['translator'], function (translator) {
};
socket.emit('admin.user.createUser', user, function (err) {
if(err) {
if (err) {
return errorEl.translateHtml('[[admin/manage/users:alerts.error-x, ' + err.message + ']]').removeClass('hide');
}
@@ -322,7 +322,7 @@ define('admin/manage/users', ['translator'], function (translator) {
}
var $this = $(this);
var type = $this.attr('data-search-type');
var type = $this.attr('data-search-type');
timeoutId = setTimeout(function () {
$('.fa-spinner').removeClass('hidden');

View File

@@ -182,7 +182,7 @@ define('admin/settings', ['uploader'], function (uploader) {
return callback(err);
}
for(var field in data) {
for (var field in data) {
if (data.hasOwnProperty(field)) {
app.config[field] = data[field];
}

View File

@@ -516,7 +516,7 @@ app.cacheBuster = null;
$('[component="header/usercontrol"] [data-status]').off('click').on('click', function (e) {
var status = $(this).attr('data-status');
socket.emit('user.setStatus', status, function (err) {
if(err) {
if (err) {
return app.alertError(err.message);
}
$('[data-uid="' + app.user.uid + '"] [component="user/status"], [component="header/profilelink"] [component="user/status"]')

View File

@@ -39,7 +39,7 @@ define('forum/categories', ['components', 'translator'], function (components, t
parseAndTranslate([post], function (html) {
html.hide();
if(recentPosts.length === 0) {
if (recentPosts.length === 0) {
html.appendTo(category);
} else {
html.insertBefore(recentPosts.first());

View File

@@ -232,7 +232,7 @@ define('forum/category', [
topic.insertBefore(topics[x]);
break;
}
if(x === numTopics - 1) {
if (x === numTopics - 1) {
topic.insertAfter(topics[x]);
}
}
@@ -253,7 +253,7 @@ define('forum/category', [
function updateTopicCount() {
socket.emit('categories.getTopicCount', ajaxify.data.cid, function (err, topicCount) {
if(err) {
if (err) {
return app.alertError(err.message);
}
navigator.setCount(topicCount);

View File

@@ -180,8 +180,8 @@ define('forum/category/tools', [
}
function isAny(method, tids) {
for(var i = 0; i < tids.length; i += 1) {
if(method(tids[i])) {
for (var i = 0; i < tids.length; i += 1) {
if (method(tids[i])) {
return true;
}
}
@@ -189,8 +189,8 @@ define('forum/category/tools', [
}
function areAll(method, tids) {
for(var i = 0; i < tids.length; i += 1) {
if(!method(tids[i])) {
for (var i = 0; i < tids.length; i += 1) {
if (!method(tids[i])) {
return false;
}
}

View File

@@ -98,7 +98,7 @@ define('forum/chats', [
return;
}
loading = true;
var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1;
var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1;
socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function (err, data) {
if (err) {
return app.alertError(err.message);

View File

@@ -59,7 +59,7 @@ define('forum/groups/details', [
var uid = userRow.attr('data-uid');
var action = btnEl.attr('data-action');
switch(action) {
switch (action) {
case 'toggleOwnership':
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
toUid: uid,

View File

@@ -12,7 +12,7 @@ define('forum/reset', function () {
$('#reset').on('click', function () {
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
socket.emit('user.reset.send', inputEl.val(), function (err) {
if(err) {
if (err) {
return app.alertError(err.message);
}

View File

@@ -20,7 +20,7 @@ define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function (recent,
}
function loadMoreTopics(direction) {
if(direction < 0 || !$('[component="category"]').length) {
if (direction < 0 || !$('[component="category"]').length) {
return;
}

View File

@@ -48,7 +48,7 @@ define('forum/topic/events', [
Events.init = function () {
Events.removeListeners();
for(var eventName in events) {
for (var eventName in events) {
if (events.hasOwnProperty(eventName)) {
socket.on(eventName, events[eventName]);
}
@@ -56,7 +56,7 @@ define('forum/topic/events', [
};
Events.removeListeners = function () {
for(var eventName in events) {
for (var eventName in events) {
if (events.hasOwnProperty(eventName)) {
socket.removeListener(eventName, events[eventName]);
}

View File

@@ -23,11 +23,11 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
$('#markSelectedRead').on('click', function () {
var tids = topicSelect.getSelectedTids();
if(!tids.length) {
if (!tids.length) {
return;
}
socket.emit('topics.markAsRead', tids, function (err) {
if(err) {
if (err) {
return app.alertError(err.message);
}
@@ -37,7 +37,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
$('#markAllRead').on('click', function () {
socket.emit('topics.markAllRead', function (err) {
if(err) {
if (err) {
return app.alertError(err.message);
}
@@ -62,7 +62,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
var tids = getCategoryTids(cid);
socket.emit('topics.markCategoryTopicsRead', cid, function (err) {
if(err) {
if (err) {
return app.alertError(err.message);
}
@@ -85,7 +85,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
}
function loadMoreTopics(direction) {
if(direction < 0 || !$('[component="category"]').length) {
if (direction < 0 || !$('[component="category"]').length) {
return;
}
var params = utils.params();
@@ -118,7 +118,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
}
function removeTids(tids) {
for(var i = 0; i < tids.length; i += 1) {
for (var i = 0; i < tids.length; i += 1) {
components.get('category/topic', 'tid', tids[i]).remove();
}
}

View File

@@ -65,7 +65,7 @@ define('forum/users', ['translator'], function (translator) {
query.onlineOnly = true;
}
if (activeSection === 'banned') {
query.bannedOnly = true;
query.bannedOnly = true;
}
if (activeSection === 'flagged') {
query.flaggedOnly = true;

View File

@@ -30,7 +30,7 @@ define('alerts', ['translator', 'components'], function (translator, components)
components.get('toaster/tray').prepend(alert);
if(typeof params.closefn === 'function') {
if (typeof params.closefn === 'function') {
alert.find('button').on('click', function () {
params.closefn();
fadeOut(alert);
@@ -46,7 +46,7 @@ define('alerts', ['translator', 'components'], function (translator, components)
alert
.addClass('pointer')
.on('click', function (e) {
if(!$(e.target).is('.close')) {
if (!$(e.target).is('.close')) {
params.clickfn();
}
fadeOut(alert);
@@ -82,7 +82,7 @@ define('alerts', ['translator', 'components'], function (translator, components)
alert
.addClass('pointer')
.on('click', function (e) {
if(!$(e.target).is('.close')) {
if (!$(e.target).is('.close')) {
params.clickfn();
}
fadeOut(alert);

View File

@@ -170,7 +170,7 @@
helpers.spawnPrivilegeStates = function (member, privileges) {
var states = [];
for(var priv in privileges) {
for (var priv in privileges) {
if (privileges.hasOwnProperty(priv)) {
states.push({
name: priv,
@@ -214,7 +214,7 @@
helpers.userAgentIcons = function (data) {
var icons = '';
switch(data.platform) {
switch (data.platform) {
case 'Linux':
icons += '<i class="fa fa-fw fa-linux"></i>';
break;
@@ -239,7 +239,7 @@
break;
}
switch(data.browser) {
switch (data.browser) {
case 'Chrome':
icons += '<i class="fa fa-fw fa-chrome"></i>';
break;

View File

@@ -125,7 +125,7 @@ define('notifications', ['sounds', 'translator', 'components'], function (sound,
});
translator.toggleTimeagoShorthand();
for(var i = 0; i < notifs.length; i += 1) {
for (var i = 0; i < notifs.length; i += 1) {
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
}
translator.toggleTimeagoShorthand();

View File

@@ -114,8 +114,8 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe
return showAlert('error', '[[uploads:select-file-to-upload]]');
}
var file = fileInput[0].files[0];
var reader = new FileReader();
var file = fileInput[0].files[0];
var reader = new FileReader();
var imageUrl;
var imageType = file.type;

View File

@@ -24,7 +24,7 @@ define('postSelect', ['components'], function (components) {
if (newPid) {
var index = PostSelect.pids.indexOf(newPid);
if(index === -1) {
if (index === -1) {
PostSelect.pids.push(newPid);
post.toggleClass('bg-success', true);
} else {

View File

@@ -18,7 +18,7 @@ define('search', ['navigator', 'translator'], function (nav, translator) {
try {
term = encodeURIComponent(term);
} catch(e) {
} catch (e) {
return app.alertError('[[error:invalid-search-term]]');
}
@@ -81,7 +81,7 @@ define('search', ['navigator', 'translator'], function (nav, translator) {
Search.getSearchPreferences = function () {
try {
return JSON.parse(localStorage.getItem('search-preferences') || '{}');
} catch(e) {
} catch (e) {
return {};
}
};

View File

@@ -459,7 +459,7 @@ define('settings', function () {
}
// Parse all values. If they are json, return json
for(var key in values) {
for (var key in values) {
if (values.hasOwnProperty(key)) {
try {
values[key] = JSON.parse(values[key]);

View File

@@ -52,7 +52,7 @@ define('topicSelect', ['components'], function (components) {
function selectRange(clickedTid) {
if(!lastSelected) {
if (!lastSelected) {
lastSelected = $('[component="category/topic"]').first().find('[component="topic/select"]');
}
@@ -70,7 +70,7 @@ define('topicSelect', ['components'], function (components) {
end = tmp;
}
for(var i = start; i <= end; i += 1) {
for (var i = start; i <= end; i += 1) {
var topic = $('[component="category/topic"]').eq(i);
toggleSelect(topic.find('[component="topic/select"]'), isSelected);
}

View File

@@ -10,9 +10,9 @@ if ('undefined' !== typeof window) {
$.fn.getCursorPosition = function () {
var el = $(this).get(0);
var pos = 0;
if('selectionStart' in el) {
if ('selectionStart' in el) {
pos = el.selectionStart;
} else if('selection' in document) {
} else if ('selection' in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
@@ -23,7 +23,7 @@ if ('undefined' !== typeof window) {
};
$.fn.selectRange = function (start, end) {
if(!end) {
if (!end) {
end = start;
}
return this.each(function () {
@@ -95,7 +95,7 @@ if ('undefined' !== typeof window) {
return el.namespace === 'bs.data-api.dropdown' && el.selector === undefined;
});
if(_clearMenus.length) {
if (_clearMenus.length) {
_clearMenus = _clearMenus[0].handler;
}

View File

@@ -71,7 +71,7 @@ app.isConnected = false;
var url_parts = window.location.pathname.slice(config.relative_path.length).split('/').slice(1);
var room;
switch(url_parts[0]) {
switch (url_parts[0]) {
case 'user':
room = 'user/' + (ajaxify.data ? ajaxify.data.theirid : 0);
break;

View File

@@ -91,7 +91,7 @@
return '';
}
str = str.replace(utils.trimRegex, '');
if(utils.isLatin.test(str)) {
if (utils.isLatin.test(str)) {
str = str.replace(utils.invalidLatinChars, '-');
} else {
str = XRegExp.replace(str, utils.invalidUnicodeChars, '-');
@@ -211,12 +211,12 @@
makeNumberHumanReadable: function (num) {
var n = parseInt(num, 10);
if(!n) {
if (!n) {
return num;
}
if (n > 999999) {
return (n / 1000000).toFixed(1) + 'm';
} else if(n > 999) {
} else if (n > 999) {
return (n / 1000).toFixed(1) + 'k';
}
return n;
@@ -314,7 +314,7 @@
var labels = [];
var tmpDate;
for(var x = 29; x >= 0; x -= 1) {
for (var x = 29; x >= 0; x -= 1) {
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate());
}
@@ -417,15 +417,15 @@
// get example: utils.props(A, 'a.b.c.foo.bar') // returns undefined without throwing a TypeError
// credits to github.com/gkindel
props: function (obj, props, value) {
if(obj === undefined) {
if (obj === undefined) {
obj = window;
}
if(props == null) {
if (props == null) {
return undefined;
}
var i = props.indexOf('.');
if(i == -1) {
if(value !== undefined) {
if (i == -1) {
if (value !== undefined) {
obj[props] = value;
}
return obj[props];
@@ -433,7 +433,7 @@
var prop = props.slice(0, i);
var newProps = props.slice(i + 1);
if(props !== undefined && !(obj[prop] instanceof Object)) {
if (props !== undefined && !(obj[prop] instanceof Object)) {
obj[prop] = {};
}

View File

@@ -86,7 +86,7 @@ Analytics.writeData = function (callback) {
}
if (Object.keys(counters).length > 0) {
for(var key in counters) {
for (var key in counters) {
if (counters.hasOwnProperty(key)) {
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:' + key, counters[key], today.getTime()));
delete counters[key];

View File

@@ -28,7 +28,7 @@ groupsController.list = function (req, res, next) {
pageCount = Math.ceil(groupNames.length / groupsPerPage);
var start = (page - 1) * groupsPerPage;
var stop = start + groupsPerPage - 1;
var stop = start + groupsPerPage - 1;
groupNames = groupNames.slice(start, stop + 1);
groups.getGroupsData(groupNames, next);

View File

@@ -79,7 +79,7 @@ function getNodeInfo(callback) {
}
function getGitInfo(callback) {
function get(cmd, callback) {
function get(cmd, callback) {
exec(cmd, function (err, stdout) {
if (err) {
winston.error(err);

View File

@@ -29,7 +29,7 @@ uploadsController.uploadCategoryPicture = function (req, res, next) {
}
if (validateUpload(req, res, next, uploadedFile, allowedImageTypes)) {
var filename = 'category-' + params.cid + path.extname(uploadedFile.name);
var filename = 'category-' + params.cid + path.extname(uploadedFile.name);
uploadImage(filename, 'category', uploadedFile, req, res, next);
}
};

View File

@@ -8,7 +8,7 @@ var validator = require('validator');
var user = require('../user');
var topics = require('../topics');
var pagination = require('../pagination');
var helpers = require('./helpers');
var helpers = require('./helpers');
var tagsController = {};

View File

@@ -149,7 +149,7 @@ topicsController.get = function (req, res, callback) {
},
function (topicData, next) {
function findPost(index) {
for(var i = 0; i < topicData.posts.length; i += 1) {
for (var i = 0; i < topicData.posts.length; i += 1) {
if (parseInt(topicData.posts[i].index, 10) === parseInt(index, 10)) {
return topicData.posts[i];
}

View File

@@ -78,7 +78,7 @@ module.exports = function (db, module) {
_id: 0,
};
for(var i = 0; i < fields.length; i += 1) {
for (var i = 0; i < fields.length; i += 1) {
fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1;
}
@@ -88,7 +88,7 @@ module.exports = function (db, module) {
}
item = item || {};
var result = {};
for(i = 0; i < fields.length; i += 1) {
for (i = 0; i < fields.length; i += 1) {
result[fields[i]] = item[fields[i]] !== undefined ? item[fields[i]] : null;
}
callback(null, result);
@@ -104,7 +104,7 @@ module.exports = function (db, module) {
_key: 1,
};
for(var i = 0; i < fields.length; i += 1) {
for (var i = 0; i < fields.length; i += 1) {
fields[i] = helpers.fieldToString(fields[i]);
_fields[fields[i]] = 1;
}
@@ -145,12 +145,12 @@ module.exports = function (db, module) {
module.getObjectValues = function (key, callback) {
module.getObject(key, function (err, data) {
if(err) {
if (err) {
return callback(err);
}
var values = [];
for(var key in data) {
for (var key in data) {
if (data && data.hasOwnProperty(key)) {
values.push(data[key]);
}

View File

@@ -12,11 +12,11 @@ helpers.toMap = function (data) {
};
helpers.fieldToString = function (field) {
if(field === null || field === undefined) {
if (field === null || field === undefined) {
return field;
}
if(typeof field !== 'string') {
if (typeof field !== 'string') {
field = field.toString();
}
// if there is a '.' in the field name it inserts subdocument in mongo, replace '.'s with \uff0E
@@ -25,7 +25,7 @@ helpers.fieldToString = function (field) {
};
helpers.valueToString = function (value) {
if(value === null || value === undefined) {
if (value === null || value === undefined) {
return value;
}

View File

@@ -55,7 +55,7 @@ module.exports = function (db, module) {
};
module.listRemoveAll = function (key, value, callback) {
callback = callback || helpers.noop;
callback = callback || helpers.noop;
if (!key) {
return callback();
}
@@ -88,7 +88,7 @@ module.exports = function (db, module) {
}
db.collection('objects').findOne({_key: key}, { array: 1}, function (err, data) {
if(err || !(data && data.array)) {
if (err || !(data && data.array)) {
return callback(err, []);
}

View File

@@ -5,7 +5,7 @@ module.exports = function (db, module) {
module.setAdd = function (key, value, callback) {
callback = callback || helpers.noop;
if(!Array.isArray(value)) {
if (!Array.isArray(value)) {
value = [value];
}
@@ -36,7 +36,7 @@ module.exports = function (db, module) {
return callback();
}
if(!Array.isArray(value)) {
if (!Array.isArray(value)) {
value = [value];
}
@@ -46,7 +46,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i]}).upsert().updateOne({ $addToSet: {
members: {
$each: value,
@@ -61,7 +61,7 @@ module.exports = function (db, module) {
module.setRemove = function (key, value, callback) {
callback = callback || helpers.noop;
if(!Array.isArray(value)) {
if (!Array.isArray(value)) {
value = [value];
}
@@ -83,7 +83,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i]}).updateOne({$pull: {
members: value,
}});
@@ -174,7 +174,7 @@ module.exports = function (db, module) {
});
var returnData = new Array(keys.length);
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
returnData[i] = sets[keys[i]] || [];
}
callback(null, returnData);
@@ -206,7 +206,7 @@ module.exports = function (db, module) {
module.setRemoveRandom = function (key, callback) {
callback = callback || function () {};
db.collection('objects').findOne({_key: key}, function (err, data) {
if(err || !data) {
if (err || !data) {
return callback(err);
}

View File

@@ -198,7 +198,7 @@ module.exports = function (db, module) {
}
value = helpers.valueToString(value);
method(key, 0, -1, function (err, result) {
if(err) {
if (err) {
return callback(err);
}
@@ -263,7 +263,7 @@ module.exports = function (db, module) {
var returnData = [];
var item;
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
item = map[keys[i]];
returnData.push(item ? item.score : null);
}
@@ -290,7 +290,7 @@ module.exports = function (db, module) {
var returnData = new Array(values.length);
var score;
for(var i = 0; i < values.length; i += 1) {
for (var i = 0; i < values.length; i += 1) {
score = map[values[i]];
returnData[i] = utils.isNumber(score) ? score : null;
}
@@ -367,7 +367,7 @@ module.exports = function (db, module) {
});
var returnData = new Array(keys.length);
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
returnData[i] = sets[keys[i]] || [];
}
callback(null, returnData);

View File

@@ -35,7 +35,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < scores.length; i += 1) {
for (var i = 0; i < scores.length; i += 1) {
bulk.find({_key: key, value: values[i]}).upsert().updateOne({$set: {score: parseFloat(scores[i])}});
}
@@ -53,7 +53,7 @@ module.exports = function (db, module) {
var bulk = db.collection('objects').initializeUnorderedBulkOp();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
bulk.find({_key: keys[i], value: value}).upsert().updateOne({$set: {score: parseFloat(score)}});
}

View File

@@ -11,7 +11,7 @@ module.exports = function (db, module) {
{ $match: { _key: {$in: keys}} },
{ $group: { _id: {value: '$value'}, count: {$sum: 1}} },
{ $match: { count: keys.length} },
{ $group: { _id: null, count: { $sum: 1 } } },
{ $group: { _id: null, count: { $sum: 1 } } },
];
db.collection('objects').aggregate(pipeline, function (err, data) {

View File

@@ -10,7 +10,7 @@ module.exports = function (db, module) {
var pipeline = [
{ $match: { _key: {$in: keys} } },
{ $group: { _id: {value: '$value' } } },
{ $group: { _id: null, count: { $sum: 1 } } },
{ $group: { _id: null, count: { $sum: 1 } } },
];
var project = { _id: 0, count: '$count' };

View File

@@ -52,7 +52,7 @@ module.exports = function (redisClient, module) {
}
var multi = redisClient.multi();
for(var x = 0; x < keys.length; x += 1) {
for (var x = 0; x < keys.length; x += 1) {
multi.hmget.apply(multi, [keys[x]].concat(fields));
}

View File

@@ -30,7 +30,7 @@ module.exports = function (redisClient, module) {
module.deleteAll = function (keys, callback) {
callback = callback || function () {};
var multi = redisClient.multi();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
multi.del(keys[i]);
}
multi.exec(function (err, res) {

View File

@@ -45,7 +45,7 @@ module.exports = function (redisClient, module) {
return callback(null, data);
}
var objects = [];
for(var i = 0; i < data.length; i += 2) {
for (var i = 0; i < data.length; i += 2) {
objects.push({value: data[i], score: parseFloat(data[i + 1])});
}
callback(null, objects);
@@ -74,7 +74,7 @@ module.exports = function (redisClient, module) {
return callback(err);
}
var objects = [];
for(var i = 0; i < data.length; i += 2) {
for (var i = 0; i < data.length; i += 2) {
objects.push({value: data[i], score: parseFloat(data[i + 1])});
}
callback(null, objects);
@@ -94,7 +94,7 @@ module.exports = function (redisClient, module) {
return callback(null, []);
}
var multi = redisClient.multi();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
multi.zcard(keys[i]);
}
multi.exec(callback);
@@ -106,7 +106,7 @@ module.exports = function (redisClient, module) {
module.sortedSetsRanks = function (keys, values, callback) {
var multi = redisClient.multi();
for(var i = 0; i < values.length; i += 1) {
for (var i = 0; i < values.length; i += 1) {
multi.zrank(keys[i], values[i]);
}
multi.exec(callback);
@@ -114,7 +114,7 @@ module.exports = function (redisClient, module) {
module.sortedSetRanks = function (key, values, callback) {
var multi = redisClient.multi();
for(var i = 0; i < values.length; i += 1) {
for (var i = 0; i < values.length; i += 1) {
multi.zrank(key, values[i]);
}
multi.exec(callback);

View File

@@ -23,7 +23,7 @@ module.exports = function (redisClient, module) {
var args = [key];
for(var i = 0; i < scores.length; i += 1) {
for (var i = 0; i < scores.length; i += 1) {
args.push(scores[i], values[i]);
}
@@ -36,7 +36,7 @@ module.exports = function (redisClient, module) {
callback = callback || function () {};
var multi = redisClient.multi();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
multi.zadd(keys[i], score, value);
}

View File

@@ -70,7 +70,7 @@ module.exports = function (redisClient, module) {
}
results = results[1] || [];
var objects = [];
for(var i = 0; i < results.length; i += 2) {
for (var i = 0; i < results.length; i += 2) {
objects.push({value: results[i], score: parseFloat(results[i + 1])});
}
callback(null, objects);

View File

@@ -28,7 +28,7 @@ module.exports = function (redisClient, module) {
module.sortedSetsRemoveRangeByScore = function (keys, min, max, callback) {
callback = callback || function () {};
var multi = redisClient.multi();
for(var i = 0; i < keys.length; i += 1) {
for (var i = 0; i < keys.length; i += 1) {
multi.zremrangebyscore(keys[i], min, max);
}
multi.exec(function (err) {

View File

@@ -51,7 +51,7 @@ module.exports = function (redisClient, module) {
}
results = results[1] || [];
var objects = [];
for(var i = 0; i < results.length; i += 2) {
for (var i = 0; i < results.length; i += 2) {
objects.push({value: results[i], score: parseFloat(results[i + 1])});
}
callback(null, objects);

View File

@@ -4,7 +4,7 @@
var async = require('async');
var validator = require('validator');
var db = require('./database');
var db = require('./database');
var batch = require('./batch');
var user = require('./user');
var utils = require('../public/src/utils');

View File

@@ -100,7 +100,7 @@ file.existsSync = function (path) {
var exists = false;
try {
exists = fs.statSync(path);
} catch(err) {
} catch (err) {
exists = false;
}

View File

@@ -38,7 +38,7 @@ module.exports = function (Groups) {
};
Groups.sort = function (strategy, groups, next) {
switch(strategy) {
switch (strategy) {
case 'count':
groups = groups.sort(function (a, b) {
return a.slug > b.slug;
@@ -77,7 +77,7 @@ module.exports = function (Groups) {
},
function (users, next) {
var uids = [];
for(var i = 0; i < users.length; i += 1) {
for (var i = 0; i < users.length; i += 1) {
var field = users[i][searchBy];
if (field.toLowerCase().startsWith(query)) {
uids.push(users[i].uid);

View File

@@ -131,7 +131,7 @@ module.exports = function (Groups) {
},
function (currentValue, next) {
var currentlyPrivate = parseInt(currentValue.private, 10) === 1;
if (!currentlyPrivate || currentlyPrivate === isPrivate) {
if (!currentlyPrivate || currentlyPrivate === isPrivate) {
return callback();
}
db.getSetMembers('group:' + groupName + ':pending', next);

View File

@@ -10,7 +10,7 @@ HotSwap.prepare = function (app) {
HotSwap.find = function (id) {
if (stack) {
for(var x = 0, numEntries = stack.length; x < numEntries; x += 1) {
for (var x = 0, numEntries = stack.length; x < numEntries; x += 1) {
if (stack[x].handle.hotswapId === id) {
return x;
}

View File

@@ -153,7 +153,7 @@ function completeConfigSetup(config, next) {
// Add CI object
if (install.ciVals) {
config.test_database = {};
for(var prop in install.ciVals) {
for (var prop in install.ciVals) {
if (install.ciVals.hasOwnProperty(prop)) {
config.test_database[prop] = install.ciVals[prop];
}

View File

@@ -59,9 +59,9 @@ var opts = {
* If logging is currently enabled, create a stream.
* Otherwise, close the current stream
*/
if(meta.config.loggerStatus > 0 || meta.config.loggerIOStatus) {
if (meta.config.loggerStatus > 0 || meta.config.loggerIOStatus) {
var stream = Logger.open(value);
if(stream) {
if (stream) {
opts.streams.log.f = stream;
} else {
opts.streams.log.f = process.stdout;
@@ -74,11 +74,11 @@ var opts = {
Logger.open = function (value) {
/* Open the streams to log to: either a path or stdout */
var stream;
if(value) {
if(file.existsSync(value)) {
if (value) {
if (file.existsSync(value)) {
var stats = fs.statSync(value);
if(stats) {
if(stats.isDirectory()) {
if (stats) {
if (stats.isDirectory()) {
stream = fs.createWriteStream(path.join(value, 'nodebb.log'), {flags: 'a'});
} else {
stream = fs.createWriteStream(value, {flags: 'a'});
@@ -89,7 +89,7 @@ var opts = {
}
if(stream) {
if (stream) {
stream.on('error', function (err) {
winston.error(err.message);
});
@@ -101,7 +101,7 @@ var opts = {
};
Logger.close = function (stream) {
if(stream.f !== process.stdout && stream.f) {
if (stream.f !== process.stdout && stream.f) {
stream.end();
}
stream.f = null;
@@ -117,7 +117,7 @@ var opts = {
};
Logger.express_open = function () {
if(opts.express.set !== 1) {
if (opts.express.set !== 1) {
opts.express.set = 1;
opts.express.app.use(Logger.expressLogger);
}
@@ -133,7 +133,7 @@ var opts = {
*
* This hijack allows us to turn logger on/off dynamically within express
*/
if(meta.config.loggerStatus > 0) {
if (meta.config.loggerStatus > 0) {
return opts.express.ofn(req, res, next);
} else {
return next();
@@ -148,7 +148,7 @@ var opts = {
*/
try {
return 'io: ' + _uid + ' ' + _type + ' ' + util.inspect(Array.prototype.slice.call(_args)) + '\n';
} catch(err) {
} catch (err) {
winston.info("Logger.prepare_io_string: Failed", err);
return "error";
}
@@ -165,11 +165,11 @@ var opts = {
for (var sid in clients) {
if (clients.hasOwnProperty(sid)) {
var client = clients[sid];
if(client.oEmit && client.oEmit !== client.emit) {
if (client.oEmit && client.oEmit !== client.emit) {
client.emit = client.oEmit;
}
if(client.$oEmit && client.$oEmit !== client.$emit) {
if (client.$oEmit && client.$oEmit !== client.$emit) {
client.$emit = client.$oEmit;
}
}
@@ -186,7 +186,7 @@ var opts = {
}
var clients = socket.io.sockets.sockets;
for(var sid in clients) {
for (var sid in clients) {
if (clients.hasOwnProperty(sid)) {
Logger.io_one(clients[sid], clients[sid].uid);
}
@@ -199,13 +199,13 @@ var opts = {
*/
function override(method, name, errorMsg) {
return function () {
if(opts.streams.log.f) {
if (opts.streams.log.f) {
opts.streams.log.f.write(Logger.prepare_io_string(name, uid, arguments));
}
try {
method.apply(socket, arguments);
} catch(err) {
} catch (err) {
winston.info(errorMsg, err);
}
};

View File

@@ -83,7 +83,7 @@ exports.buildTargets = function (targets, callback) {
function (next) {
async.eachSeries(targets, function (target, next) {
var startTime;
switch(target) {
switch (target) {
case 'js':
setImmediate(next);
break;

View File

@@ -31,7 +31,7 @@ module.exports = function (Meta) {
try {
pkgData = JSON.parse(pkgData);
} catch(e) {
} catch (e) {
process.stdout.write('[' + 'missing'.red + '] ' + module.bold + ' is a required dependency but could not be found\n');
depsMissing = true;
return next(true);

View File

@@ -150,7 +150,7 @@ module.exports = function (Meta) {
});
minifier.on('message', function (message) {
switch(message.type) {
switch (message.type) {
case 'end':
Meta.js.target[target].cache = message.minified;
Meta.js.target[target].map = message.sourceMap;
@@ -226,7 +226,7 @@ module.exports = function (Meta) {
* Check if the parent process is running with the debug option --debug (or --debug-brk)
*/
var forkProcessParams = {};
if(global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
/**
* use the line below if you want to debug minifier.js script too (or even --debug-brk option, but
* you'll have to setup your debugger and connect to the forked process)

View File

@@ -120,7 +120,7 @@ function compile(callback) {
var matches = null;
var regex = /[ \t]*<!-- IMPORT ([\s\S]*?)? -->[ \t]*/;
while((matches = file.match(regex)) !== null) {
while ((matches = file.match(regex)) !== null) {
var partial = "/" + matches[1];
if (paths[partial] && relativePath !== partial) {

View File

@@ -78,7 +78,7 @@ module.exports = function (Meta) {
'theme:src': '',
};
switch(data.type) {
switch (data.type) {
case 'local':
async.waterfall([
async.apply(Meta.configs.get, 'theme:id'),

View File

@@ -190,7 +190,7 @@ middleware.processTimeagoLocales = function (req, res, next) {
try {
exists = fs.accessSync(localPath, fs.F_OK | fs.R_OK);
} catch(e) {
} catch (e) {
exists = false;
}

View File

@@ -1,7 +1,7 @@
'use strict';
var async = require('async');
var nconf = require('nconf');
var nconf = require('nconf');
var meta = require('../meta');
var user = require('../user');

View File

@@ -460,7 +460,7 @@ var utils = require('../public/src/utils');
return notifications;
}
switch(mergeId) {
switch (mergeId) {
// intentional fall-through
case 'notifications:upvoted_your_post_in':
case 'notifications:user_started_following_you':

View File

@@ -26,7 +26,7 @@ pagination.create = function (currentPage, pageCount, queryObj) {
if (startPage > pageCount - 5) {
startPage -= 2 - (pageCount - currentPage);
}
for(var i = 0; i < 5; i += 1) {
for (var i = 0; i < 5; i += 1) {
pagesToShow.push(startPage + i);
}

View File

@@ -13,7 +13,7 @@
function forkChild(message, callback) {
var forkProcessParams = {};
if(global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
forkProcessParams = {execArgv: ['--debug=' + (5859), '--nolazy']};
}
var child = fork('./bcrypt', [], forkProcessParams);

View File

@@ -107,7 +107,7 @@ var middleware;
if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') {
process.stdout.write('\n');
winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.');
for(var x = 0, numPlugins = Plugins.versionWarning.length; x < numPlugins; x += 1) {
for (var x = 0, numPlugins = Plugins.versionWarning.length; x < numPlugins; x += 1) {
process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n');
}
process.stdout.write('\n');
@@ -252,7 +252,7 @@ var middleware;
var pluginMap = {};
var dependencies = require(path.join(nconf.get('base_dir'), 'package.json')).dependencies;
apiReturn = apiReturn || [];
for(var i = 0; i < apiReturn.length; i += 1) {
for (var i = 0; i < apiReturn.length; i += 1) {
apiReturn[i].id = apiReturn[i].name;
apiReturn[i].installed = false;
apiReturn[i].active = false;

View File

@@ -160,7 +160,7 @@ module.exports = function (Plugins) {
next.apply(null, arguments);
}
});
} catch(err) {
} catch (err) {
winston.error('[plugins] Error executing \'' + hook + '\' in plugin \'' + hookObj.id + '\'');
winston.error(err);
clearTimeout(timeoutId);

View File

@@ -140,7 +140,7 @@ module.exports = function (Plugins) {
} else {
callback();
}
} catch(err) {
} catch (err) {
winston.error(err.stack);
winston.warn('[plugins] Unable to parse library for: ' + pluginData.id);
callback();
@@ -301,7 +301,7 @@ module.exports = function (Plugins) {
pluginData.repository = packageData.repository;
pluginData.nbbpm = packageData.nbbpm;
pluginData.path = pluginPath;
} catch(err) {
} catch (err) {
var pluginDir = pluginPath.split(path.sep);
pluginDir = pluginDir[pluginDir.length - 1];

View File

@@ -240,14 +240,14 @@ module.exports = function (Posts) {
function (posts, next) {
// Parse out flag data into its own object inside each post hash
async.map(posts, function (postObj, next) {
for(var prop in postObj) {
for (var prop in postObj) {
postObj.flagData = postObj.flagData || {};
if (postObj.hasOwnProperty(prop) && prop.startsWith('flag:')) {
postObj.flagData[prop.slice(5)] = postObj[prop];
if (prop === 'flag:state') {
switch(postObj[prop]) {
switch (postObj[prop]) {
case 'open':
postObj.flagData.labelClass = 'info';
break;
@@ -296,14 +296,14 @@ module.exports = function (Posts) {
}
// Track new additions
for(prop in flagObj) {
for (prop in flagObj) {
if (flagObj.hasOwnProperty(prop) && !postData.hasOwnProperty('flag:' + prop) && flagObj[prop].length) {
changes.push(prop);
}
}
// Track changed items
for(prop in postData) {
for (prop in postData) {
if (
postData.hasOwnProperty(prop) && prop.startsWith('flag:') &&
flagObj.hasOwnProperty(prop.slice(5)) &&
@@ -324,7 +324,7 @@ module.exports = function (Posts) {
var history = JSON.parse(postData['flag:history'] || '[]');
changes.forEach(function (property) {
switch(property) {
switch (property) {
case 'assignee': // intentional fall-through
case 'state':
history.unshift({

View File

@@ -68,7 +68,7 @@ module.exports = function (Posts) {
content = content.slice(0, current.index + 6) + absolute + content.slice(current.index + 6 + current[1].length);
}
} catch(err) {
} catch (err) {
winston.verbose(err.messsage);
}
}

View File

@@ -136,7 +136,7 @@ module.exports = function (Posts) {
function toObject(key, data) {
var obj = {};
for(var i = 0; i < data.length; i += 1) {
for (var i = 0; i < data.length; i += 1) {
obj[data[i][key]] = data[i];
}
return obj;

View File

@@ -30,7 +30,7 @@ module.exports = function (Posts) {
function (deleted, next) {
if (parseInt(deleted, 10) === 1 && isDelete) {
return next(new Error('[[error:post-already-deleted]]'));
} else if(parseInt(deleted, 10) !== 1 && !isDelete) {
} else if (parseInt(deleted, 10) !== 1 && !isDelete) {
return next(new Error('[[error:post-already-restored]]'));
}

View File

@@ -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 {

View File

@@ -107,7 +107,7 @@ helpers.isUsersAllowedTo = function (privilege, uids, cid, callback) {
}
var result = [];
for(var i = 0; i < uids.length; i += 1) {
for (var i = 0; i < uids.length; i += 1) {
result.push(results.hasUserPrivilege[i] || results.hasGroupPrivilege[i]);
}

View File

@@ -26,7 +26,7 @@ var PubSub = function () {
try {
var msg = JSON.parse(message);
self.emit(msg.event, msg.data);
} catch(err) {
} catch (err) {
winston.error(err.stack);
}
});

View File

@@ -4,7 +4,7 @@ var express = require('express');
var uploadsController = require('../controllers/uploads');
module.exports = function (app, middleware, controllers) {
module.exports = function (app, middleware, controllers) {
var router = express.Router();
app.use('/api', router);

View File

@@ -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];
}
@@ -132,7 +132,7 @@ module.exports = function (app, middleware, hotswapIds) {
userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers);
for(var x = 0; x < routers.length; x += 1) {
for (var x = 0; x < routers.length; x += 1) {
app.use(relativePath, routers[x]);
}

View File

@@ -38,7 +38,7 @@ sitemap.render = function (callback) {
numPages = Math.ceil(tids.length / numTopics);
}
for(var x = 1; x <= numPages; x += 1) {
for (var x = 1; x <= numPages; x += 1) {
returnData.topics.push(x);
}

View File

@@ -13,7 +13,7 @@ var plugins = require('../../plugins');
var User = {};
User.makeAdmins = function (socket, uids, callback) {
if(!Array.isArray(uids)) {
if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));
}
@@ -22,7 +22,7 @@ User.makeAdmins = function (socket, uids, callback) {
return callback(err);
}
for(var i = 0; i < userData.length; i += 1) {
for (var i = 0; i < userData.length; i += 1) {
if (userData[i] && parseInt(userData[i].banned, 10) === 1) {
return callback(new Error('[[error:cant-make-banned-users-admin]]'));
}
@@ -35,7 +35,7 @@ User.makeAdmins = function (socket, uids, callback) {
};
User.removeAdmins = function (socket, uids, callback) {
if(!Array.isArray(uids)) {
if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));
}

View File

@@ -44,7 +44,7 @@ SocketCategories.getWatchedCategories = function (socket, data, callback) {
if (err) {
return callback(err);
}
var watchedCategories = results.categories.filter(function (category) {
var watchedCategories = results.categories.filter(function (category) {
return category && results.ignoredCids.indexOf(category.cid.toString()) === -1;
});

View File

@@ -241,7 +241,7 @@ SocketGroups.search = function (socket, data, callback) {
};
SocketGroups.loadMore = function (socket, data, callback) {
if (!data.sort || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) {
if (!data.sort || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) {
return callback();
}

View File

@@ -62,7 +62,7 @@ module.exports = function (SocketPosts) {
return callback(err, []);
}
async.map(data, function (uids, next) {
async.map(data, function (uids, next) {
var otherCount = 0;
if (uids.length > 6) {
otherCount = uids.length - 5;

View File

@@ -11,7 +11,7 @@ var social = require('../../social');
module.exports = function (SocketTopics) {
SocketTopics.loadMore = function (socket, data, callback) {
if (!data || !data.tid || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) {
if (!data || !data.tid || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) {
return callback(new Error('[[error:invalid-data]]'));
}
var userPrivileges;

View File

@@ -26,7 +26,7 @@ module.exports = function (SocketUser) {
user.isAdminOrGlobalModOrSelf(socket.uid, data.uid, next);
},
function (next) {
switch(type) {
switch (type) {
case 'default':
next(null, '');
break;

View File

@@ -56,7 +56,7 @@ start.start = function () {
},
], function (err) {
if (err) {
switch(err.message) {
switch (err.message) {
case 'schema-out-of-date':
winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
winston.warn(' ./nodebb upgrade');

View File

@@ -69,7 +69,7 @@ module.exports = function (Topics) {
userData: function (next) {
var uids = [];
for(var i = 0; i < postData.length; i += 1) {
for (var i = 0; i < postData.length; i += 1) {
if (postData[i] && uids.indexOf(postData[i].uid) === -1) {
uids.push(postData[i].uid);
}
@@ -90,7 +90,7 @@ module.exports = function (Topics) {
},
editors: function (next) {
var editors = [];
for(var i = 0; i < postData.length; i += 1) {
for (var i = 0; i < postData.length; i += 1) {
if (postData[i] && postData[i].editor && editors.indexOf(postData[i].editor) === -1) {
editors.push(postData[i].editor);
}

View File

@@ -7,7 +7,7 @@ var db = require('../database');
var plugins = require('../plugins');
var privileges = require('../privileges');
var user = require('../user');
var categories = require('../categories');
var categories = require('../categories');
module.exports = function (Topics) {
var terms = {

Some files were not shown because too many files have changed in this diff Show More