Fix eslint rules (#5117)

* Fix semi linter rule

* Fix semi-spacing linter rule

* Fix no-undef-init linter rule

* Fix space-before-blocks linter rule
v1.18.x
Sergii Paryzhskyi 9 years ago committed by Julian Lam
parent 727710fbd9
commit e515b791da

@ -48,7 +48,6 @@
"no-extend-native": "off", "no-extend-native": "off",
"no-shadow-restricted-names": "off", "no-shadow-restricted-names": "off",
"no-extra-boolean-cast": "off", "no-extra-boolean-cast": "off",
"no-undef-init": "off",
"no-script-url": "off", "no-script-url": "off",
"no-path-concat": "off", "no-path-concat": "off",
"no-unused-expressions": "off", "no-unused-expressions": "off",
@ -66,7 +65,6 @@
"padded-blocks": "off", "padded-blocks": "off",
"eol-last": "off", "eol-last": "off",
"lines-around-directive": "off", "lines-around-directive": "off",
"space-before-blocks": "off",
"no-restricted-syntax": "off", "no-restricted-syntax": "off",
"vars-on-top": "off", "vars-on-top": "off",
"no-prototype-builtins": "off", "no-prototype-builtins": "off",
@ -80,7 +78,6 @@
"keyword-spacing": "off", "keyword-spacing": "off",
"no-plusplus": "off", "no-plusplus": "off",
"no-mixed-operators": "off", "no-mixed-operators": "off",
"semi": "off",
"comma-spacing": "off", "comma-spacing": "off",
"global-require": "off", "global-require": "off",
"no-trailing-spaces": "off", "no-trailing-spaces": "off",
@ -97,7 +94,6 @@
"no-console": "off", "no-console": "off",
"space-unary-ops": "off", "space-unary-ops": "off",
"import/no-dynamic-require": "off", "import/no-dynamic-require": "off",
"semi-spacing": "off",
"no-bitwise": "off", "no-bitwise": "off",
"no-empty": "off", "no-empty": "off",
"array-bracket-spacin": "off", "array-bracket-spacin": "off",

@ -251,7 +251,7 @@ function setup() {
install.setup(function (err, data) { install.setup(function (err, data) {
var separator = ' '; var separator = ' ';
if (process.stdout.columns > 10) { if (process.stdout.columns > 10) {
for(var x = 0,cols = process.stdout.columns - 10;x < cols;x++) { for(var x = 0,cols = process.stdout.columns - 10; x < cols; x++) {
separator += '='; separator += '=';
} }
} }

@ -14,7 +14,7 @@
bootbox.alert({ bootbox.alert({
closeButton: false, closeButton: false,
message: translated, message: translated,
callback: function (){ callback: function () {
window.location.reload(); window.location.reload();
} }
}); });

@ -11,7 +11,7 @@ define('admin/appearance/skins', function () {
url: 'https://bootswatch.com/api/3.json' url: 'https://bootswatch.com/api/3.json'
}).done(Skins.render); }).done(Skins.render);
$('#skins').on('click', function (e){ $('#skins').on('click', function (e) {
var target = $(e.target); var target = $(e.target);
if (!target.attr('data-action')) { if (!target.attr('data-action')) {
@ -72,7 +72,7 @@ define('admin/appearance/skins', function () {
if (config['theme:src']) { if (config['theme:src']) {
var skin = config['theme:src'] var skin = config['theme:src']
.match(/latest\/(\S+)\/bootstrap.min.css/)[1] .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); highlightSelectedTheme(skin);
} }

@ -5,7 +5,7 @@ define('admin/appearance/themes', function () {
var Themes = {}; var Themes = {};
Themes.init = function () { Themes.init = function () {
$('#installed_themes').on('click', function (e){ $('#installed_themes').on('click', function (e) {
var target = $(e.target), var target = $(e.target),
action = target.attr('data-action'); action = target.attr('data-action');

@ -273,7 +273,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function (semver, Chart)
adjustPieCharts(); adjustPieCharts();
$('[data-action="updateGraph"]').on('click', function () { $('[data-action="updateGraph"]').on('click', function () {
var until = undefined; var until;
switch($(this).attr('data-until')) { switch($(this).attr('data-until')) {
case 'last-month': case 'last-month':
var lastMonth = new Date(); var lastMonth = new Date();

@ -2,7 +2,7 @@
/*global define*/ /*global define*/
define('admin/general/languages', ['admin/settings'], function (Settings) { define('admin/general/languages', ['admin/settings'], function (Settings) {
var Languages = {} var Languages = {};
Languages.init = function () { Languages.init = function () {
Settings.prepare(); Settings.prepare();

@ -77,7 +77,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) { templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) {
li = $(translator.unescape(li)); li = $(translator.unescape(li));
$('#enabled').append(li); $('#enabled').append(li);
componentHandler.upgradeDom() componentHandler.upgradeDom();
}); });
} }

@ -5,8 +5,8 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
var Categories = {}, newCategoryId = -1, sortables; var Categories = {}, newCategoryId = -1, sortables;
Categories.init = function () { Categories.init = function () {
socket.emit('admin.categories.getAll', function (error, payload){ socket.emit('admin.categories.getAll', function (error, payload) {
if(error){ if(error) {
return app.alertError(error.message); return app.alertError(error.message);
} }
@ -85,7 +85,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
}); });
}; };
Categories.render = function (categories){ Categories.render = function (categories) {
var container = $('.categories'); var container = $('.categories');
if (!categories || !categories.length) { if (!categories || !categories.length) {
@ -124,7 +124,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
var isCategoryUpdate = (newCategoryId != -1); var isCategoryUpdate = (newCategoryId != -1);
//Update needed? //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 parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid],
modified = {}, i = 0, list = parentCategory.toArray(), len = list.length; modified = {}, i = 0, list = parentCategory.toArray(), len = list.length;
@ -134,7 +134,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
}; };
} }
if (isCategoryUpdate){ if (isCategoryUpdate) {
modified[e.item.dataset.cid].parentCid = newCategoryId; modified[e.item.dataset.cid].parentCid = newCategoryId;
} }
@ -151,7 +151,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
* @param container {object} parent jquery element for the list * @param container {object} parent jquery element for the list
* @param parentId {number} parent category identifier * @param parentId {number} parent category identifier
*/ */
function renderList(categories, container, parentId){ function renderList(categories, container, parentId) {
// Translate category names if needed // Translate category names if needed
var count = 0; var count = 0;
categories.forEach(function (category, idx, parent) { categories.forEach(function (category, idx, parent) {
@ -179,7 +179,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
container.append(html); container.append(html);
// Handle and children categories in this level have // Handle and children categories in this level have
for(var x = 0,numCategories = categories.length;x < numCategories;x++) { for(var x = 0,numCategories = categories.length; x < numCategories; x++) {
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid); renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
} }

@ -235,7 +235,7 @@ define('admin/manage/category', [
privs.push(el.getAttribute('data-privilege')); privs.push(el.getAttribute('data-privilege'));
} }
}); });
for(var x = 0,numPrivs = privs.length;x < numPrivs;x++) { for(var x = 0,numPrivs = privs.length; x < numPrivs; x++) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input'); 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) { inputs.each(function (idx, el) {
if (!el.checked) { if (!el.checked) {

@ -59,7 +59,7 @@ define(function () {
value = $input.val().toLowerCase(), value = $input.val().toLowerCase(),
menuItems = $('#acp-search .dropdown-menu').html(''); menuItems = $('#acp-search .dropdown-menu').html('');
function toUpperCase(txt){ function toUpperCase(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
} }

@ -2,7 +2,7 @@
/* global define, socket */ /* global define, socket */
define('admin/settings/general', ['admin/settings'], function (Settings) { define('admin/settings/general', ['admin/settings'], function (Settings) {
var Module = {} var Module = {};
Module.init = function () { Module.init = function () {
$('button[data-action="removeLogo"]').on('click', function () { $('button[data-action="removeLogo"]').on('click', function () {

@ -122,7 +122,7 @@ $(document).ready(function () {
var payload = { var payload = {
url: url url: url
} };
$(window).trigger('action:ajaxify.start', payload); $(window).trigger('action:ajaxify.start', payload);

@ -33,7 +33,7 @@ app.cacheBuster = null;
app.handleSearch(); app.handleSearch();
} }
$('body').on('click', '#new_topic', function (){ $('body').on('click', '#new_topic', function () {
app.newTopic(); app.newTopic();
}); });
@ -41,7 +41,7 @@ app.cacheBuster = null;
components.get('user/logout').on('click', app.logout); components.get('user/logout').on('click', app.logout);
}); });
Visibility.change(function (event, state){ Visibility.change(function (event, state) {
if (state === 'visible') { if (state === 'visible') {
app.isFocused = true; app.isFocused = true;
app.alternatingTitle(''); app.alternatingTitle('');
@ -428,7 +428,7 @@ app.cacheBuster = null;
$('#search-form').on('submit', dismissSearch); $('#search-form').on('submit', dismissSearch);
searchInput.on('blur', dismissSearch); searchInput.on('blur', dismissSearch);
function dismissSearch(){ function dismissSearch() {
searchFields.addClass('hidden'); searchFields.addClass('hidden');
searchButton.removeClass('hidden'); searchButton.removeClass('hidden');
} }

@ -13,7 +13,7 @@ define('forum/compose', [], function () {
container: container container: container
}); });
} }
} };
return Compose; return Compose;
}); });

@ -60,7 +60,7 @@ define('forum/groups/list', ['forum/infinitescroll'], function (infinitescroll)
$('[component="groups/container"]').attr('data-nextstart', data.nextStart); $('[component="groups/container"]').attr('data-nextstart', data.nextStart);
} }
}); });
} };
Groups.search = function () { Groups.search = function () {
var groupsEl = $('#groups-list'), var groupsEl = $('#groups-list'),

@ -22,7 +22,7 @@ define('autocomplete', function () {
if (result && result.users) { if (result && result.users) {
var names = result.users.map(function (user) { var names = result.users.map(function (user) {
var username = $('<div/>').html(user.username).text() var username = $('<div/>').html(user.username).text();
return user && { return user && {
label: username, label: username,
value: username, value: username,

@ -19,7 +19,7 @@ define('sounds', ['buzz'], function (buzz) {
} }
eventSoundMapping = mapping; eventSoundMapping = mapping;
}); });
} };
function loadData(callback) { function loadData(callback) {
socket.emit('modules.sounds.getData', function (err, data) { socket.emit('modules.sounds.getData', function (err, data) {

@ -88,7 +88,7 @@ if ('undefined' !== typeof window) {
}); });
}(jQuery || {fn:{}})); }(jQuery || {fn:{}}));
(function (){ (function () {
// FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245 // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245
// from http://stackoverflow.com/questions/15931962/bootstrap-dropdown-disappear-with-right-click-on-firefox // from http://stackoverflow.com/questions/15931962/bootstrap-dropdown-disappear-with-right-click-on-firefox
// obtain a reference to the original handler // obtain a reference to the original handler

@ -309,7 +309,7 @@
labels = [], labels = [],
tmpDate; tmpDate;
for(var x = 29;x >= 0;x--) { for(var x = 29; x >= 0; x--) {
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate()); labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate());
} }
@ -443,7 +443,7 @@
}; };
if (typeof String.prototype.startsWith != 'function') { if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (prefix){ String.prototype.startsWith = function (prefix) {
if (this.length < prefix.length) { if (this.length < prefix.length) {
return false; return false;
} }

@ -29,7 +29,7 @@ var async = require('async'),
} }
// custom done condition // custom done condition
options.doneIf = typeof options.doneIf === 'function' ? options.doneIf : function (){}; options.doneIf = typeof options.doneIf === 'function' ? options.doneIf : function () {};
var batch = options.batch || DEFAULT_BATCH_SIZE; var batch = options.batch || DEFAULT_BATCH_SIZE;
var start = 0; var start = 0;

@ -301,7 +301,7 @@ var privileges = require('./privileges');
category.parentCid = 0; category.parentCid = 0;
} }
if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)){ if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)) {
tree.push(category); tree.push(category);
category.children = Categories.getTree(categories, category.cid); category.children = Categories.getTree(categories, category.cid);
} }
@ -318,7 +318,7 @@ var privileges = require('./privileges');
var bullet = level ? '&bull; ' : ''; var bullet = level ? '&bull; ' : '';
category.value = category.cid; category.value = category.cid;
category.text = level + bullet + category.name category.text = level + bullet + category.name;
categoriesData.push(category); categoriesData.push(category);
category.children.forEach(function (child) { category.children.forEach(function (child) {
@ -349,7 +349,7 @@ var privileges = require('./privileges');
Categories.filterIgnoringUids = function (cid, uids, callback) { Categories.filterIgnoringUids = function (cid, uids, callback) {
async.waterfall([ async.waterfall([
function (next){ function (next) {
db.sortedSetScores('cid:' + cid + ':ignorers', uids, next); db.sortedSetScores('cid:' + cid + ':ignorers', uids, next);
}, },
function (scores, next) { function (scores, next) {

@ -89,7 +89,7 @@ module.exports = function (Categories) {
db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next); db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next);
} }
}, },
function (next){ function (next) {
Categories.updateRecentTid(cid, postData.tid, next); Categories.updateRecentTid(cid, postData.tid, next);
}, },
function (next) { function (next) {

@ -52,7 +52,7 @@ groupsController.list = function (req, res, next) {
groupsController.get = function (req, res, callback) { groupsController.get = function (req, res, callback) {
var groupName = req.params.name; var groupName = req.params.name;
async.waterfall([ async.waterfall([
function (next){ function (next) {
groups.exists(groupName, next); groups.exists(groupName, next);
}, },
function (exists, next) { function (exists, next) {

@ -57,7 +57,7 @@ function getNodeInfo(callback) {
platform: os.platform(), platform: os.platform(),
arch: os.arch(), arch: os.arch(),
release: os.release(), release: os.release(),
load: os.loadavg().map(function (load){ return load.toFixed(2); }).join(', ') load: os.loadavg().map(function (load) { return load.toFixed(2); }).join(', ')
} }
}; };

@ -55,7 +55,7 @@ topicsController.get = function (req, res, callback) {
if (!res.locals.isAPI && (!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) { if (!res.locals.isAPI && (!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) {
var url = '/topic/' + results.topic.slug; var url = '/topic/' + results.topic.slug;
if (req.params.post_index){ if (req.params.post_index) {
url += '/' + req.params.post_index; url += '/' + req.params.post_index;
} }
if (currentPage > 1) { if (currentPage > 1) {

@ -65,7 +65,7 @@ module.exports = function (Groups) {
function (uploadData, next) { function (uploadData, next) {
Groups.setGroupField(data.groupName, 'cover:thumb:url', uploadData.url, next); Groups.setGroupField(data.groupName, 'cover:thumb:url', uploadData.url, next);
}, },
function (next){ function (next) {
fs.unlink(tempPath, next); // Delete temporary file fs.unlink(tempPath, next); // Delete temporary file
} }
], function (err) { ], function (err) {

@ -131,7 +131,7 @@ module.exports = function (Groups) {
} else { } else {
return 0; return 0;
} }
}) });
next(null, results); next(null, results);
} }
], callback); ], callback);

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

@ -43,7 +43,7 @@ module.exports = function (middleware) {
}; };
var isAllowed = function (url) { var isAllowed = function (url) {
for(var x = 0,numAllowed = allowedRoutes.length,route;x < numAllowed;x++) { for(var x = 0,numAllowed = allowedRoutes.length,route; x < numAllowed; x++) {
route = new RegExp(allowedRoutes[x]); route = new RegExp(allowedRoutes[x]);
if (route.test(url)) { if (route.test(url)) {
return true; return true;

@ -161,6 +161,3 @@ module.exports = function (middleware) {
}; };
}; };

@ -107,9 +107,9 @@ var middleware;
return next(); return next();
} }
plugins = plugins.filter(function (plugin){ plugins = plugins.filter(function (plugin) {
return plugin && typeof plugin === 'string'; return plugin && typeof plugin === 'string';
}).map(function (plugin){ }).map(function (plugin) {
return path.join(__dirname, '../node_modules/', plugin); return path.join(__dirname, '../node_modules/', plugin);
}); });
@ -122,7 +122,7 @@ var middleware;
if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') { if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') {
process.stdout.write('\n'); 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.'); 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++) { for(var x = 0,numPlugins = Plugins.versionWarning.length; x < numPlugins; x++) {
process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n'); process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n');
} }
process.stdout.write('\n'); process.stdout.write('\n');
@ -329,7 +329,7 @@ var middleware;
pluginArray.sort(function (a, b) { pluginArray.sort(function (a, b) {
if (a.name > b.name ) { if (a.name > b.name ) {
return 1; return 1;
} else if (a.name < b.name ){ } else if (a.name < b.name ) {
return -1; return -1;
} else { } else {
return 0; return 0;
@ -348,20 +348,20 @@ var middleware;
async.apply(fs.readdir, npmPluginPath), async.apply(fs.readdir, npmPluginPath),
function (dirs, next) { function (dirs, next) {
dirs = dirs.filter(function (dir){ dirs = dirs.filter(function (dir) {
return dir.startsWith('nodebb-plugin-') || return dir.startsWith('nodebb-plugin-') ||
dir.startsWith('nodebb-widget-') || dir.startsWith('nodebb-widget-') ||
dir.startsWith('nodebb-rewards-') || dir.startsWith('nodebb-rewards-') ||
dir.startsWith('nodebb-theme-'); dir.startsWith('nodebb-theme-');
}).map(function (dir){ }).map(function (dir) {
return path.join(npmPluginPath, dir); return path.join(npmPluginPath, dir);
}); });
async.filter(dirs, function (dir, callback){ async.filter(dirs, function (dir, callback) {
fs.stat(dir, function (err, stats){ fs.stat(dir, function (err, stats) {
callback(!err && stats.isDirectory()); callback(!err && stats.isDirectory());
}); });
}, function (plugins){ }, function (plugins) {
next(null, plugins); next(null, plugins);
}); });
}, },

@ -66,7 +66,7 @@ module.exports = function (privileges) {
memberData.forEach(function (member) { memberData.forEach(function (member) {
member.privileges = {}; member.privileges = {};
for(var x = 0,numPrivs = userPrivileges.length;x < numPrivs;x++) { for(var x = 0,numPrivs = userPrivileges.length; x < numPrivs; x++) {
member.privileges[userPrivileges[x]] = memberSets[x].indexOf(parseInt(member.uid, 10)) !== -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) { var memberData = groupNames.map(function (member) {
memberPrivs = {}; memberPrivs = {};
for(var x = 0,numPrivs = groupPrivileges.length;x < numPrivs;x++) { for(var x = 0,numPrivs = groupPrivileges.length; x < numPrivs; x++) {
memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1; memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1;
} }
return { return {

@ -364,7 +364,7 @@ function sendFeed(feed, res) {
res.type('xml').set('Content-Length', Buffer.byteLength(xml)).send(xml); res.type('xml').set('Content-Length', Buffer.byteLength(xml)).send(xml);
} }
module.exports = function (app, middleware, controllers){ module.exports = function (app, middleware, controllers) {
app.get('/topic/:topic_id.rss', generateForTopic); app.get('/topic/:topic_id.rss', generateForTopic);
app.get('/category/:category_id.rss', generateForCategory); app.get('/category/:category_id.rss', generateForCategory);
app.get('/recent.rss', generateForRecent); app.get('/recent.rss', generateForRecent);

@ -98,7 +98,7 @@ module.exports = function (app, middleware, hotswapIds) {
var ensureLoggedIn = require('connect-ensure-login'); var ensureLoggedIn = require('connect-ensure-login');
if (Array.isArray(hotswapIds) && hotswapIds.length) { if (Array.isArray(hotswapIds) && hotswapIds.length) {
for(var idx,x = 0;x < hotswapIds.length;x++) { for(var idx,x = 0; x < hotswapIds.length; x++) {
idx = routers.push(express.Router()) - 1; idx = routers.push(express.Router()) - 1;
routers[idx].hotswapId = hotswapIds[x]; routers[idx].hotswapId = hotswapIds[x];
} }
@ -135,7 +135,7 @@ module.exports = function (app, middleware, hotswapIds) {
userRoutes(router, middleware, controllers); userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers); groupRoutes(router, middleware, controllers);
for(var x = 0;x < routers.length;x++) { for(var x = 0; x < routers.length; x++) {
app.use(relativePath, routers[x]); app.use(relativePath, routers[x]);
} }

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

@ -25,7 +25,7 @@ Categories.getAll = function (socket, data, callback) {
//Hook changes, there is no req, and res //Hook changes, there is no req, and res
plugins.fireHook('filter:admin.categories.get', {categories: categories}, next); plugins.fireHook('filter:admin.categories.get', {categories: categories}, next);
}, },
function (result, next){ function (result, next) {
next(null, categories.getTree(result.categories, 0)); next(null, categories.getTree(result.categories, 0));
} }
], function (err, categoriesTree) { ], function (err, categoriesTree) {

@ -167,5 +167,5 @@ module.exports = function (SocketPosts) {
}, },
async.apply(posts.updateFlagData) async.apply(posts.updateFlagData)
], callback); ], callback);
} };
}; };

@ -21,7 +21,7 @@ module.exports = function (SocketPosts) {
privileges.posts.canMove(data.pid, socket.uid, next); privileges.posts.canMove(data.pid, socket.uid, next);
}, },
function (canMove, next) { function (canMove, next) {
if (!canMove){ if (!canMove) {
return next(new Error('[[error:no-privileges]]')); return next(new Error('[[error:no-privileges]]'));
} }

@ -122,6 +122,6 @@ module.exports = function (SocketUser) {
} }
callback(null, data.list.pictures); callback(null, data.list.pictures);
}) });
}; };
}; };

@ -393,7 +393,7 @@ var social = require('./social');
}); });
}, next); }, next);
} }
], function (err){ ], function (err) {
callback(err); callback(err);
}); });
}; };

@ -147,10 +147,10 @@ module.exports = function (Topics) {
Topics.filterIgnoringUids = function (tid, uids, callback) { Topics.filterIgnoringUids = function (tid, uids, callback) {
async.waterfall([ async.waterfall([
function (next){ function (next) {
db.isSetMembers('tid:' + tid + ':ignorers', uids, next); db.isSetMembers('tid:' + tid + ':ignorers', uids, next);
}, },
function (isMembers, next){ function (isMembers, next) {
var readingUids = uids.filter(function (uid, index) { var readingUids = uids.filter(function (uid, index) {
return uid && isMembers[index]; return uid && isMembers[index];
}); });

@ -56,7 +56,7 @@ module.exports = function (Topics) {
Topics.create({uid: results.postData.uid, title: title, cid: cid}, next); Topics.create({uid: results.postData.uid, title: title, cid: cid}, next);
}, },
function (results, next) { function (results, next) {
Topics.updateTopicBookmarks(fromTid, pids, function (){ next( null, results );} ); Topics.updateTopicBookmarks(fromTid, pids, function () { next( null, results );} );
}, },
function (_tid, next) { function (_tid, next) {
function move(pid, next) { function move(pid, next) {

@ -37,7 +37,7 @@ module.exports = function (User) {
expiry_readable: new Date(parseInt(expiry, 10)).toString().replace(/:/g, '%3A'), expiry_readable: new Date(parseInt(expiry, 10)).toString().replace(/:/g, '%3A'),
reason: validator.escape(String(reason)) reason: validator.escape(String(reason))
}); });
}) });
}; };
User.getModerationHistory = function (uid, callback) { User.getModerationHistory = function (uid, callback) {

@ -138,7 +138,7 @@ module.exports = function (User) {
db.delete('invitation:email:' + email, callback); db.delete('invitation:email:' + email, callback);
} }
], function (err) { ], function (err) {
next(err) next(err);
}); });
} }
], callback); ], callback);

@ -81,7 +81,7 @@ describe('authentication', function () {
}, function (err, response, body) { }, function (err, response, body) {
assert.ifError(err); assert.ifError(err);
assert.equal(body, 'not-authorized'); assert.equal(body, 'not-authorized');
done() done();
}); });
}); });
}); });
@ -119,7 +119,7 @@ describe('authentication', function () {
assert(body); assert(body);
assert.equal(body.username, 'regular'); assert.equal(body.username, 'regular');
assert.equal(body.email, 'regular@nodebb.org'); assert.equal(body.email, 'regular@nodebb.org');
done() done();
}); });
}); });
}); });

@ -7,7 +7,7 @@ var db = require('./mocks/databasemock');
describe('Test database', function () { describe('Test database', function () {
it('should work', function () { it('should work', function () {
assert.doesNotThrow(function (){ assert.doesNotThrow(function () {
require('./mocks/databasemock'); require('./mocks/databasemock');
}); });
}); });

@ -33,7 +33,7 @@
var testDbConfig = nconf.get('test_database'); var testDbConfig = nconf.get('test_database');
var productionDbConfig = nconf.get(dbType); var productionDbConfig = nconf.get(dbType);
if (!testDbConfig){ if (!testDbConfig) {
errorText = 'test_database is not defined'; errorText = 'test_database is not defined';
winston.info( winston.info(
'\n===========================================================\n' + '\n===========================================================\n' +

@ -67,7 +67,7 @@ describe('Plugins', function () {
plugins.registerHook('test-plugin', {hook: 'static:test.hook', method: actionMethod}); plugins.registerHook('test-plugin', {hook: 'static:test.hook', method: actionMethod});
plugins.fireHook('static:test.hook', {bar: 'test'}, function (err) { plugins.fireHook('static:test.hook', {bar: 'test'}, function (err) {
assert.ifError(err); assert.ifError(err);
done() done();
}); });
}); });

@ -252,14 +252,14 @@ describe('Topic\'s', function () {
}); });
}); });
describe('.ignore', function (){ describe('.ignore', function () {
var newTid; var newTid;
var uid; var uid;
var newTopic; var newTopic;
before(function (done){ before(function (done) {
uid = topic.userId; uid = topic.userId;
async.waterfall([ async.waterfall([
function (done){ function (done) {
topics.post({uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId}, function (err, result) { topics.post({uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId}, function (err, result) {
if (err) { if (err) {
return done(err); return done(err);
@ -270,43 +270,43 @@ describe('Topic\'s', function () {
done(); done();
}); });
}, },
function (done){ function (done) {
topics.markUnread( newTid, uid, done ); topics.markUnread( newTid, uid, done );
} }
],done); ],done);
}); });
it('should not appear in the unread list', function (done){ it('should not appear in the unread list', function (done) {
async.waterfall([ async.waterfall([
function (done){ function (done) {
topics.ignore( newTid, uid, done ); topics.ignore( newTid, uid, done );
}, },
function (done){ function (done) {
topics.getUnreadTopics(0, uid, 0, -1, '', done ); topics.getUnreadTopics(0, uid, 0, -1, '', done );
}, },
function (results, done){ function (results, done) {
var topics = results.topics; var topics = results.topics;
var tids = topics.map( function (topic){ return topic.tid; } ); var tids = topics.map( function (topic) { return topic.tid; } );
assert.equal(tids.indexOf(newTid), -1, 'The topic appeared in the unread list.'); assert.equal(tids.indexOf(newTid), -1, 'The topic appeared in the unread list.');
done(); done();
} }
], done); ], done);
}); });
it('should not appear as unread in the recent list', function (done){ it('should not appear as unread in the recent list', function (done) {
async.waterfall([ async.waterfall([
function (done){ function (done) {
topics.ignore( newTid, uid, done ); topics.ignore( newTid, uid, done );
}, },
function (done){ function (done) {
topics.getLatestTopics( uid, 0, -1, 'year', done ); topics.getLatestTopics( uid, 0, -1, 'year', done );
}, },
function (results, done){ function (results, done) {
var topics = results.topics; var topics = results.topics;
var topic; var topic;
var i; var i;
for(i = 0; i < topics.length; ++i){ for(i = 0; i < topics.length; ++i) {
if( topics[i].tid == newTid ){ if( topics[i].tid == newTid ) {
assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list'); assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list');
return done(); return done();
} }
@ -317,40 +317,40 @@ describe('Topic\'s', function () {
], done); ], done);
}); });
it('should appear as unread again when marked as reading', function (done){ it('should appear as unread again when marked as reading', function (done) {
async.waterfall([ async.waterfall([
function (done){ function (done) {
topics.ignore( newTid, uid, done ); topics.ignore( newTid, uid, done );
}, },
function (done){ function (done) {
topics.follow( newTid, uid, done ); topics.follow( newTid, uid, done );
}, },
function (done){ function (done) {
topics.getUnreadTopics(0, uid, 0, -1, '', done ); topics.getUnreadTopics(0, uid, 0, -1, '', done );
}, },
function (results, done){ function (results, done) {
var topics = results.topics; var topics = results.topics;
var tids = topics.map( function (topic){ return topic.tid; } ); var tids = topics.map( function (topic) { return topic.tid; } );
assert.notEqual(tids.indexOf(newTid), -1, 'The topic did not appear in the unread list.'); assert.notEqual(tids.indexOf(newTid), -1, 'The topic did not appear in the unread list.');
done(); done();
} }
], done); ], done);
}); });
it('should appear as unread again when marked as following', function (done){ it('should appear as unread again when marked as following', function (done) {
async.waterfall([ async.waterfall([
function (done){ function (done) {
topics.ignore( newTid, uid, done ); topics.ignore( newTid, uid, done );
}, },
function (done){ function (done) {
topics.follow( newTid, uid, done ); topics.follow( newTid, uid, done );
}, },
function (done){ function (done) {
topics.getUnreadTopics(0, uid, 0, -1, '', done ); topics.getUnreadTopics(0, uid, 0, -1, '', done );
}, },
function (results, done){ function (results, done) {
var topics = results.topics; var topics = results.topics;
var tids = topics.map( function (topic){ return topic.tid; } ); var tids = topics.map( function (topic) { return topic.tid; } );
assert.notEqual(tids.indexOf(newTid), -1, 'The topic did not appear in the unread list.'); assert.notEqual(tids.indexOf(newTid), -1, 'The topic did not appear in the unread list.');
done(); done();
} }
@ -360,12 +360,12 @@ describe('Topic\'s', function () {
describe('.fork', function (){ describe('.fork', function () {
var newTopic; var newTopic;
var replies = []; var replies = [];
var topicPids; var topicPids;
var originalBookmark = 5; var originalBookmark = 5;
function postReply( next ){ function postReply( next ) {
topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid}, topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid},
function (err, result) { function (err, result) {
assert.equal(err, null, 'was created with error'); assert.equal(err, null, 'was created with error');
@ -379,30 +379,30 @@ describe('Topic\'s', function () {
before( function (done) { before( function (done) {
async.waterfall( async.waterfall(
[ [
function (next){ function (next) {
groups.join('administrators', topic.userId, next); groups.join('administrators', topic.userId, next);
}, },
function ( next ){ function ( next ) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) { topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
assert.ifError( err ); assert.ifError( err );
newTopic = result.topicData; newTopic = result.topicData;
next(); next();
}); });
}, },
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ postReply( next );}, function ( next ) { postReply( next );},
function ( next ){ function ( next ) {
topicPids = replies.map( function ( reply ){ return reply.pid; } ); topicPids = replies.map( function ( reply ) { return reply.pid; } );
topics.setUserBookmark( newTopic.tid, topic.userId, originalBookmark, next ); topics.setUserBookmark( newTopic.tid, topic.userId, originalBookmark, next );
}], }],
done ); done );
@ -413,9 +413,9 @@ describe('Topic\'s', function () {
done(); done();
}); });
it('should not update the user\'s bookmark', function (done){ it('should not update the user\'s bookmark', function (done) {
async.waterfall([ async.waterfall([
function (next){ function (next) {
topics.createTopicFromPosts( topics.createTopicFromPosts(
topic.userId, topic.userId,
'Fork test, no bookmark update', 'Fork test, no bookmark update',
@ -423,19 +423,19 @@ describe('Topic\'s', function () {
newTopic.tid, newTopic.tid,
next ); next );
}, },
function ( forkedTopicData, next){ function ( forkedTopicData, next) {
topics.getUserBookmark( newTopic.tid, topic.userId, next ); topics.getUserBookmark( newTopic.tid, topic.userId, next );
}, },
function ( bookmark, next ){ function ( bookmark, next ) {
assert.equal( originalBookmark, bookmark ); assert.equal( originalBookmark, bookmark );
next(); next();
} }
],done); ],done);
}); });
it('should update the user\'s bookmark ', function (done){ it('should update the user\'s bookmark ', function (done) {
async.waterfall([ async.waterfall([
function (next){ function (next) {
topics.createTopicFromPosts( topics.createTopicFromPosts(
topic.userId, topic.userId,
'Fork test, no bookmark update', 'Fork test, no bookmark update',
@ -443,10 +443,10 @@ describe('Topic\'s', function () {
newTopic.tid, newTopic.tid,
next ); next );
}, },
function ( forkedTopicData, next){ function ( forkedTopicData, next) {
topics.getUserBookmark( newTopic.tid, topic.userId, next ); topics.getUserBookmark( newTopic.tid, topic.userId, next );
}, },
function ( bookmark, next ){ function ( bookmark, next ) {
assert.equal( originalBookmark - 2, bookmark ); assert.equal( originalBookmark - 2, bookmark );
next(); next();
} }

@ -7,8 +7,8 @@ var Translator = shim.Translator;
require('../src/languages').init(function () {}); require('../src/languages').init(function () {});
describe('translator shim', function (){ describe('translator shim', function () {
describe('.translate()', function (){ describe('.translate()', function () {
it('should translate correctly', function (done) { it('should translate correctly', function (done) {
shim.translate('[[global:pagination.out_of, (foobar), [[global:home]]]]', function (translated) { shim.translate('[[global:pagination.out_of, (foobar), [[global:home]]]]', function (translated) {
assert.strictEqual(translated, '(foobar) out of Home'); assert.strictEqual(translated, '(foobar) out of Home');
@ -18,8 +18,8 @@ describe('translator shim', function (){
}); });
}); });
describe('new Translator(language)', function (){ describe('new Translator(language)', function () {
describe('.translate()', function (){ describe('.translate()', function () {
it('should handle basic translations', function (done) { it('should handle basic translations', function (done) {
var translator = new Translator('en_GB'); var translator = new Translator('en_GB');
@ -165,7 +165,7 @@ describe('new Translator(language)', function (){
}); });
}); });
describe('Translator.create()', function (){ describe('Translator.create()', function () {
it('should return an instance of Translator', function (done) { it('should return an instance of Translator', function (done) {
var translator = Translator.create('en_GB'); var translator = Translator.create('en_GB');

@ -49,7 +49,7 @@ describe('User', function () {
describe('.create(), when created', function () { describe('.create(), when created', function () {
it('should be created properly', function (done) { 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.equal(error, null, 'was created with error');
assert.ok(userId); assert.ok(userId);

@ -7,7 +7,7 @@ var utils = require('./../public/src/utils.js');
describe('Utility Methods', function () { describe('Utility Methods', function () {
describe('username validation', function () { describe('username validation', function () {
it('accepts latin-1 characters', function (){ it('accepts latin-1 characters', function () {
var username = "John\"'-. Doeäâèéë1234"; var username = "John\"'-. Doeäâèéë1234";
assert(utils.isUserNameValid(username), 'invalid username'); assert(utils.isUserNameValid(username), 'invalid username');
}); });
@ -29,7 +29,7 @@ describe('Utility Methods', function () {
}); });
describe('UUID generation', function () { describe('UUID generation', function () {
it('return unique random value every time', function (){ it('return unique random value every time', function () {
var uuid1 = utils.generateUUID(), var uuid1 = utils.generateUUID(),
uuid2 = utils.generateUUID(); uuid2 = utils.generateUUID();
assert.notEqual(uuid1, uuid2, 'matches'); assert.notEqual(uuid1, uuid2, 'matches');

Loading…
Cancel
Save