From 4bb49a717188e9b318f8dcf453666e606c2a758b Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Sat, 18 Feb 2017 15:05:36 -0700 Subject: [PATCH] ESlint no-unused-vars --- .eslintrc | 2 +- Gruntfile.js | 1 - loader.js | 2 +- public/src/admin/advanced/errors.js | 2 +- public/src/admin/advanced/logs.js | 2 +- public/src/admin/appearance/customise.js | 4 ++-- public/src/admin/extend/plugins.js | 29 +++++++++++------------- public/src/admin/extend/rewards.js | 1 - public/src/admin/extend/widgets.js | 2 +- public/src/admin/general/dashboard.js | 2 +- public/src/admin/general/homepage.js | 2 +- public/src/admin/general/navigation.js | 2 +- public/src/admin/manage/category.js | 28 +---------------------- public/src/admin/manage/groups.js | 3 +-- public/src/admin/manage/ip-blacklist.js | 2 +- public/src/admin/manage/registration.js | 4 ++-- public/src/admin/modules/selectable.js | 2 +- public/src/admin/settings/email.js | 2 +- public/src/admin/settings/general.js | 2 +- public/src/client/account/profile.js | 3 +-- public/src/client/account/topics.js | 2 -- public/src/client/categories.js | 1 - public/src/client/category.js | 4 ++-- public/src/client/groups/list.js | 2 -- public/src/client/groups/memberlist.js | 2 +- public/src/client/login.js | 6 ++--- public/src/client/topic/replies.js | 2 +- public/src/installer/install.js | 4 ++-- public/src/modules/iconSelect.js | 2 +- public/src/modules/search.js | 2 +- public/src/modules/settings/array.js | 3 +-- public/src/modules/settings/key.js | 3 +-- public/src/modules/settings/object.js | 3 +-- src/categories/unread.js | 2 -- src/controllers/admin/appearance.js | 2 +- src/controllers/admin/cache.js | 2 +- src/controllers/admin/categories.js | 2 +- src/controllers/admin/groups.js | 3 --- src/controllers/admin/info.js | 2 +- src/controllers/admin/users.js | 2 +- src/controllers/authentication.js | 3 +-- src/controllers/helpers.js | 2 +- src/controllers/index.js | 2 +- src/database/mongo/list.js | 10 ++++---- src/database/mongo/main.js | 8 +++---- src/database/mongo/sets.js | 8 +++---- src/database/redis.js | 1 - src/database/redis/hash.js | 4 ++-- src/database/redis/list.js | 8 +++---- src/database/redis/main.js | 6 ++--- src/database/redis/sets.js | 8 +++---- src/events.js | 2 +- src/meta/dependencies.js | 4 ++-- src/middleware/index.js | 3 +-- src/notifications.js | 3 --- src/plugins.js | 2 +- src/plugins/hooks.js | 2 +- src/plugins/install.js | 2 +- src/privileges/posts.js | 2 -- src/reset.js | 2 +- src/routes/debug.js | 3 +-- src/routes/feeds.js | 2 +- src/socket.io/blacklist.js | 3 --- src/socket.io/topics.js | 3 --- src/topics/fork.js | 3 +-- src/topics/user.js | 4 ---- src/user/bans.js | 2 +- src/user/invite.js | 2 +- test/.eslintrc | 3 +++ test/rewards.js | 4 ++-- 70 files changed, 97 insertions(+), 162 deletions(-) diff --git a/.eslintrc b/.eslintrc index 57105ee349..777f786b71 100644 --- a/.eslintrc +++ b/.eslintrc @@ -62,7 +62,7 @@ "no-mixed-requires": "off", // "brace-style": "off", "max-statements-per-line": "off", - "no-unused-vars": "off", + // "no-unused-vars": "off", // "no-mixed-spaces-and-tabs": "off", // "no-useless-concat": "off", // "require-jsdoc": "off", diff --git a/Gruntfile.js b/Gruntfile.js index cbfba0db6b..3a2a4cd4e7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,7 +16,6 @@ module.exports = function (grunt) { function update(action, filepath, target) { var updateArgs = args.slice(); - var fromFile = ''; var compiling = ''; var time = Date.now(); diff --git a/loader.js b/loader.js index ead0e36125..38009f4691 100644 --- a/loader.js +++ b/loader.js @@ -237,6 +237,6 @@ fs.open(path.join(__dirname, 'config.json'), 'r', function (err) { }); } else { // No config detected, kickstart web installer - var child = require('child_process').fork('app'); + require('child_process').fork('app'); } }); diff --git a/public/src/admin/advanced/errors.js b/public/src/admin/advanced/errors.js index c49cef724e..6356d5690b 100644 --- a/public/src/admin/advanced/errors.js +++ b/public/src/admin/advanced/errors.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/advanced/errors', ['Chart', 'translator'], function (Chart, translator) { +define('admin/advanced/errors', ['Chart'], function (Chart) { var Errors = {}; Errors.init = function () { diff --git a/public/src/admin/advanced/logs.js b/public/src/admin/advanced/logs.js index 5d13543a40..e756bea7d8 100644 --- a/public/src/admin/advanced/logs.js +++ b/public/src/admin/advanced/logs.js @@ -10,7 +10,7 @@ define('admin/advanced/logs', function () { // Affix menu $('.affix').affix(); - $('.logs').find('button[data-action]').on('click', function (event) { + $('.logs').find('button[data-action]').on('click', function () { var btnEl = $(this); var action = btnEl.attr('data-action'); diff --git a/public/src/admin/appearance/customise.js b/public/src/admin/appearance/customise.js index edad9e8a74..566161e5a9 100644 --- a/public/src/admin/appearance/customise.js +++ b/public/src/admin/appearance/customise.js @@ -15,7 +15,7 @@ define('admin/appearance/customise', ['admin/settings'], function (Settings) { customCSS.setTheme('ace/theme/twilight'); customCSS.getSession().setMode('ace/mode/css'); - customCSS.on('change', function (event) { + customCSS.on('change', function () { app.flags = app.flags || {}; app.flags._unsaved = true; $('#customCSS-holder').val(customCSS.getValue()); @@ -24,7 +24,7 @@ define('admin/appearance/customise', ['admin/settings'], function (Settings) { customHTML.setTheme('ace/theme/twilight'); customHTML.getSession().setMode('ace/mode/html'); - customHTML.on('change', function (event) { + customHTML.on('change', function () { app.flags = app.flags || {}; app.flags._unsaved = true; $('#customHTML-holder').val(customHTML.getValue()); diff --git a/public/src/admin/extend/plugins.js b/public/src/admin/extend/plugins.js index 1419a76555..9622b4fbc0 100644 --- a/public/src/admin/extend/plugins.js +++ b/public/src/admin/extend/plugins.js @@ -71,21 +71,19 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t return; } - require(['semver'], function (semver) { - if (payload.version !== 'latest') { - Plugins.toggleInstall(pluginID, payload.version); - } else if (payload.version === 'latest') { - confirmInstall(pluginID, function (confirm) { - if (confirm) { - Plugins.toggleInstall(pluginID, 'latest'); - } else { - btn.removeAttr('disabled'); - } - }); - } else { - btn.removeAttr('disabled'); - } - }); + if (payload.version !== 'latest') { + Plugins.toggleInstall(pluginID, payload.version); + } else if (payload.version === 'latest') { + confirmInstall(pluginID, function (confirm) { + if (confirm) { + Plugins.toggleInstall(pluginID, 'latest'); + } else { + btn.removeAttr('disabled'); + } + }); + } else { + btn.removeAttr('disabled'); + } }); }); @@ -198,7 +196,6 @@ define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, t Plugins.toggleInstall = function (pluginID, version, callback) { var btn = $('li[data-plugin-id="' + pluginID + '"] button[data-action="toggleInstall"]'); - var activateBtn = btn.siblings('[data-action="toggleActive"]'); btn.find('i').attr('class', 'fa fa-refresh fa-spin'); socket.emit('admin.plugins.toggleInstall', { diff --git a/public/src/admin/extend/rewards.js b/public/src/admin/extend/rewards.js index 374251166f..fe1322b8e2 100644 --- a/public/src/admin/extend/rewards.js +++ b/public/src/admin/extend/rewards.js @@ -42,7 +42,6 @@ define('admin/extend/rewards', ['translator'], function (translator) { .on('click', '.toggle', function () { var btn = $(this); var disabled = btn.hasClass('btn-success'); - var id = $(this).parents('[data-id]').attr('data-id'); btn.toggleClass('btn-warning').toggleClass('btn-success').translateHtml('[[admin/extend/rewards:' + (disabled ? 'disable' : 'enable') + ']]'); // send disable api call return false; diff --git a/public/src/admin/extend/widgets.js b/public/src/admin/extend/widgets.js index 134efe3864..4394ee9a04 100644 --- a/public/src/admin/extend/widgets.js +++ b/public/src/admin/extend/widgets.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/extend/widgets', ['jqueryui'], function (jqueryui) { +define('admin/extend/widgets', ['jqueryui'], function () { var Widgets = {}; Widgets.init = function () { diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index ed46203970..10fe6ffc6d 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -24,7 +24,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s realtimeInterval: 1500, }; - $(window).on('action:ajaxify.start', function (ev, data) { + $(window).on('action:ajaxify.start', function () { clearInterval(intervals.rooms); clearInterval(intervals.graphs); diff --git a/public/src/admin/general/homepage.js b/public/src/admin/general/homepage.js index 17e28d8cbb..ca5438c6a1 100644 --- a/public/src/admin/general/homepage.js +++ b/public/src/admin/general/homepage.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/general/homepage', ['admin/settings'], function (Settings) { +define('admin/general/homepage', ['admin/settings'], function () { function toggleCustomRoute() { if ($('[data-field="homePageRoute"]').val()) { $('#homePageCustom').hide(); diff --git a/public/src/admin/general/navigation.js b/public/src/admin/general/navigation.js index 992c4fcb56..5269c1c2c0 100644 --- a/public/src/admin/general/navigation.js +++ b/public/src/admin/general/navigation.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], function (translator, iconSelect, jqueryui) { +define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], function (translator, iconSelect) { var navigation = {}; var available; diff --git a/public/src/admin/manage/category.js b/public/src/admin/manage/category.js index e70b858afa..af99bf9748 100644 --- a/public/src/admin/manage/category.js +++ b/public/src/admin/manage/category.js @@ -26,32 +26,6 @@ define('admin/manage/category', [ } } - function save(e) { - e.preventDefault(); - - if (Object.keys(modified_categories).length) { - socket.emit('admin.categories.update', modified_categories, function (err, results) { - if (err) { - return app.alertError(err.message); - } - - if (results && results.length) { - app.flags._unsaved = false; - app.alert({ - title: '[[admin/manage/categories:alert.updated]]', - message: translator.compile( - 'admin/manage/categories:alert.updated-success', - results.join(', ') - ), - type: 'success', - timeout: 2000, - }); - } - }); - modified_categories = {}; - } - } - $('.blockclass, form.category select').each(function () { var $this = $(this); $this.val($this.attr('data-value')); @@ -226,7 +200,7 @@ define('admin/manage/category', [ ajaxify.data.category.tagWhitelist.forEach(function (tag) { tagEl.tagsinput('add', tag); }); - tagEl.on('itemAdded itemRemoved', function (event) { + tagEl.on('itemAdded itemRemoved', function () { modified(tagEl); }); } diff --git a/public/src/admin/manage/groups.js b/public/src/admin/manage/groups.js index 90f46e82c3..71aaac5175 100644 --- a/public/src/admin/manage/groups.js +++ b/public/src/admin/manage/groups.js @@ -32,7 +32,6 @@ define('admin/manage/groups', ['translator'], function (translator) { name: createGroupName.val(), description: $('#create-group-desc').val(), }; - var errorText; socket.emit('admin.groups.create', submitObj, function (err) { if (err) { @@ -62,7 +61,7 @@ define('admin/manage/groups', ['translator'], function (translator) { if (confirm) { socket.emit('groups.delete', { groupName: groupName, - }, function (err, data) { + }, function (err) { if (err) { return app.alertError(err.message); } diff --git a/public/src/admin/manage/ip-blacklist.js b/public/src/admin/manage/ip-blacklist.js index a9cf75d022..0b565325d7 100644 --- a/public/src/admin/manage/ip-blacklist.js +++ b/public/src/admin/manage/ip-blacklist.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/manage/ip-blacklist', ['translator'], function (translator) { +define('admin/manage/ip-blacklist', [], function () { var Blacklist = {}; Blacklist.init = function () { diff --git a/public/src/admin/manage/registration.js b/public/src/admin/manage/registration.js index 2db0e5c6bf..048aafbf96 100644 --- a/public/src/admin/manage/registration.js +++ b/public/src/admin/manage/registration.js @@ -5,7 +5,7 @@ define('admin/manage/registration', function () { var Registration = {}; Registration.init = function () { - $('.users-list').on('click', '[data-action]', function (ev) { + $('.users-list').on('click', '[data-action]', function () { var parent = $(this).parents('[data-username]'); var action = $(this).attr('data-action'); var username = parent.attr('data-username'); @@ -20,7 +20,7 @@ define('admin/manage/registration', function () { return false; }); - $('.invites-list').on('click', '[data-action]', function (ev) { + $('.invites-list').on('click', '[data-action]', function () { var parent = $(this).parents('[data-invitation-mail][data-invited-by]'); var email = parent.attr('data-invitation-mail'); var invitedBy = parent.attr('data-invited-by'); diff --git a/public/src/admin/modules/selectable.js b/public/src/admin/modules/selectable.js index 80df206333..bd45e6f850 100644 --- a/public/src/admin/modules/selectable.js +++ b/public/src/admin/modules/selectable.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/modules/selectable', ['jqueryui'], function (jqueryui) { +define('admin/modules/selectable', ['jqueryui'], function () { var selectable = {}; selectable.enable = function (containerEl, targets) { diff --git a/public/src/admin/settings/email.js b/public/src/admin/settings/email.js index 4e75c10fb7..4156073367 100644 --- a/public/src/admin/settings/email.js +++ b/public/src/admin/settings/email.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/settings/email', ['admin/settings'], function (settings) { +define('admin/settings/email', ['admin/settings'], function () { var module = {}; var emailEditor; diff --git a/public/src/admin/settings/general.js b/public/src/admin/settings/general.js index 2487035a8b..af66449e02 100644 --- a/public/src/admin/settings/general.js +++ b/public/src/admin/settings/general.js @@ -1,7 +1,7 @@ 'use strict'; -define('admin/settings/general', ['admin/settings'], function (Settings) { +define('admin/settings/general', ['admin/settings'], function () { var Module = {}; Module.init = function () { diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index 9f57454e00..2f8a834d36 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -4,9 +4,8 @@ define('forum/account/profile', [ 'forum/account/header', 'forum/infinitescroll', - 'translator', 'components', -], function (header, infinitescroll, translator) { +], function (header, infinitescroll) { var Account = {}; var theirid; diff --git a/public/src/client/account/topics.js b/public/src/client/account/topics.js index bdd7626902..340c2e11b9 100644 --- a/public/src/client/account/topics.js +++ b/public/src/client/account/topics.js @@ -3,7 +3,6 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'], function (header, infinitescroll) { var AccountTopics = {}; - var template; var set; AccountTopics.init = function () { @@ -13,7 +12,6 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'], }; AccountTopics.handleInfiniteScroll = function (_template, _set) { - template = _template; set = _set; if (!config.usePagination) { diff --git a/public/src/client/categories.js b/public/src/client/categories.js index 30b22d5260..ff1dfa3401 100644 --- a/public/src/client/categories.js +++ b/public/src/client/categories.js @@ -35,7 +35,6 @@ define('forum/categories', ['components', 'translator'], function (components, t } var recentPosts = category.find('[component="category/posts"]'); - var insertBefore = recentPosts.first(); parseAndTranslate([post], function (html) { html.hide(); diff --git a/public/src/client/category.js b/public/src/client/category.js index 5b51c2249a..e2dfcd9924 100644 --- a/public/src/client/category.js +++ b/public/src/client/category.js @@ -112,11 +112,11 @@ define('forum/category', [ }); }; - Category.navigatorCallback = function (topIndex, bottomIndex, elementCount) { + Category.navigatorCallback = function (topIndex, bottomIndex) { return bottomIndex; }; - $(window).on('action:ajaxify.contentLoaded', function (ev, data) { + $(window).on('action:ajaxify.contentLoaded', function () { if (ajaxify.data.template.category && ajaxify.data.cid) { var bookmarkIndex = localStorage.getItem('category:' + ajaxify.data.cid + ':bookmark'); var clickedIndex = localStorage.getItem('category:' + ajaxify.data.cid + ':bookmark:clicked'); diff --git a/public/src/client/groups/list.js b/public/src/client/groups/list.js index 8a1bb996b4..882d59eef1 100644 --- a/public/src/client/groups/list.js +++ b/public/src/client/groups/list.js @@ -5,8 +5,6 @@ define('forum/groups/list', ['forum/infinitescroll'], function (infinitescroll) var Groups = {}; Groups.init = function () { - var groupsEl = $('#groups-list'); - infinitescroll.init(Groups.loadMoreGroups); // Group creation diff --git a/public/src/client/groups/memberlist.js b/public/src/client/groups/memberlist.js index a5231817b3..16874b6b79 100644 --- a/public/src/client/groups/memberlist.js +++ b/public/src/client/groups/memberlist.js @@ -1,7 +1,7 @@ 'use strict'; -define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], function (components, infinitescroll) { +define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], function () { var MemberList = {}; var searchInterval; var groupName; diff --git a/public/src/client/login.js b/public/src/client/login.js index bf138c2a25..078b7448f7 100644 --- a/public/src/client/login.js +++ b/public/src/client/login.js @@ -1,7 +1,7 @@ 'use strict'; -define('forum/login', ['translator'], function (translator) { +define('forum/login', [], function () { var Login = {}; Login.init = function () { @@ -35,10 +35,10 @@ define('forum/login', ['translator'], function (translator) { headers: { 'x-csrf-token': config.csrf_token, }, - success: function (data, status) { + success: function (data) { window.location.href = data + '?loggedin'; }, - error: function (data, status) { + error: function (data) { if (data.status === 403 && data.responseText === 'Forbidden') { window.location.href = config.relative_path + '/login?error=csrf-invalid'; } else { diff --git a/public/src/client/topic/replies.js b/public/src/client/topic/replies.js index 3156d44b63..56b5981843 100644 --- a/public/src/client/topic/replies.js +++ b/public/src/client/topic/replies.js @@ -16,7 +16,7 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts'], }); } - function onRepliesClicked(button, tid) { + function onRepliesClicked(button) { var post = button.closest('[data-pid]'); var pid = post.data('pid'); var open = button.children('[component="post/replies/open"]'); diff --git a/public/src/installer/install.js b/public/src/installer/install.js index fffc3e62a5..2b789041da 100644 --- a/public/src/installer/install.js +++ b/public/src/installer/install.js @@ -75,7 +75,7 @@ $('document').ready(function () { } } - function validateConfirmPassword(field) { + function validateConfirmPassword() { if ($('[name="admin:password"]').val() !== $('[name="admin:passwordConfirm"]').val()) { parent.addClass('error'); help.html('Passwords do not match.'); @@ -116,7 +116,7 @@ $('document').ready(function () { $.post('/launch', function () { setInterval(function () { - $.get('/admin').done(function (data) { + $.get('/admin').done(function () { window.location = 'admin'; }); }, 750); diff --git a/public/src/modules/iconSelect.js b/public/src/modules/iconSelect.js index 76d457088f..96a38e0df6 100644 --- a/public/src/modules/iconSelect.js +++ b/public/src/modules/iconSelect.js @@ -44,7 +44,7 @@ define('iconSelect', function () { success: { label: 'Select', className: 'btn-primary', - callback: function (confirm) { + callback: function () { var iconClass = $('.bootbox .selected').attr('class'); var categoryIconClass = $('
').addClass(iconClass).removeClass('fa').removeClass('selected').attr('class'); diff --git a/public/src/modules/search.js b/public/src/modules/search.js index 65f68af699..1401bf8619 100644 --- a/public/src/modules/search.js +++ b/public/src/modules/search.js @@ -85,7 +85,7 @@ define('search', ['navigator', 'translator'], function (nav, translator) { } }; - Search.queryTopic = function (tid, term, callback) { + Search.queryTopic = function (tid, term) { socket.emit('topics.search', { tid: tid, term: term, diff --git a/public/src/modules/settings/array.js b/public/src/modules/settings/array.js index 6268c8d6c9..9b51aee582 100644 --- a/public/src/modules/settings/array.js +++ b/public/src/modules/settings/array.js @@ -1,7 +1,6 @@ 'use strict'; define('settings/array', function () { - var Settings = null; var SettingsArray; var helper = null; @@ -95,7 +94,7 @@ define('settings/array', function () { SettingsArray = { types: ['array', 'div'], use: function () { - helper = (Settings = this).helper; + helper = this.helper; }, create: function (ignored, tagName) { return helper.createElement(tagName || 'div'); diff --git a/public/src/modules/settings/key.js b/public/src/modules/settings/key.js index eac0f9e3c0..df3ade0a32 100644 --- a/public/src/modules/settings/key.js +++ b/public/src/modules/settings/key.js @@ -1,7 +1,6 @@ 'use strict'; define('settings/key', function () { - var Settings = null; var SettingsKey; var helper = null; var lastKey = null; @@ -182,7 +181,7 @@ define('settings/key', function () { SettingsKey = { types: ['key'], use: function () { - helper = (Settings = this).helper; + helper = this.helper; }, init: function (element) { element.focus(function () { diff --git a/public/src/modules/settings/object.js b/public/src/modules/settings/object.js index e7c88ec585..7e79e54cc3 100644 --- a/public/src/modules/settings/object.js +++ b/public/src/modules/settings/object.js @@ -1,7 +1,6 @@ 'use strict'; define('settings/object', function () { - var Settings = null; var SettingsObject; var helper = null; @@ -57,7 +56,7 @@ define('settings/object', function () { SettingsObject = { types: ['object'], use: function () { - helper = (Settings = this).helper; + helper = this.helper; }, create: function (ignored, tagName) { return helper.createElement(tagName || 'div'); diff --git a/src/categories/unread.js b/src/categories/unread.js index 68cb957fe8..1ef6ee40b5 100644 --- a/src/categories/unread.js +++ b/src/categories/unread.js @@ -1,7 +1,5 @@ - 'use strict'; -var async = require('async'); var db = require('../database'); module.exports = function (Categories) { diff --git a/src/controllers/admin/appearance.js b/src/controllers/admin/appearance.js index ee3232204a..021733d417 100644 --- a/src/controllers/admin/appearance.js +++ b/src/controllers/admin/appearance.js @@ -2,7 +2,7 @@ var appearanceController = {}; -appearanceController.get = function (req, res, next) { +appearanceController.get = function (req, res) { var term = req.params.term ? req.params.term : 'themes'; res.render('admin/appearance/' + term, {}); diff --git a/src/controllers/admin/cache.js b/src/controllers/admin/cache.js index 3dab364893..dce16818f8 100644 --- a/src/controllers/admin/cache.js +++ b/src/controllers/admin/cache.js @@ -2,7 +2,7 @@ var cacheController = {}; -cacheController.get = function (req, res, next) { +cacheController.get = function (req, res) { var postCache = require('../../posts/cache'); var groupCache = require('../../groups').cache; diff --git a/src/controllers/admin/categories.js b/src/controllers/admin/categories.js index d1e7b1ef7c..4a60fc14e2 100644 --- a/src/controllers/admin/categories.js +++ b/src/controllers/admin/categories.js @@ -38,7 +38,7 @@ categoriesController.get = function (req, res, next) { }); }; -categoriesController.getAll = function (req, res, next) { +categoriesController.getAll = function (req, res) { // Categories list will be rendered on client side with recursion, etc. res.render('admin/manage/categories', {}); }; diff --git a/src/controllers/admin/groups.js b/src/controllers/admin/groups.js index 4e4aa64531..5e7dd1e78f 100644 --- a/src/controllers/admin/groups.js +++ b/src/controllers/admin/groups.js @@ -6,12 +6,9 @@ var db = require('../../database'); var groups = require('../../groups'); var meta = require('../../meta'); var pagination = require('../../pagination'); -var helpers = require('../helpers'); - var groupsController = {}; - groupsController.list = function (req, res, next) { var page = parseInt(req.query.page, 10) || 1; var groupsPerPage = 20; diff --git a/src/controllers/admin/info.js b/src/controllers/admin/info.js index 572dcd93c2..88fef98b4b 100644 --- a/src/controllers/admin/info.js +++ b/src/controllers/admin/info.js @@ -13,7 +13,7 @@ var infoController = {}; var info = {}; -infoController.get = function (req, res, next) { +infoController.get = function (req, res) { info = {}; pubsub.publish('sync:node:info:start'); setTimeout(function () { diff --git a/src/controllers/admin/users.js b/src/controllers/admin/users.js index ad10b7365e..54d9ab93de 100644 --- a/src/controllers/admin/users.js +++ b/src/controllers/admin/users.js @@ -15,7 +15,7 @@ var usersController = {}; var userFields = ['uid', 'username', 'userslug', 'email', 'postcount', 'joindate', 'banned', 'reputation', 'picture', 'flags', 'lastonline', 'email:confirmed']; -usersController.search = function (req, res, next) { +usersController.search = function (req, res) { res.render('admin/manage/users', { search_display: '', users: [], diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index e83cb56a33..6a2051d2c9 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -6,7 +6,6 @@ var passport = require('passport'); var nconf = require('nconf'); var validator = require('validator'); var _ = require('underscore'); -var url = require('url'); var db = require('../database'); var meta = require('../meta'); @@ -19,7 +18,7 @@ var sockets = require('../socket.io'); var authenticationController = {}; -authenticationController.register = function (req, res, next) { +authenticationController.register = function (req, res) { var registrationType = meta.config.registrationType || 'normal'; if (registrationType === 'disabled') { diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 773b0e6463..5571bfbf62 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -18,7 +18,7 @@ helpers.notAllowed = function (req, res, error) { req: req, res: res, error: error, - }, function (err, data) { + }, function (err) { if (err) { return winston.error(err); } diff --git a/src/controllers/index.js b/src/controllers/index.js index 57e23e069f..04c613be1e 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -416,7 +416,7 @@ Controllers.handleURIErrors = function (err, req, res, next) { } }; -Controllers.handleErrors = function (err, req, res, next) { +Controllers.handleErrors = function (err, req, res) { switch (err.code) { case 'EBADCSRFTOKEN': winston.error(req.path + '\n', err.message); diff --git a/src/database/mongo/list.js b/src/database/mongo/list.js index a639ec0d73..0c5e2955e5 100644 --- a/src/database/mongo/list.js +++ b/src/database/mongo/list.js @@ -18,7 +18,7 @@ module.exports = function (db, module) { } if (exists) { - db.collection('objects').update({ _key: key }, { $push: { array: { $each: [value], $position: 0 } } }, { upsert: true, w: 1 }, function (err, res) { + db.collection('objects').update({ _key: key }, { $push: { array: { $each: [value], $position: 0 } } }, { upsert: true, w: 1 }, function (err) { callback(err); }); } else { @@ -33,7 +33,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').update({ _key: key }, { $push: { array: value } }, { upsert: true, w: 1 }, function (err, res) { + db.collection('objects').update({ _key: key }, { $push: { array: value } }, { upsert: true, w: 1 }, function (err) { callback(err); }); }; @@ -48,7 +48,7 @@ module.exports = function (db, module) { return callback(err); } - db.collection('objects').update({ _key: key }, { $pop: { array: 1 } }, function (err, result) { + db.collection('objects').update({ _key: key }, { $pop: { array: 1 } }, function (err) { callback(err, (value && value.length) ? value[0] : null); }); }); @@ -61,7 +61,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); - db.collection('objects').update({ _key: key }, { $pull: { array: value } }, function (err, res) { + db.collection('objects').update({ _key: key }, { $pull: { array: value } }, function (err) { callback(err); }); }; @@ -76,7 +76,7 @@ module.exports = function (db, module) { return callback(err); } - db.collection('objects').update({ _key: key }, { $set: { array: value } }, function (err, res) { + db.collection('objects').update({ _key: key }, { $set: { array: value } }, function (err) { callback(err); }); }); diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js index c4cd9fe752..4ca3bb2cd3 100644 --- a/src/database/mongo/main.js +++ b/src/database/mongo/main.js @@ -1,7 +1,5 @@ 'use strict'; -var winston = require('winston'); - module.exports = function (db, module) { var helpers = module.helpers.mongo; @@ -33,7 +31,7 @@ module.exports = function (db, module) { if (!key) { return callback(); } - db.collection('objects').remove({ _key: key }, function (err, res) { + db.collection('objects').remove({ _key: key }, function (err) { callback(err); }); }; @@ -43,7 +41,7 @@ module.exports = function (db, module) { if (!Array.isArray(keys) || !keys.length) { return callback(); } - db.collection('objects').remove({ _key: { $in: keys } }, function (err, res) { + db.collection('objects').remove({ _key: { $in: keys } }, function (err) { callback(err); }); }; @@ -76,7 +74,7 @@ module.exports = function (db, module) { module.rename = function (oldKey, newKey, callback) { callback = callback || helpers.noop; - db.collection('objects').update({ _key: oldKey }, { $set: { _key: newKey } }, { multi: true }, function (err, res) { + db.collection('objects').update({ _key: oldKey }, { $set: { _key: newKey } }, { multi: true }, function (err) { callback(err); }); }; diff --git a/src/database/mongo/sets.js b/src/database/mongo/sets.js index 54f6458249..18ce2a932a 100644 --- a/src/database/mongo/sets.js +++ b/src/database/mongo/sets.js @@ -24,7 +24,7 @@ module.exports = function (db, module) { }, { upsert: true, w: 1, - }, function (err, res) { + }, function (err) { callback(err); }); }; @@ -54,7 +54,7 @@ module.exports = function (db, module) { } }); } - bulk.execute(function (err, res) { + bulk.execute(function (err) { callback(err); }); }; @@ -69,7 +69,7 @@ module.exports = function (db, module) { array[index] = helpers.valueToString(element); }); - db.collection('objects').update({ _key: key }, { $pullAll: { members: value } }, function (err, res) { + db.collection('objects').update({ _key: key }, { $pullAll: { members: value } }, function (err) { callback(err); }); }; @@ -89,7 +89,7 @@ module.exports = function (db, module) { } }); } - bulk.execute(function (err, res) { + bulk.execute(function (err) { callback(err); }); }; diff --git a/src/database/redis.js b/src/database/redis.js index d076476f20..27394f7463 100644 --- a/src/database/redis.js +++ b/src/database/redis.js @@ -6,7 +6,6 @@ var semver = require('semver'); var session = require('express-session'); var redis; - var connectRedis; var redisClient; module.questions = [ diff --git a/src/database/redis/hash.js b/src/database/redis/hash.js index 2a83630f4b..938beb2971 100644 --- a/src/database/redis/hash.js +++ b/src/database/redis/hash.js @@ -96,13 +96,13 @@ module.exports = function (redisClient, module) { module.deleteObjectField = function (key, field, callback) { callback = callback || function () {}; - redisClient.hdel(key, field, function (err, res) { + redisClient.hdel(key, field, function (err) { callback(err); }); }; module.deleteObjectFields = function (key, fields, callback) { - helpers.multiKeyValues(redisClient, 'hdel', key, fields, function (err, results) { + helpers.multiKeyValues(redisClient, 'hdel', key, fields, function (err) { callback(err); }); }; diff --git a/src/database/redis/list.js b/src/database/redis/list.js index 3323937cbf..fb445573ff 100644 --- a/src/database/redis/list.js +++ b/src/database/redis/list.js @@ -3,14 +3,14 @@ module.exports = function (redisClient, module) { module.listPrepend = function (key, value, callback) { callback = callback || function () {}; - redisClient.lpush(key, value, function (err, res) { + redisClient.lpush(key, value, function (err) { callback(err); }); }; module.listAppend = function (key, value, callback) { callback = callback || function () {}; - redisClient.rpush(key, value, function (err, res) { + redisClient.rpush(key, value, function (err) { callback(err); }); }; @@ -22,14 +22,14 @@ module.exports = function (redisClient, module) { module.listRemoveAll = function (key, value, callback) { callback = callback || function () {}; - redisClient.lrem(key, 0, value, function (err, res) { + redisClient.lrem(key, 0, value, function (err) { callback(err); }); }; module.listTrim = function (key, start, stop, callback) { callback = callback || function () {}; - redisClient.ltrim(key, start, stop, function (err, res) { + redisClient.ltrim(key, start, stop, function (err) { callback(err); }); }; diff --git a/src/database/redis/main.js b/src/database/redis/main.js index 1ab8a7ff13..baca6b0ffe 100644 --- a/src/database/redis/main.js +++ b/src/database/redis/main.js @@ -21,7 +21,7 @@ module.exports = function (redisClient, module) { module.delete = function (key, callback) { callback = callback || function () {}; - redisClient.del(key, function (err, res) { + redisClient.del(key, function (err) { callback(err); }); }; @@ -32,7 +32,7 @@ module.exports = function (redisClient, module) { for (var i = 0; i < keys.length; i += 1) { multi.del(keys[i]); } - multi.exec(function (err, res) { + multi.exec(function (err) { callback(err); }); }; @@ -55,7 +55,7 @@ module.exports = function (redisClient, module) { module.rename = function (oldKey, newKey, callback) { callback = callback || function () {}; - redisClient.rename(oldKey, newKey, function (err, res) { + redisClient.rename(oldKey, newKey, function (err) { callback(err && err.message !== 'ERR no such key' ? err : null); }); }; diff --git a/src/database/redis/sets.js b/src/database/redis/sets.js index 951b2648c9..a5716438e4 100644 --- a/src/database/redis/sets.js +++ b/src/database/redis/sets.js @@ -11,28 +11,28 @@ module.exports = function (redisClient, module) { if (!value.length) { return callback(); } - redisClient.sadd(key, value, function (err, res) { + redisClient.sadd(key, value, function (err) { callback(err); }); }; module.setsAdd = function (keys, value, callback) { callback = callback || function () {}; - helpers.multiKeysValue(redisClient, 'sadd', keys, value, function (err, res) { + helpers.multiKeysValue(redisClient, 'sadd', keys, value, function (err) { callback(err); }); }; module.setRemove = function (key, value, callback) { callback = callback || function () {}; - redisClient.srem(key, value, function (err, res) { + redisClient.srem(key, value, function (err) { callback(err); }); }; module.setsRemove = function (keys, value, callback) { callback = callback || function () {}; - helpers.multiKeysValue(redisClient, 'srem', keys, value, function (err, res) { + helpers.multiKeysValue(redisClient, 'srem', keys, value, function (err) { callback(err); }); }; diff --git a/src/events.js b/src/events.js index a484aa1fef..3c8ea7a252 100644 --- a/src/events.js +++ b/src/events.js @@ -30,7 +30,7 @@ var utils = require('../public/src/utils'); }, ], next); }, - ], function (err, result) { + ], function (err) { callback(err); }); }; diff --git a/src/meta/dependencies.js b/src/meta/dependencies.js index fff0308e83..939f14b674 100644 --- a/src/meta/dependencies.js +++ b/src/meta/dependencies.js @@ -5,7 +5,7 @@ var fs = require('fs'); var async = require('async'); var semver = require('semver'); var winston = require('winston'); -var colors = require('colors'); +require('colors'); var pkg = require('../../package.json'); @@ -47,7 +47,7 @@ module.exports = function (Meta) { next(true); } }); - }, function (ok) { + }, function () { if (depsMissing) { callback(new Error('dependencies-missing')); } else if (depsOutdated) { diff --git a/src/middleware/index.js b/src/middleware/index.js index df11d8a830..ea8e94e518 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -10,7 +10,6 @@ var ensureLoggedIn = require('connect-ensure-login'); var toobusy = require('toobusy-js'); var plugins = require('../plugins'); -var languages = require('../languages'); var meta = require('../meta'); var user = require('../user'); var groups = require('../groups'); @@ -181,7 +180,7 @@ middleware.applyBlacklist = function (req, res, next) { }); }; -middleware.processTimeagoLocales = function (req, res, next) { +middleware.processTimeagoLocales = function (req, res) { var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js'; var localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path); var exists; diff --git a/src/notifications.js b/src/notifications.js index c2c8f01874..31960dc2f1 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -373,7 +373,6 @@ var utils = require('../public/src/utils'); Notifications.prune = function () { var week = 604800000; - var numPruned = 0; var cutoffTime = Date.now() - week; @@ -390,8 +389,6 @@ var utils = require('../public/src/utils'); return 'notifications:' + nid; }); - numPruned = nids.length; - async.parallel([ function (next) { db.sortedSetRemove('notifications', nids, next); diff --git a/src/plugins.js b/src/plugins.js index 84673f635f..0b2611ae25 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -115,7 +115,7 @@ var middleware; Object.keys(Plugins.loadedHooks).forEach(function (hook) { var hooks = Plugins.loadedHooks[hook]; - hooks = hooks.sort(function (a, b) { + hooks.sort(function (a, b) { return a.priority - b.priority; }); }); diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index 4db26fb560..208eaae1b8 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -44,7 +44,7 @@ module.exports = function (Plugins) { if (parts.length > 2) { parts.pop(); } - var hook = parts.join(':'); + parts.join(':'); } if (data.hook && data.method) { diff --git a/src/plugins/install.js b/src/plugins/install.js index be97ad4a68..1e0fe0838c 100644 --- a/src/plugins/install.js +++ b/src/plugins/install.js @@ -80,7 +80,7 @@ module.exports = function (Plugins) { }, function (active, next) { if (active) { - Plugins.toggleActive(id, function (err, status) { + Plugins.toggleActive(id, function (err) { next(err); }); return; diff --git a/src/privileges/posts.js b/src/privileges/posts.js index 08703ed3f9..8a31ad4129 100644 --- a/src/privileges/posts.js +++ b/src/privileges/posts.js @@ -221,13 +221,11 @@ module.exports = function (privileges) { }; function isPostEditable(pid, uid, callback) { - var tid; async.waterfall([ function (next) { posts.getPostFields(pid, ['tid', 'timestamp'], next); }, function (postData, next) { - tid = postData.tid; var postEditDuration = parseInt(meta.config.postEditDuration, 10); if (postEditDuration && Date.now() - parseInt(postData.timestamp, 10) > postEditDuration * 1000) { return callback(null, { flag: false, message: '[[error:post-edit-duration-expired, ' + meta.config.postEditDuration + ']]' }); diff --git a/src/reset.js b/src/reset.js index a6ed18b32a..f709c4188b 100644 --- a/src/reset.js +++ b/src/reset.js @@ -83,7 +83,7 @@ function resetTheme(themeId, callback) { var meta = require('./meta'); var fs = require('fs'); - fs.access('node_modules/' + themeId + '/package.json', function (err, fd) { + fs.access('node_modules/' + themeId + '/package.json', function (err) { if (err) { winston.warn('[reset] Theme `%s` is not installed on this forum', themeId); callback(new Error('theme-not-found')); diff --git a/src/routes/debug.js b/src/routes/debug.js index 59ec743c00..2ec3f23934 100644 --- a/src/routes/debug.js +++ b/src/routes/debug.js @@ -7,9 +7,8 @@ var user = require('../user'); var categories = require('../categories'); var topics = require('../topics'); var posts = require('../posts'); -var db = require('../database'); -module.exports = function (app, middleware, controllers) { +module.exports = function (app) { var router = express.Router(); router.get('/uid/:uid', function (req, res) { diff --git a/src/routes/feeds.js b/src/routes/feeds.js index 357c7dcc7d..5e3d75c34d 100644 --- a/src/routes/feeds.js +++ b/src/routes/feeds.js @@ -13,7 +13,7 @@ var meta = require('../meta'); var helpers = require('../controllers/helpers'); var privileges = require('../privileges'); -module.exports = function (app, middleware, controllers) { +module.exports = function (app, middleware) { app.get('/topic/:topic_id.rss', middleware.maintenanceMode, generateForTopic); app.get('/category/:category_id.rss', middleware.maintenanceMode, generateForCategory); app.get('/recent.rss', middleware.maintenanceMode, generateForRecent); diff --git a/src/socket.io/blacklist.js b/src/socket.io/blacklist.js index a05d632f3f..8592a8b901 100644 --- a/src/socket.io/blacklist.js +++ b/src/socket.io/blacklist.js @@ -1,9 +1,6 @@ 'use strict'; -var async = require('async'); -var winston = require('winston'); - var user = require('../user'); var meta = require('../meta'); diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index 358ff4223f..5eb9ce61dd 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -1,8 +1,5 @@ - 'use strict'; -var async = require('async'); - var topics = require('../topics'); var websockets = require('./index'); var user = require('../user'); diff --git a/src/topics/fork.js b/src/topics/fork.js index 4765727d6f..396ae3d63b 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -2,9 +2,8 @@ 'use strict'; var async = require('async'); -var winston = require('winston'); + var db = require('../database'); -var user = require('../user'); var posts = require('../posts'); var privileges = require('../privileges'); var plugins = require('../plugins'); diff --git a/src/topics/user.js b/src/topics/user.js index 2ecefb5c53..d0a8d21426 100644 --- a/src/topics/user.js +++ b/src/topics/user.js @@ -1,10 +1,6 @@ - - 'use strict'; -var async = require('async'); var db = require('../database'); -var posts = require('../posts'); module.exports = function (Topics) { Topics.isOwner = function (tid, uid, callback) { diff --git a/src/user/bans.js b/src/user/bans.js index e98380a573..dc70d012dd 100644 --- a/src/user/bans.js +++ b/src/user/bans.js @@ -1,8 +1,8 @@ 'use strict'; var async = require('async'); + var db = require('../database'); -var plugins = require('../plugins'); module.exports = function (User) { User.ban = function (uid, until, reason, callback) { diff --git a/src/user/invite.js b/src/user/invite.js index 25cadc41bf..7e1b8c9866 100644 --- a/src/user/invite.js +++ b/src/user/invite.js @@ -134,7 +134,7 @@ module.exports = function (User) { db.setRemove('invitation:uid:' + invitedByUid, email, next); }, function deleteInviteKey(next) { - db.delete('invitation:email:' + email, callback); + db.delete('invitation:email:' + email, next); }, ], function (err) { next(err); diff --git a/test/.eslintrc b/test/.eslintrc index d17a3b4940..4dea92c4c9 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -1,5 +1,8 @@ { "env": { "mocha": true + }, + "rules": { + "no-unused-vars": "off" } } diff --git a/test/rewards.js b/test/rewards.js index 67a00fe911..965df4770f 100644 --- a/test/rewards.js +++ b/test/rewards.js @@ -31,10 +31,10 @@ describe('rewards', function () { async.series([ function (next) { - Groups.join('administrators', adminUid, done); + Groups.join('administrators', adminUid, next); }, function (next) { - Groups.join('rewardGroup', adminUid, done); + Groups.join('rewardGroup', adminUid, next); }, ], done); });