diff --git a/.eslintrc.json b/.eslintrc.json index c16b47f396..c1536e1c01 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -48,7 +48,6 @@ "no-extend-native": "off", "no-shadow-restricted-names": "off", "no-extra-boolean-cast": "off", - "no-undef-init": "off", "no-script-url": "off", "no-path-concat": "off", "no-unused-expressions": "off", @@ -66,7 +65,6 @@ "padded-blocks": "off", "eol-last": "off", "lines-around-directive": "off", - "space-before-blocks": "off", "no-restricted-syntax": "off", "vars-on-top": "off", "no-prototype-builtins": "off", @@ -80,7 +78,6 @@ "keyword-spacing": "off", "no-plusplus": "off", "no-mixed-operators": "off", - "semi": "off", "comma-spacing": "off", "global-require": "off", "no-trailing-spaces": "off", @@ -97,7 +94,6 @@ "no-console": "off", "space-unary-ops": "off", "import/no-dynamic-require": "off", - "semi-spacing": "off", "no-bitwise": "off", "no-empty": "off", "array-bracket-spacin": "off", diff --git a/app.js b/app.js index 82ffd2f7b1..947a5f4465 100644 --- a/app.js +++ b/app.js @@ -251,7 +251,7 @@ function setup() { install.setup(function (err, data) { var separator = ' '; 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 += '='; } } diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index 9d56403854..13a2340d5f 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -14,7 +14,7 @@ bootbox.alert({ closeButton: false, message: translated, - callback: function (){ + callback: function () { window.location.reload(); } }); diff --git a/public/src/admin/appearance/skins.js b/public/src/admin/appearance/skins.js index 9dc02a1efc..7583dc952d 100644 --- a/public/src/admin/appearance/skins.js +++ b/public/src/admin/appearance/skins.js @@ -11,7 +11,7 @@ define('admin/appearance/skins', function () { url: 'https://bootswatch.com/api/3.json' }).done(Skins.render); - $('#skins').on('click', function (e){ + $('#skins').on('click', function (e) { var target = $(e.target); if (!target.attr('data-action')) { @@ -72,7 +72,7 @@ define('admin/appearance/skins', function () { 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/appearance/themes.js b/public/src/admin/appearance/themes.js index 41adcc1589..835dcda654 100644 --- a/public/src/admin/appearance/themes.js +++ b/public/src/admin/appearance/themes.js @@ -5,7 +5,7 @@ define('admin/appearance/themes', function () { var Themes = {}; Themes.init = function () { - $('#installed_themes').on('click', function (e){ + $('#installed_themes').on('click', function (e) { var target = $(e.target), action = target.attr('data-action'); diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index d6f02e6e3b..62ef80313a 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -273,7 +273,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function (semver, Chart) adjustPieCharts(); $('[data-action="updateGraph"]').on('click', function () { - var until = undefined; + var until; switch($(this).attr('data-until')) { case 'last-month': var lastMonth = new Date(); diff --git a/public/src/admin/general/languages.js b/public/src/admin/general/languages.js index 7d597ffc46..8ccf016698 100644 --- a/public/src/admin/general/languages.js +++ b/public/src/admin/general/languages.js @@ -2,7 +2,7 @@ /*global define*/ define('admin/general/languages', ['admin/settings'], function (Settings) { - var Languages = {} + var Languages = {}; Languages.init = function () { Settings.prepare(); diff --git a/public/src/admin/general/navigation.js b/public/src/admin/general/navigation.js index 35ca62e094..ee53fa5561 100644 --- a/public/src/admin/general/navigation.js +++ b/public/src/admin/general/navigation.js @@ -77,7 +77,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) { li = $(translator.unescape(li)); $('#enabled').append(li); - componentHandler.upgradeDom() + componentHandler.upgradeDom(); }); } diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index 4244fa41ab..bbc5a69695 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -5,8 +5,8 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri var Categories = {}, newCategoryId = -1, sortables; Categories.init = function () { - socket.emit('admin.categories.getAll', function (error, payload){ - if(error){ + socket.emit('admin.categories.getAll', function (error, payload) { + if(error) { 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'); if (!categories || !categories.length) { @@ -124,7 +124,7 @@ 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], 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; } @@ -151,7 +151,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri * @param container {object} parent jquery element for the list * @param parentId {number} parent category identifier */ - function renderList(categories, container, parentId){ + function renderList(categories, container, parentId) { // Translate category names if needed var count = 0; categories.forEach(function (category, idx, parent) { @@ -179,7 +179,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++) { + for(var x = 0,numCategories = categories.length; x < numCategories; x++) { renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid); } diff --git a/public/src/admin/manage/category.js b/public/src/admin/manage/category.js index a48c73f9ec..bc0b1652b5 100644 --- a/public/src/admin/manage/category.js +++ b/public/src/admin/manage/category.js @@ -235,7 +235,7 @@ define('admin/manage/category', [ 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'); inputs.each(function (idx, el) { if (!el.checked) { diff --git a/public/src/admin/modules/search.js b/public/src/admin/modules/search.js index b639034ebd..f64a2490e7 100644 --- a/public/src/admin/modules/search.js +++ b/public/src/admin/modules/search.js @@ -59,7 +59,7 @@ define(function () { value = $input.val().toLowerCase(), menuItems = $('#acp-search .dropdown-menu').html(''); - function toUpperCase(txt){ + function toUpperCase(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); } diff --git a/public/src/admin/settings/general.js b/public/src/admin/settings/general.js index fc0d7d540f..af1028c70e 100644 --- a/public/src/admin/settings/general.js +++ b/public/src/admin/settings/general.js @@ -2,7 +2,7 @@ /* global define, socket */ define('admin/settings/general', ['admin/settings'], function (Settings) { - var Module = {} + var Module = {}; Module.init = function () { $('button[data-action="removeLogo"]').on('click', function () { diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index 8630859899..77b04f63c1 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -122,7 +122,7 @@ $(document).ready(function () { var payload = { url: url - } + }; $(window).trigger('action:ajaxify.start', payload); diff --git a/public/src/app.js b/public/src/app.js index 0659268f18..6b14d9e489 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -33,7 +33,7 @@ app.cacheBuster = null; app.handleSearch(); } - $('body').on('click', '#new_topic', function (){ + $('body').on('click', '#new_topic', function () { app.newTopic(); }); @@ -41,7 +41,7 @@ app.cacheBuster = null; components.get('user/logout').on('click', app.logout); }); - Visibility.change(function (event, state){ + Visibility.change(function (event, state) { if (state === 'visible') { app.isFocused = true; app.alternatingTitle(''); @@ -428,7 +428,7 @@ app.cacheBuster = null; $('#search-form').on('submit', dismissSearch); searchInput.on('blur', dismissSearch); - function dismissSearch(){ + function dismissSearch() { searchFields.addClass('hidden'); searchButton.removeClass('hidden'); } diff --git a/public/src/client/compose.js b/public/src/client/compose.js index 4b2bb87b4e..f1ff7c7acf 100644 --- a/public/src/client/compose.js +++ b/public/src/client/compose.js @@ -13,7 +13,7 @@ define('forum/compose', [], function () { container: container }); } - } + }; return Compose; }); diff --git a/public/src/client/groups/list.js b/public/src/client/groups/list.js index 55ac232eb1..6e24bf5d78 100644 --- a/public/src/client/groups/list.js +++ b/public/src/client/groups/list.js @@ -60,7 +60,7 @@ define('forum/groups/list', ['forum/infinitescroll'], function (infinitescroll) $('[component="groups/container"]').attr('data-nextstart', data.nextStart); } }); - } + }; Groups.search = function () { var groupsEl = $('#groups-list'), diff --git a/public/src/modules/autocomplete.js b/public/src/modules/autocomplete.js index 0a6c664d52..c20f804f38 100644 --- a/public/src/modules/autocomplete.js +++ b/public/src/modules/autocomplete.js @@ -22,7 +22,7 @@ define('autocomplete', function () { if (result && result.users) { var names = result.users.map(function (user) { - var username = $('
').html(user.username).text() + var username = $('
').html(user.username).text(); return user && { label: username, value: username, diff --git a/public/src/modules/sounds.js b/public/src/modules/sounds.js index c82391159e..a31bbe507a 100644 --- a/public/src/modules/sounds.js +++ b/public/src/modules/sounds.js @@ -19,7 +19,7 @@ define('sounds', ['buzz'], function (buzz) { } eventSoundMapping = mapping; }); - } + }; function loadData(callback) { socket.emit('modules.sounds.getData', function (err, data) { diff --git a/public/src/overrides.js b/public/src/overrides.js index c644bb6281..d2120876c1 100644 --- a/public/src/overrides.js +++ b/public/src/overrides.js @@ -88,7 +88,7 @@ if ('undefined' !== typeof window) { }); }(jQuery || {fn:{}})); - (function (){ + (function () { // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245 // from http://stackoverflow.com/questions/15931962/bootstrap-dropdown-disappear-with-right-click-on-firefox // obtain a reference to the original handler diff --git a/public/src/utils.js b/public/src/utils.js index 93af4b1e71..0b78b34030 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -309,7 +309,7 @@ labels = [], tmpDate; - for(var x = 29;x >= 0;x--) { + for(var x = 29; x >= 0; x--) { tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x)); labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate()); } @@ -443,7 +443,7 @@ }; if (typeof String.prototype.startsWith != 'function') { - String.prototype.startsWith = function (prefix){ + String.prototype.startsWith = function (prefix) { if (this.length < prefix.length) { return false; } diff --git a/src/batch.js b/src/batch.js index ca0944b80d..202a600017 100644 --- a/src/batch.js +++ b/src/batch.js @@ -29,7 +29,7 @@ var async = require('async'), } // 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 start = 0; diff --git a/src/categories.js b/src/categories.js index 4e2c435f8e..65c60bb58c 100644 --- a/src/categories.js +++ b/src/categories.js @@ -301,7 +301,7 @@ var privileges = require('./privileges'); category.parentCid = 0; } - if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)){ + if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)) { tree.push(category); category.children = Categories.getTree(categories, category.cid); } @@ -318,7 +318,7 @@ var privileges = require('./privileges'); var bullet = level ? '• ' : ''; category.value = category.cid; - category.text = level + bullet + category.name + category.text = level + bullet + category.name; categoriesData.push(category); category.children.forEach(function (child) { @@ -349,7 +349,7 @@ var privileges = require('./privileges'); Categories.filterIgnoringUids = function (cid, uids, callback) { async.waterfall([ - function (next){ + function (next) { db.sortedSetScores('cid:' + cid + ':ignorers', uids, next); }, function (scores, next) { diff --git a/src/categories/topics.js b/src/categories/topics.js index b9ab96bee2..ec211da960 100644 --- a/src/categories/topics.js +++ b/src/categories/topics.js @@ -89,7 +89,7 @@ module.exports = function (Categories) { db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next); } }, - function (next){ + function (next) { Categories.updateRecentTid(cid, postData.tid, next); }, function (next) { diff --git a/src/controllers/admin/groups.js b/src/controllers/admin/groups.js index 19aeb4f2f4..a424a5c070 100644 --- a/src/controllers/admin/groups.js +++ b/src/controllers/admin/groups.js @@ -52,7 +52,7 @@ groupsController.list = function (req, res, next) { groupsController.get = function (req, res, callback) { var groupName = req.params.name; async.waterfall([ - function (next){ + function (next) { groups.exists(groupName, next); }, function (exists, next) { diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js index 6c60d6a048..9977d75fa9 100644 --- a/src/controllers/admin/info.js +++ b/src/controllers/admin/info.js @@ -57,7 +57,7 @@ function getNodeInfo(callback) { platform: os.platform(), arch: os.arch(), 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(', ') } }; diff --git a/src/controllers/topics.js b/src/controllers/topics.js index c739052937..e6072be9f2 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -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 + '/')) { var url = '/topic/' + results.topic.slug; - if (req.params.post_index){ + if (req.params.post_index) { url += '/' + req.params.post_index; } if (currentPage > 1) { diff --git a/src/groups/cover.js b/src/groups/cover.js index f2ed4e05ea..d7dfc8890c 100644 --- a/src/groups/cover.js +++ b/src/groups/cover.js @@ -65,7 +65,7 @@ module.exports = function (Groups) { function (uploadData, next) { Groups.setGroupField(data.groupName, 'cover:thumb:url', uploadData.url, next); }, - function (next){ + function (next) { fs.unlink(tempPath, next); // Delete temporary file } ], function (err) { diff --git a/src/groups/search.js b/src/groups/search.js index 74b30c3188..55bf5e5789 100644 --- a/src/groups/search.js +++ b/src/groups/search.js @@ -131,7 +131,7 @@ module.exports = function (Groups) { } else { return 0; } - }) + }); next(null, results); } ], callback); diff --git a/src/hotswap.js b/src/hotswap.js index d5d3749b7b..ece8f205d7 100644 --- a/src/hotswap.js +++ b/src/hotswap.js @@ -10,7 +10,7 @@ HotSwap.prepare = function (app) { HotSwap.find = function (id) { 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) { return x; } diff --git a/src/middleware/maintenance.js b/src/middleware/maintenance.js index 3abe15f6f8..5ef04ef8fa 100644 --- a/src/middleware/maintenance.js +++ b/src/middleware/maintenance.js @@ -43,7 +43,7 @@ module.exports = function (middleware) { }; 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]); if (route.test(url)) { return true; diff --git a/src/middleware/user.js b/src/middleware/user.js index 9f8a61401c..c4c39a1e81 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -161,6 +161,3 @@ module.exports = function (middleware) { }; }; - - - diff --git a/src/plugins.js b/src/plugins.js index 10bda11b31..d5a86d72dc 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -107,9 +107,9 @@ var middleware; return next(); } - plugins = plugins.filter(function (plugin){ + plugins = plugins.filter(function (plugin) { return plugin && typeof plugin === 'string'; - }).map(function (plugin){ + }).map(function (plugin) { return path.join(__dirname, '../node_modules/', plugin); }); @@ -122,7 +122,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++) { + for(var x = 0,numPlugins = Plugins.versionWarning.length; x < numPlugins; x++) { process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n'); } process.stdout.write('\n'); @@ -329,7 +329,7 @@ var middleware; pluginArray.sort(function (a, b) { if (a.name > b.name ) { return 1; - } else if (a.name < b.name ){ + } else if (a.name < b.name ) { return -1; } else { return 0; @@ -348,20 +348,20 @@ var middleware; async.apply(fs.readdir, npmPluginPath), function (dirs, next) { - dirs = dirs.filter(function (dir){ + dirs = dirs.filter(function (dir) { return dir.startsWith('nodebb-plugin-') || dir.startsWith('nodebb-widget-') || dir.startsWith('nodebb-rewards-') || dir.startsWith('nodebb-theme-'); - }).map(function (dir){ + }).map(function (dir) { return path.join(npmPluginPath, dir); }); - async.filter(dirs, function (dir, callback){ - fs.stat(dir, function (err, stats){ + async.filter(dirs, function (dir, callback) { + fs.stat(dir, function (err, stats) { callback(!err && stats.isDirectory()); }); - }, function (plugins){ + }, function (plugins) { next(null, plugins); }); }, diff --git a/src/privileges/categories.js b/src/privileges/categories.js index 717551e99f..67b004e19e 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++) { + for(var x = 0,numPrivs = userPrivileges.length; x < numPrivs; x++) { 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++) { + for(var x = 0,numPrivs = groupPrivileges.length; x < numPrivs; x++) { memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1; } return { diff --git a/src/routes/feeds.js b/src/routes/feeds.js index 7a178ab9f0..50ebbc9342 100644 --- a/src/routes/feeds.js +++ b/src/routes/feeds.js @@ -364,7 +364,7 @@ function sendFeed(feed, res) { 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('/category/:category_id.rss', generateForCategory); app.get('/recent.rss', generateForRecent); diff --git a/src/routes/index.js b/src/routes/index.js index 47f06771b5..ccf8b5efd0 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++) { + for(var idx,x = 0; x < hotswapIds.length; x++) { idx = routers.push(express.Router()) - 1; routers[idx].hotswapId = hotswapIds[x]; } @@ -135,7 +135,7 @@ module.exports = function (app, middleware, hotswapIds) { userRoutes(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]); } diff --git a/src/sitemap.js b/src/sitemap.js index d21bb96241..9e52985c02 100644 --- a/src/sitemap.js +++ b/src/sitemap.js @@ -37,7 +37,7 @@ sitemap.render = function (callback) { numPages = Math.ceil(tids.length / numTopics); } - for(var x = 1;x <= numPages;x++) { + for(var x = 1; x <= numPages; x++) { returnData.topics.push(x); } diff --git a/src/socket.io/admin/categories.js b/src/socket.io/admin/categories.js index b90ec3e4b6..e05f6db36e 100644 --- a/src/socket.io/admin/categories.js +++ b/src/socket.io/admin/categories.js @@ -25,7 +25,7 @@ Categories.getAll = function (socket, data, callback) { //Hook changes, there is no req, and res plugins.fireHook('filter:admin.categories.get', {categories: categories}, next); }, - function (result, next){ + function (result, next) { next(null, categories.getTree(result.categories, 0)); } ], function (err, categoriesTree) { diff --git a/src/socket.io/posts/flag.js b/src/socket.io/posts/flag.js index e34808990a..565c4ec7c9 100644 --- a/src/socket.io/posts/flag.js +++ b/src/socket.io/posts/flag.js @@ -167,5 +167,5 @@ module.exports = function (SocketPosts) { }, async.apply(posts.updateFlagData) ], callback); - } + }; }; diff --git a/src/socket.io/posts/move.js b/src/socket.io/posts/move.js index dc830566eb..207db2aef5 100644 --- a/src/socket.io/posts/move.js +++ b/src/socket.io/posts/move.js @@ -21,7 +21,7 @@ module.exports = function (SocketPosts) { privileges.posts.canMove(data.pid, socket.uid, next); }, function (canMove, next) { - if (!canMove){ + if (!canMove) { return next(new Error('[[error:no-privileges]]')); } diff --git a/src/socket.io/user/picture.js b/src/socket.io/user/picture.js index 7539d1687e..95f1613501 100644 --- a/src/socket.io/user/picture.js +++ b/src/socket.io/user/picture.js @@ -122,6 +122,6 @@ module.exports = function (SocketUser) { } callback(null, data.list.pictures); - }) + }); }; }; \ No newline at end of file diff --git a/src/topics.js b/src/topics.js index d7eb658e3b..de8b795466 100644 --- a/src/topics.js +++ b/src/topics.js @@ -393,7 +393,7 @@ var social = require('./social'); }); }, next); } - ], function (err){ + ], function (err) { callback(err); }); }; diff --git a/src/topics/follow.js b/src/topics/follow.js index b68e7beb26..49feeb50c1 100644 --- a/src/topics/follow.js +++ b/src/topics/follow.js @@ -147,10 +147,10 @@ module.exports = function (Topics) { Topics.filterIgnoringUids = function (tid, uids, callback) { async.waterfall([ - function (next){ + function (next) { db.isSetMembers('tid:' + tid + ':ignorers', uids, next); }, - function (isMembers, next){ + function (isMembers, next) { var readingUids = uids.filter(function (uid, index) { return uid && isMembers[index]; }); diff --git a/src/topics/fork.js b/src/topics/fork.js index c1cd019a90..d882cddf00 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -56,7 +56,7 @@ module.exports = function (Topics) { Topics.create({uid: results.postData.uid, title: title, cid: cid}, next); }, function (results, next) { - Topics.updateTopicBookmarks(fromTid, pids, function (){ next( null, results );} ); + Topics.updateTopicBookmarks(fromTid, pids, function () { next( null, results );} ); }, function (_tid, next) { function move(pid, next) { diff --git a/src/user/info.js b/src/user/info.js index 43991a800f..46b4024e32 100644 --- a/src/user/info.js +++ b/src/user/info.js @@ -37,7 +37,7 @@ module.exports = function (User) { expiry_readable: new Date(parseInt(expiry, 10)).toString().replace(/:/g, '%3A'), reason: validator.escape(String(reason)) }); - }) + }); }; User.getModerationHistory = function (uid, callback) { diff --git a/src/user/invite.js b/src/user/invite.js index 726a7af144..1066a662ac 100644 --- a/src/user/invite.js +++ b/src/user/invite.js @@ -138,7 +138,7 @@ module.exports = function (User) { db.delete('invitation:email:' + email, callback); } ], function (err) { - next(err) + next(err); }); } ], callback); diff --git a/test/authentication.js b/test/authentication.js index 583c5907ba..38860e873a 100644 --- a/test/authentication.js +++ b/test/authentication.js @@ -81,7 +81,7 @@ describe('authentication', function () { }, function (err, response, body) { assert.ifError(err); assert.equal(body, 'not-authorized'); - done() + done(); }); }); }); @@ -119,7 +119,7 @@ describe('authentication', function () { assert(body); assert.equal(body.username, 'regular'); assert.equal(body.email, 'regular@nodebb.org'); - done() + done(); }); }); }); diff --git a/test/database.js b/test/database.js index 01539fdf6b..36b2ef932d 100644 --- a/test/database.js +++ b/test/database.js @@ -7,7 +7,7 @@ var db = require('./mocks/databasemock'); describe('Test database', function () { it('should work', function () { - assert.doesNotThrow(function (){ + assert.doesNotThrow(function () { require('./mocks/databasemock'); }); }); diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index 1338cde8cc..1bc780a2cc 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -33,7 +33,7 @@ var testDbConfig = nconf.get('test_database'); var productionDbConfig = nconf.get(dbType); - if (!testDbConfig){ + if (!testDbConfig) { errorText = 'test_database is not defined'; winston.info( '\n===========================================================\n' + diff --git a/test/plugins.js b/test/plugins.js index 36137133fe..87acbdb82f 100644 --- a/test/plugins.js +++ b/test/plugins.js @@ -67,7 +67,7 @@ describe('Plugins', function () { plugins.registerHook('test-plugin', {hook: 'static:test.hook', method: actionMethod}); plugins.fireHook('static:test.hook', {bar: 'test'}, function (err) { assert.ifError(err); - done() + done(); }); }); diff --git a/test/topics.js b/test/topics.js index 83b026909b..135ec5de8c 100644 --- a/test/topics.js +++ b/test/topics.js @@ -252,14 +252,14 @@ describe('Topic\'s', function () { }); }); - describe('.ignore', function (){ + describe('.ignore', function () { var newTid; var uid; var newTopic; - before(function (done){ + before(function (done) { uid = topic.userId; 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) { if (err) { return done(err); @@ -270,43 +270,43 @@ describe('Topic\'s', function () { done(); }); }, - function (done){ + function (done) { topics.markUnread( newTid, uid, done ); } ],done); }); - it('should not appear in the unread list', function (done){ + it('should not appear in the unread list', function (done) { async.waterfall([ - function (done){ + function (done) { topics.ignore( newTid, uid, done ); }, - function (done){ + function (done) { topics.getUnreadTopics(0, uid, 0, -1, '', done ); }, - function (results, done){ + function (results, done) { 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.'); 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([ - function (done){ + function (done) { topics.ignore( newTid, uid, done ); }, - function (done){ + function (done) { topics.getLatestTopics( uid, 0, -1, 'year', done ); }, - function (results, done){ + function (results, done) { var topics = results.topics; var topic; var i; - for(i = 0; i < topics.length; ++i){ - if( topics[i].tid == newTid ){ + for(i = 0; i < topics.length; ++i) { + if( topics[i].tid == newTid ) { assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list'); return done(); } @@ -317,40 +317,40 @@ describe('Topic\'s', function () { ], 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([ - function (done){ + function (done) { topics.ignore( newTid, uid, done ); }, - function (done){ + function (done) { topics.follow( newTid, uid, done ); }, - function (done){ + function (done) { topics.getUnreadTopics(0, uid, 0, -1, '', done ); }, - function (results, done){ + function (results, done) { 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.'); 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([ - function (done){ + function (done) { topics.ignore( newTid, uid, done ); }, - function (done){ + function (done) { topics.follow( newTid, uid, done ); }, - function (done){ + function (done) { topics.getUnreadTopics(0, uid, 0, -1, '', done ); }, - function (results, done){ + function (results, done) { 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.'); done(); } @@ -360,12 +360,12 @@ describe('Topic\'s', function () { - describe('.fork', function (){ + describe('.fork', function () { var newTopic; var replies = []; var topicPids; var originalBookmark = 5; - function postReply( next ){ + function postReply( next ) { topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid}, function (err, result) { assert.equal(err, null, 'was created with error'); @@ -379,30 +379,30 @@ describe('Topic\'s', function () { before( function (done) { async.waterfall( [ - function (next){ + function (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) { assert.ifError( err ); newTopic = result.topicData; 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 ){ - topicPids = replies.map( function ( reply ){ return reply.pid; } ); + 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 ) { + topicPids = replies.map( function ( reply ) { return reply.pid; } ); topics.setUserBookmark( newTopic.tid, topic.userId, originalBookmark, next ); }], done ); @@ -413,9 +413,9 @@ describe('Topic\'s', function () { done(); }); - it('should not update the user\'s bookmark', function (done){ + it('should not update the user\'s bookmark', function (done) { async.waterfall([ - function (next){ + function (next) { topics.createTopicFromPosts( topic.userId, 'Fork test, no bookmark update', @@ -423,19 +423,19 @@ describe('Topic\'s', function () { newTopic.tid, next ); }, - function ( forkedTopicData, next){ + function ( forkedTopicData, next) { topics.getUserBookmark( newTopic.tid, topic.userId, next ); }, - function ( bookmark, next ){ + function ( bookmark, next ) { assert.equal( originalBookmark, bookmark ); next(); } ],done); }); - it('should update the user\'s bookmark ', function (done){ + it('should update the user\'s bookmark ', function (done) { async.waterfall([ - function (next){ + function (next) { topics.createTopicFromPosts( topic.userId, 'Fork test, no bookmark update', @@ -443,10 +443,10 @@ describe('Topic\'s', function () { newTopic.tid, next ); }, - function ( forkedTopicData, next){ + function ( forkedTopicData, next) { topics.getUserBookmark( newTopic.tid, topic.userId, next ); }, - function ( bookmark, next ){ + function ( bookmark, next ) { assert.equal( originalBookmark - 2, bookmark ); next(); } diff --git a/test/translator.js b/test/translator.js index 18518f2e2e..673311ddaf 100644 --- a/test/translator.js +++ b/test/translator.js @@ -7,8 +7,8 @@ var Translator = shim.Translator; require('../src/languages').init(function () {}); -describe('translator shim', function (){ - describe('.translate()', function (){ +describe('translator shim', function () { + describe('.translate()', function () { it('should translate correctly', function (done) { shim.translate('[[global:pagination.out_of, (foobar), [[global:home]]]]', function (translated) { assert.strictEqual(translated, '(foobar) out of Home'); @@ -18,8 +18,8 @@ describe('translator shim', function (){ }); }); -describe('new Translator(language)', function (){ - describe('.translate()', function (){ +describe('new Translator(language)', function () { + describe('.translate()', function () { it('should handle basic translations', function (done) { 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) { var translator = Translator.create('en_GB'); diff --git a/test/user.js b/test/user.js index bc805d79a0..722188ed8b 100644 --- a/test/user.js +++ b/test/user.js @@ -49,7 +49,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); diff --git a/test/utils.js b/test/utils.js index d342eca7a5..f1606b4766 100644 --- a/test/utils.js +++ b/test/utils.js @@ -7,7 +7,7 @@ var utils = require('./../public/src/utils.js'); describe('Utility Methods', function () { describe('username validation', function () { - it('accepts latin-1 characters', function (){ + it('accepts latin-1 characters', function () { var username = "John\"'-. Doeäâèéë1234"; assert(utils.isUserNameValid(username), 'invalid username'); }); @@ -29,7 +29,7 @@ describe('Utility Methods', 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(), uuid2 = utils.generateUUID(); assert.notEqual(uuid1, uuid2, 'matches');