From fb363957d1ff8ac63c0a50aaeeb2dd86975876bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 18 Nov 2021 16:42:18 -0500 Subject: [PATCH] refactor: tab rules --- install/package.json | 2 +- public/src/admin/manage/privileges.js | 2 +- public/src/admin/manage/users.js | 6 +-- public/src/ajaxify.js | 2 +- public/src/app.js | 4 +- public/src/client/chats/search.js | 2 +- public/src/client/groups/details.js | 4 +- public/src/client/infinitescroll.js | 2 +- public/src/modules/chat.js | 2 +- public/src/modules/helpers.js | 2 +- public/src/modules/hooks.js | 8 ++-- public/src/modules/notifications.js | 2 +- public/src/modules/scrollStop.js | 2 +- public/src/utils.js | 2 +- src/api/posts.js | 2 +- src/api/topics.js | 2 +- src/categories/create.js | 2 +- src/categories/index.js | 2 +- src/categories/recentreplies.js | 2 +- src/cli/index.js | 2 +- src/cli/upgrade-plugins.js | 2 +- src/controllers/accounts/helpers.js | 2 +- src/controllers/accounts/settings.js | 6 +-- src/controllers/admin/dashboard.js | 2 +- src/controllers/admin/events.js | 4 +- src/controllers/admin/privileges.js | 2 +- src/controllers/authentication.js | 10 ++-- src/controllers/mods.js | 2 +- src/controllers/write/topics.js | 6 +-- src/database/mongo/sorted/union.js | 2 +- src/database/postgres/main.js | 2 +- src/flags.js | 14 +++--- src/groups/invite.js | 2 +- src/groups/search.js | 2 +- src/messaging/notifications.js | 2 +- src/meta/blacklist.js | 10 ++-- src/meta/errors.js | 2 +- src/meta/settings.js | 2 +- src/middleware/user.js | 2 +- src/notifications.js | 2 +- src/plugins/hooks.js | 4 +- src/posts/queue.js | 2 +- src/posts/votes.js | 2 +- src/routes/authentication.js | 4 +- src/routes/index.js | 2 +- src/routes/write/files.js | 6 +-- src/routes/write/flags.js | 2 +- src/routes/write/topics.js | 2 +- src/socket.io/flags.js | 2 +- src/socket.io/posts/tools.js | 2 +- src/topics/unread.js | 4 +- .../1.6.0/clear-stale-digest-template.js | 6 +-- src/user/auth.js | 2 +- src/user/email.js | 6 +-- src/user/index.js | 6 +-- src/user/interstitials.js | 4 +- src/user/reset.js | 2 +- src/webserver.js | 2 +- test/api.js | 20 ++++---- test/groups.js | 2 +- test/i18n.js | 2 +- test/messaging.js | 10 ++-- test/meta.js | 6 +-- test/posts.js | 2 +- test/socket.io.js | 2 +- test/topics/thumbs.js | 4 +- test/uploads.js | 48 ------------------- test/user.js | 14 +++--- test/utils.js | 1 + 69 files changed, 128 insertions(+), 175 deletions(-) diff --git a/install/package.json b/install/package.json index fa778e8d2c..fd5979b8e0 100644 --- a/install/package.json +++ b/install/package.json @@ -146,7 +146,7 @@ "@commitlint/config-angular": "14.1.0", "coveralls": "3.1.1", "eslint": "7.32.0", - "eslint-config-nodebb": "0.0.3", + "eslint-config-nodebb": "0.1.1", "eslint-plugin-import": "2.25.3", "grunt": "1.4.1", "grunt-contrib-watch": "1.1.0", diff --git a/public/src/admin/manage/privileges.js b/public/src/admin/manage/privileges.js index afb9c45a6b..89d771a1b1 100644 --- a/public/src/admin/manage/privileges.js +++ b/public/src/admin/manage/privileges.js @@ -84,7 +84,7 @@ define('admin/manage/privileges', [ Privileges.exposeAssumedPrivileges(); checkboxRowSelector.updateAll(); - Privileges.addEvents(); // events with confirmation modals + Privileges.addEvents(); // events with confirmation modals }; Privileges.addEvents = function () { diff --git a/public/src/admin/manage/users.js b/public/src/admin/manage/users.js index 7c6543fa75..5eb6615620 100644 --- a/public/src/admin/manage/users.js +++ b/public/src/admin/manage/users.js @@ -145,7 +145,7 @@ define('admin/manage/users', [ const uids = getSelectedUids(); if (!uids.length) { app.alertError('[[error:no-users-selected]]'); - return false; // specifically to keep the menu open + return false; // specifically to keep the menu open } bootbox.confirm((uids.length > 1 ? '[[admin/manage/users:alerts.confirm-ban-multi]]' : '[[admin/manage/users:alerts.confirm-ban]]'), function (confirm) { @@ -163,7 +163,7 @@ define('admin/manage/users', [ const uids = getSelectedUids(); if (!uids.length) { app.alertError('[[error:no-users-selected]]'); - return false; // specifically to keep the menu open + return false; // specifically to keep the menu open } Benchpress.render('admin/partials/temporary-ban', {}).then(function (html) { @@ -207,7 +207,7 @@ define('admin/manage/users', [ const uids = getSelectedUids(); if (!uids.length) { app.alertError('[[error:no-users-selected]]'); - return false; // specifically to keep the menu open + return false; // specifically to keep the menu open } Promise.all(uids.map(function (uid) { diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index d42a0b89d1..300d633635 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -536,7 +536,7 @@ $(document).ready(function () { } // eslint-disable-next-line no-script-url - if (hrefEmpty(this.href) || this.protocol === 'javascript:' || href === '#' || href === '') { + if (hrefEmpty(this.href) || this.protocol === 'javascript:' || href === '#' || href === '') { return e.preventDefault(); } diff --git a/public/src/app.js b/public/src/app.js index 68cfd9024f..4ea7d4ff21 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -37,7 +37,7 @@ app.flags = {}; * e.g. New Topic/Reply, post tools */ if (document.body) { - let earlyQueue = []; // once we can ES6, use Set instead + let earlyQueue = []; // once we can ES6, use Set instead const earlyClick = function (ev) { let btnEl = ev.target.closest('button'); const anchorEl = ev.target.closest('a'); @@ -114,7 +114,7 @@ app.flags = {}; }); }; - app.require = async (modules) => { // allows you to await require.js modules + app.require = async (modules) => { // allows you to await require.js modules const single = !Array.isArray(modules); if (single) { modules = [modules]; diff --git a/public/src/client/chats/search.js b/public/src/client/chats/search.js index fac37f908e..6467b60009 100644 --- a/public/src/client/chats/search.js +++ b/public/src/client/chats/search.js @@ -45,7 +45,7 @@ define('forum/chats/search', ['components', 'api'], function (components, api) { function displayUser(chatsListEl, userObj) { function createUserImage() { return (userObj.picture ? - '' : + '' : '
' + userObj['icon:text'] + '
') + ' ' + userObj.username; } diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index b0ed482c0c..d4583d0c48 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -102,7 +102,7 @@ define('forum/groups/details', [ Details.deleteGroup(); break; - case 'join': // intentional fall-throughs! + case 'join': // intentional fall-throughs! api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh()).catch(app.alertError); break; @@ -111,7 +111,7 @@ define('forum/groups/details', [ break; // TODO (14/10/2020): rewrite these to use api module and merge with above 2 case blocks - case 'accept': // intentional fall-throughs! + case 'accept': // intentional fall-throughs! case 'reject': case 'issueInvite': case 'rescindInvite': diff --git a/public/src/client/infinitescroll.js b/public/src/client/infinitescroll.js index e734cf455e..20eb4fc592 100644 --- a/public/src/client/infinitescroll.js +++ b/public/src/client/infinitescroll.js @@ -5,7 +5,7 @@ define('forum/infinitescroll', ['hooks'], function (hooks) { const scroll = {}; let callback; let previousScrollTop = 0; - let loadingMore = false; + let loadingMore = false; let container; let scrollTimeout = 0; diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index d57386040a..6a4b0e0fbc 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -1,7 +1,7 @@ 'use strict'; define('chat', [ - 'components', 'taskbar', 'translator', 'hooks', 'bootbox', + 'components', 'taskbar', 'translator', 'hooks', 'bootbox', ], function (components, taskbar, translator, hooks, bootbox) { const module = {}; let newMessage = false; diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index 4ec6763e94..a73c251100 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -285,7 +285,7 @@ case 'iPad': icons += ''; break; - case 'iPod': // intentional fall-through + case 'iPod': // intentional fall-through case 'iPhone': icons += ''; break; diff --git a/public/src/modules/hooks.js b/public/src/modules/hooks.js index f324bc706e..f6c2cbe971 100644 --- a/public/src/modules/hooks.js +++ b/public/src/modules/hooks.js @@ -6,10 +6,10 @@ define('hooks', [], () => { temporary: new Set(), runOnce: new Set(), deprecated: { - 'action:script.load': 'filter:script.load', // 👋 @ 1.18.0 - 'action:category.loaded': 'action:topics.loaded', // 👋 @ 1.19.0 - 'action:category.loading': 'action:topics.loading', // 👋 @ 1.19.0 - 'action:composer.check': 'filter:composer.check', // 👋 @ 1.19.0 + 'action:script.load': 'filter:script.load', // 👋 @ 1.18.0 + 'action:category.loaded': 'action:topics.loaded', // 👋 @ 1.19.0 + 'action:category.loading': 'action:topics.loading', // 👋 @ 1.19.0 + 'action:composer.check': 'filter:composer.check', // 👋 @ 1.19.0 }, }; diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js index cb8ed86b6b..5dc46daecc 100644 --- a/public/src/modules/notifications.js +++ b/public/src/modules/notifications.js @@ -142,7 +142,7 @@ define('notifications', [ Tinycon.setBubble(count > 99 ? '99+' : count); } - if (navigator.setAppBadge) { // feature detection + if (navigator.setAppBadge) { // feature detection navigator.setAppBadge(count); } }; diff --git a/public/src/modules/scrollStop.js b/public/src/modules/scrollStop.js index c6134feefa..497a099f71 100644 --- a/public/src/modules/scrollStop.js +++ b/public/src/modules/scrollStop.js @@ -20,7 +20,7 @@ define('scrollStop', function () { if ( (e.originalEvent.deltaY < 0 && scrollTop === 0) || // scroll up - (e.originalEvent.deltaY > 0 && (elementHeight + scrollTop) >= scrollHeight) // scroll down + (e.originalEvent.deltaY > 0 && (elementHeight + scrollTop) >= scrollHeight) // scroll down ) { return false; } diff --git a/public/src/utils.js b/public/src/utils.js index 684dd6b3ea..67c71d3243 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -737,7 +737,7 @@ }, isInternalURI: function (targetLocation, referenceLocation, relative_path) { - return targetLocation.host === '' || // Relative paths are always internal links + return targetLocation.host === '' || // Relative paths are always internal links ( targetLocation.host === referenceLocation.host && // Otherwise need to check if protocol and host match diff --git a/src/api/posts.js b/src/api/posts.js index 3cc62f2383..a49e6eb9ed 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -94,7 +94,7 @@ postsAPI.edit = async function (caller, data) { ]); const uids = _.uniq(_.flatten(memberData).concat(String(caller.uid))); - uids.forEach(uid => websockets.in(`uid_${uid}`).emit('event:post_edited', editResult)); + uids.forEach(uid => websockets.in(`uid_${uid}`).emit('event:post_edited', editResult)); return returnData; }; diff --git a/src/api/topics.js b/src/api/topics.js index 4925a62c7e..75a902f39f 100644 --- a/src/api/topics.js +++ b/src/api/topics.js @@ -71,7 +71,7 @@ topicsAPI.reply = async function (caller, data) { return queueObj; } - const postData = await topics.reply(payload); // postData seems to be a subset of postObj, refactor? + const postData = await topics.reply(payload); // postData seems to be a subset of postObj, refactor? const postObj = await posts.getPostSummaryByPids([postData.pid], caller.uid, {}); const result = { diff --git a/src/categories/create.js b/src/categories/create.js index c72fce2bd4..805583b74f 100644 --- a/src/categories/create.js +++ b/src/categories/create.js @@ -21,7 +21,7 @@ module.exports = function (Categories) { data.name = String(data.name || `Category ${cid}`); const slug = `${cid}/${slugify(data.name)}`; const smallestOrder = firstChild.length ? firstChild[0].score - 1 : 1; - const order = data.order || smallestOrder; // If no order provided, place it at the top + const order = data.order || smallestOrder; // If no order provided, place it at the top const colours = Categories.assignColours(); let category = { diff --git a/src/categories/index.js b/src/categories/index.js index b5ae7cf056..5789c25e37 100644 --- a/src/categories/index.js +++ b/src/categories/index.js @@ -392,7 +392,7 @@ Categories.buildForSelectCategories = function (categories, fields, parentCid) { rootCategories.forEach(category => recursive(category, categoriesData, '', 0)); const pickFields = [ - 'cid', 'name', 'level', 'icon', 'parentCid', + 'cid', 'name', 'level', 'icon', 'parentCid', 'color', 'bgColor', 'backgroundImage', 'imageClass', ]; fields = fields || []; diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.js index c1d1a540eb..935ef80642 100644 --- a/src/categories/recentreplies.js +++ b/src/categories/recentreplies.js @@ -153,7 +153,7 @@ module.exports = function (Categories) { function getPostsRecursive(category, posts) { if (Array.isArray(category.posts)) { - category.posts.forEach(p => posts.push(p)); + category.posts.forEach(p => posts.push(p)); } category.children.forEach(child => getPostsRecursive(child, posts)); diff --git a/src/cli/index.js b/src/cli/index.js index b7ef494f36..409b429502 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -100,7 +100,7 @@ nconf.argv(opts).env({ prestart.setupWinston(); // Alternate configuration file support -const configFile = path.resolve(paths.baseDir, nconf.get('config') || 'config.json'); +const configFile = path.resolve(paths.baseDir, nconf.get('config') || 'config.json'); const configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database')); prestart.loadConfig(configFile); diff --git a/src/cli/upgrade-plugins.js b/src/cli/upgrade-plugins.js index dfa2d38d0c..388e92bd54 100644 --- a/src/cli/upgrade-plugins.js +++ b/src/cli/upgrade-plugins.js @@ -97,7 +97,7 @@ async function checkPlugins() { const toCheck = Object.keys(plugins); if (!toCheck.length) { process.stdout.write(' OK'.green + ''.reset); - return []; // no extraneous plugins installed + return []; // no extraneous plugins installed } const suggestedModules = await getSuggestedModules(nbbVersion, toCheck); process.stdout.write(' OK'.green + ''.reset); diff --git a/src/controllers/accounts/helpers.js b/src/controllers/accounts/helpers.js index 21e3e16908..e0462ea2e8 100644 --- a/src/controllers/accounts/helpers.js +++ b/src/controllers/accounts/helpers.js @@ -78,7 +78,7 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID, query = {}) userData.isSelf = isSelf; userData.isFollowing = results.isFollowing; userData.hasPrivateChat = results.hasPrivateChat; - userData.showHidden = results.canEdit; // remove in v1.19.0 + userData.showHidden = results.canEdit; // remove in v1.19.0 userData.groups = Array.isArray(results.groups) && results.groups.length ? results.groups[0] : []; userData.disableSignatures = meta.config.disableSignatures === 1; userData['reputation:disabled'] = meta.config['reputation:disabled'] === 1; diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js index cc79c10880..1331b79d95 100644 --- a/src/controllers/accounts/settings.js +++ b/src/controllers/accounts/settings.js @@ -60,17 +60,17 @@ settingsController.get = async function (req, res, next) { userData.bootswatchSkinOptions = [ { name: 'Default', value: '' }, { name: 'Cerulean', value: 'cerulean' }, - { name: 'Cosmo', value: 'cosmo' }, + { name: 'Cosmo', value: 'cosmo' }, { name: 'Cyborg', value: 'cyborg' }, { name: 'Darkly', value: 'darkly' }, { name: 'Flatly', value: 'flatly' }, - { name: 'Journal', value: 'journal' }, + { name: 'Journal', value: 'journal' }, { name: 'Lumen', value: 'lumen' }, { name: 'Paper', value: 'paper' }, { name: 'Readable', value: 'readable' }, { name: 'Sandstone', value: 'sandstone' }, { name: 'Simplex', value: 'simplex' }, - { name: 'Slate', value: 'slate' }, + { name: 'Slate', value: 'slate' }, { name: 'Spacelab', value: 'spacelab' }, { name: 'Superhero', value: 'superhero' }, { name: 'United', value: 'united' }, diff --git a/src/controllers/admin/dashboard.js b/src/controllers/admin/dashboard.js index d16d2dbaa6..ac9f4fc130 100644 --- a/src/controllers/admin/dashboard.js +++ b/src/controllers/admin/dashboard.js @@ -188,7 +188,7 @@ async function getStatsFromAnalytics(set, field) { today: data.slice(-1)[0], lastweek: sum(data.slice(-14)), thisweek: sum(data.slice(-7)), - lastmonth: sum(data.slice(0)), // entire set + lastmonth: sum(data.slice(0)), // entire set thismonth: sum(data.slice(-30)), alltime: await getGlobalField(field), }; diff --git a/src/controllers/admin/events.js b/src/controllers/admin/events.js index f077972aca..3d59892090 100644 --- a/src/controllers/admin/events.js +++ b/src/controllers/admin/events.js @@ -15,8 +15,8 @@ eventsController.get = async function (req, res) { // Limit by date let from = req.query.start ? new Date(req.query.start) || undefined : undefined; let to = req.query.end ? new Date(req.query.end) || undefined : new Date(); - from = from && from.setHours(0, 0, 0, 0); // setHours returns a unix timestamp (Number, not Date) - to = to && to.setHours(23, 59, 59, 999); // setHours returns a unix timestamp (Number, not Date) + from = from && from.setHours(0, 0, 0, 0); // setHours returns a unix timestamp (Number, not Date) + to = to && to.setHours(23, 59, 59, 999); // setHours returns a unix timestamp (Number, not Date) const currentFilter = req.query.type || ''; diff --git a/src/controllers/admin/privileges.js b/src/controllers/admin/privileges.js index c3ab23b9d6..28833b5562 100644 --- a/src/controllers/admin/privileges.js +++ b/src/controllers/admin/privileges.js @@ -21,7 +21,7 @@ privilegesController.get = async function (req, res) { name: '[[admin/manage/privileges:global]]', icon: 'fa-list', }, { - cid: 'admin', // what do? + cid: 'admin', name: '[[admin/manage/privileges:admin]]', icon: 'fa-lock', }]; diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index e970f895cd..4afd54fb84 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -106,7 +106,7 @@ authenticationController.register = async function (req, res) { user.isPasswordValid(userData.password); - res.locals.processLogin = true; // set it to false in plugin if you wish to just register only + res.locals.processLogin = true; // set it to false in plugin if you wish to just register only await plugins.hooks.fire('filter:register.check', { req: req, res: res, userData: userData }); const data = await registerAndLoginUser(req, res, userData); @@ -151,7 +151,7 @@ authenticationController.registerComplete = async function (req, res) { req.body.files = req.files; if ( (cur.callback.constructor && cur.callback.constructor.name === 'AsyncFunction') || - cur.callback.length === 2 // non-async function w/o callback + cur.callback.length === 2 // non-async function w/o callback ) { memo.push(cur.callback); } else { @@ -187,7 +187,7 @@ authenticationController.registerComplete = async function (req, res) { if (req.session.registration.register === true) { res.locals.processLogin = true; - req.body.noscript = 'true'; // trigger full page load on error + req.body.noscript = 'true'; // trigger full page load on error const data = await registerAndLoginUser(req, res, req.session.registration); if (!data) { @@ -388,7 +388,9 @@ authenticationController.onSuccessfulLogin = async function (req, uid) { version: req.useragent.version, }); await Promise.all([ - new Promise(resolve => req.session.save(resolve)), + new Promise((resolve) => { + req.session.save(resolve); + }), user.auth.addSession(uid, req.sessionID), user.updateLastOnlineTime(uid), user.updateOnlineUsers(uid), diff --git a/src/controllers/mods.js b/src/controllers/mods.js index be875eda76..e058a6a99f 100644 --- a/src/controllers/mods.js +++ b/src/controllers/mods.js @@ -114,7 +114,7 @@ modsController.flags.detail = async function (req, res, next) { results.privileges = { ...results.privileges[0], ...results.privileges[1] }; if (!results.flagData || (!(results.isAdminOrGlobalMod || !!results.moderatedCids.length))) { - return next(); // 404 + return next(); // 404 } if (results.flagData.type === 'user') { diff --git a/src/controllers/write/topics.js b/src/controllers/write/topics.js index 1a6b8a342f..d0f860680f 100644 --- a/src/controllers/write/topics.js +++ b/src/controllers/write/topics.js @@ -50,7 +50,7 @@ Topics.pin = async (req, res) => { if (req.body.expiry) { await topics.tools.setPinExpiry(req.params.tid, req.body.expiry, req.uid); } - await api.topics.pin(req, { tids: [req.params.tid] }); + await api.topics.pin(req, { tids: [req.params.tid] }); helpers.formatApiResponse(200, res); }; @@ -107,7 +107,7 @@ Topics.deleteTags = async (req, res) => { }; Topics.getThumbs = async (req, res) => { - if (isFinite(req.params.tid)) { // post_uuids can be passed in occasionally, in that case no checks are necessary + if (isFinite(req.params.tid)) { // post_uuids can be passed in occasionally, in that case no checks are necessary const [exists, canRead] = await Promise.all([ topics.exists(req.params.tid), privileges.topics.can('topics:read', req.params.tid, req.uid), @@ -126,7 +126,7 @@ Topics.addThumb = async (req, res) => { return; } - const files = await uploadsController.uploadThumb(req, res); // response is handled here + const files = await uploadsController.uploadThumb(req, res); // response is handled here // Add uploaded files to topic zset if (files && files.length) { diff --git a/src/database/mongo/sorted/union.js b/src/database/mongo/sorted/union.js index 86f86683f3..ea4ad4d8e1 100644 --- a/src/database/mongo/sorted/union.js +++ b/src/database/mongo/sorted/union.js @@ -58,7 +58,7 @@ module.exports = function (module) { if (params.withScores) { project.score = '$totalScore'; } - pipeline.push({ $project: project }); + pipeline.push({ $project: project }); let data = await module.client.collection('objects').aggregate(pipeline).toArray(); if (!params.withScores) { diff --git a/src/database/postgres/main.js b/src/database/postgres/main.js index 5e6ba43e61..a3f784960a 100644 --- a/src/database/postgres/main.js +++ b/src/database/postgres/main.js @@ -28,7 +28,7 @@ module.exports = function (module) { }); return key.map(k => res.rows.some(r => r.k === k)); } - const res = await module.pool.query({ + const res = await module.pool.query({ name: 'exists', text: ` SELECT EXISTS(SELECT * diff --git a/src/flags.js b/src/flags.js index e071bf6fa9..0afa88ef34 100644 --- a/src/flags.js +++ b/src/flags.js @@ -64,8 +64,8 @@ Flags.init = async function () { cid: function (sets, orSets, key) { prepareSets(sets, orSets, 'flags:byCid:', key); }, - page: function () { /* noop */ }, - perPage: function () { /* noop */ }, + page: function () { /* noop */ }, + perPage: function () { /* noop */ }, quick: function (sets, orSets, key, uid) { switch (key) { case 'mine': @@ -141,7 +141,7 @@ Flags.getFlagIdsWithFilters = async function ({ filters, uid, query }) { winston.warn(`[flags/list] No flag filter type found: ${type}`); } } - sets = (sets.length || orSets.length) ? sets : ['flags:datetime']; // No filter default + sets = (sets.length || orSets.length) ? sets : ['flags:datetime']; // No filter default let flagIds = []; if (sets.length === 1) { @@ -244,7 +244,7 @@ Flags.sort = async function (flagIds, sort) { break; } - case 'upvotes': // fall-through + case 'upvotes': // fall-through case 'downvotes': case 'replies': { flagIds = await filterPosts(flagIds); @@ -426,8 +426,8 @@ Flags.create = async function (type, id, uid, reason, timestamp) { }), Flags.addReport(flagId, type, id, uid, reason, timestamp), db.sortedSetAdd('flags:datetime', timestamp, flagId), // by time, the default - db.sortedSetAdd(`flags:byType:${type}`, timestamp, flagId), // by flag type - db.sortedSetIncrBy('flags:byTarget', 1, [type, id].join(':')), // by flag target (score is count) + db.sortedSetAdd(`flags:byType:${type}`, timestamp, flagId), // by flag type + db.sortedSetIncrBy('flags:byTarget', 1, [type, id].join(':')), // by flag target (score is count) analytics.increment('flags') // some fancy analytics ); @@ -441,7 +441,7 @@ Flags.create = async function (type, id, uid, reason, timestamp) { if (type === 'post') { batched.push( - db.sortedSetAdd(`flags:byPid:${id}`, timestamp, flagId), // by target pid + db.sortedSetAdd(`flags:byPid:${id}`, timestamp, flagId), // by target pid posts.setPostField(id, 'flagId', flagId) ); diff --git a/src/groups/invite.js b/src/groups/invite.js index 784f0f560b..74b7453c4e 100644 --- a/src/groups/invite.js +++ b/src/groups/invite.js @@ -45,7 +45,7 @@ module.exports = function (Groups) { groupNames = [groupNames]; } const sets = []; - groupNames.forEach(groupName => sets.push(`group:${groupName}:pending`, `group:${groupName}:invited`)); + groupNames.forEach(groupName => sets.push(`group:${groupName}:pending`, `group:${groupName}:invited`)); await db.setsRemove(sets, uid); }; diff --git a/src/groups/search.js b/src/groups/search.js index 4bec5085af..9b6b15d5a4 100644 --- a/src/groups/search.js +++ b/src/groups/search.js @@ -42,7 +42,7 @@ module.exports = function (Groups) { groups.sort((a, b) => b.createtime - a.createtime); break; - case 'alpha': // intentional fall-through + case 'alpha': // intentional fall-through default: groups.sort((a, b) => (a.slug > b.slug ? 1 : -1)); } diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js index 895138c7e8..bd03f2dd48 100644 --- a/src/messaging/notifications.js +++ b/src/messaging/notifications.js @@ -7,7 +7,7 @@ const plugins = require('../plugins'); const meta = require('../meta'); module.exports = function (Messaging) { - Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser + Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser Messaging.notifyUsersInRoom = async (fromUid, roomId, messageObj) => { let uids = await Messaging.getUidsInRoom(roomId, 0, -1); diff --git a/src/meta/blacklist.js b/src/meta/blacklist.js index 8fd15bd5be..8e3bc7b1f7 100644 --- a/src/meta/blacklist.js +++ b/src/meta/blacklist.js @@ -45,8 +45,8 @@ Blacklist.get = async function () { Blacklist.test = async function (clientIp) { // Some handy test addresses - // clientIp = '2001:db8:85a3:0:0:8a2e:370:7334'; // IPv6 - // clientIp = '127.0.15.1'; // IPv4 + // clientIp = '2001:db8:85a3:0:0:8a2e:370:7334'; // IPv6 + // clientIp = '127.0.15.1'; // IPv4 // clientIp = '127.0.15.1:3443'; // IPv4 with port strip port to not fail if (!clientIp) { return; @@ -62,15 +62,15 @@ Blacklist.test = async function (clientIp) { } if ( - !Blacklist._rules.ipv4.includes(clientIp) && // not explicitly specified in ipv4 list - !Blacklist._rules.ipv6.includes(clientIp) && // not explicitly specified in ipv6 list + !Blacklist._rules.ipv4.includes(clientIp) && // not explicitly specified in ipv4 list + !Blacklist._rules.ipv6.includes(clientIp) && // not explicitly specified in ipv6 list !Blacklist._rules.cidr.some((subnet) => { const cidr = ipaddr.parseCIDR(subnet); if (addr.kind() !== cidr[0].kind()) { return false; } return addr.match(cidr); - }) // not in a blacklisted IPv4 or IPv6 cidr range + }) // not in a blacklisted IPv4 or IPv6 cidr range ) { try { // To return test failure, pass back an error in callback diff --git a/src/meta/errors.js b/src/meta/errors.js index 843051e310..1d2949c28a 100644 --- a/src/meta/errors.js +++ b/src/meta/errors.js @@ -37,7 +37,7 @@ Errors.log404 = function (route) { if (!route) { return; } - route = route.slice(0, 512).replace(/\/$/, ''); // remove trailing slashes + route = route.slice(0, 512).replace(/\/$/, ''); // remove trailing slashes analytics.increment('errors:404'); counters[route] = counters[route] || 0; counters[route] += 1; diff --git a/src/meta/settings.js b/src/meta/settings.js index 4ac548895f..1207d13734 100644 --- a/src/meta/settings.js +++ b/src/meta/settings.js @@ -94,7 +94,7 @@ Settings.set = async function (hash, values, quiet) { plugins.hooks.fire('action:settings.set', { plugin: hash, - settings: { ...values, ...sortedListData }, // Add back sorted list data to values hash + settings: { ...values, ...sortedListData }, // Add back sorted list data to values hash }); pubsub.publish(`action:settings.set.${hash}`, values); diff --git a/src/middleware/user.js b/src/middleware/user.js index b9f195477e..c70d4f21d9 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -73,7 +73,7 @@ module.exports = function (middleware) { await plugins.hooks.fire('response:middleware.authenticate', { req: req, res: res, - next: function () {}, // no-op for backwards compatibility + next: function () {}, // no-op for backwards compatibility }); if (!res.headersSent) { diff --git a/src/notifications.js b/src/notifications.js index 57dae2f635..6c9c01f46f 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -371,7 +371,7 @@ Notifications.merge = async function (notifications) { notifications = mergeIds.reduce((notifications, mergeId) => { const isolated = notifications.filter(n => n && n.hasOwnProperty('mergeId') && n.mergeId.split('|')[0] === mergeId); if (isolated.length <= 1) { - return notifications; // Nothing to merge + return notifications; // Nothing to merge } // Each isolated mergeId may have multiple differentiators, so process each separately diff --git a/src/plugins/hooks.js b/src/plugins/hooks.js index 050da0a628..108b4750ac 100644 --- a/src/plugins/hooks.js +++ b/src/plugins/hooks.js @@ -8,8 +8,8 @@ const utils = require('../utils'); const Hooks = module.exports; Hooks.deprecatedHooks = { - 'filter:email.send': 'static:email.send', // 👋 @ 1.19.0 - 'filter:router.page': 'response:router.page', // 👋 @ 2.0.0 + 'filter:email.send': 'static:email.send', // 👋 @ 1.19.0 + 'filter:router.page': 'response:router.page', // 👋 @ 2.0.0 }; Hooks.internals = { diff --git a/src/posts/queue.js b/src/posts/queue.js index 33a64e14be..7e5790e166 100644 --- a/src/posts/queue.js +++ b/src/posts/queue.js @@ -19,7 +19,7 @@ const socketHelpers = require('../socket.io/helpers'); module.exports = function (Posts) { Posts.getQueuedPosts = async (filter = {}, options = {}) => { - options = { metadata: true, ...options }; // defaults + options = { metadata: true, ...options }; // defaults let postData = _.cloneDeep(cache.get('post-queue')); if (!postData) { const ids = await db.getSortedSetRange('post:queue', 0, -1); diff --git a/src/posts/votes.js b/src/posts/votes.js index c4d976a1ee..8f3f240314 100644 --- a/src/posts/votes.js +++ b/src/posts/votes.js @@ -206,7 +206,7 @@ module.exports = function (Posts) { let current = voteStatus.upvoted ? 'upvote' : 'downvote'; if (unvote) { // e.g. unvoting, removing a upvote or downvote hook = 'unvote'; - } else { // e.g. User *has not* voted, clicks upvote or downvote + } else { // e.g. User *has not* voted, clicks upvote or downvote current = 'unvote'; } // action:post.upvote diff --git a/src/routes/authentication.js b/src/routes/authentication.js index 6d7a36e037..b2b4f0bf6d 100644 --- a/src/routes/authentication.js +++ b/src/routes/authentication.js @@ -137,9 +137,7 @@ Auth.reloadRoutes = async function (params) { res.locals.strategy = strategy; next(); })(req, res, next); - }, - Auth.middleware.validateAuth, - (req, res, next) => { + }, Auth.middleware.validateAuth, (req, res, next) => { async.waterfall([ async.apply(req.login.bind(req), res.locals.user), async.apply(controllers.authentication.onSuccessfulLogin, req, req.uid), diff --git a/src/routes/index.js b/src/routes/index.js index 076c7c36b2..402384b0d3 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -203,7 +203,7 @@ function addRemountableRoutes(app, router, middleware, mounts) { const original = mount; mount = mounts[original]; - if (!mount) { // do not mount at all + if (!mount) { // do not mount at all winston.warn(`[router] Not mounting /${original}`); return; } diff --git a/src/routes/write/files.js b/src/routes/write/files.js index 97ddde6d01..873144870c 100644 --- a/src/routes/write/files.js +++ b/src/routes/write/files.js @@ -11,9 +11,9 @@ module.exports = function () { const middlewares = [middleware.ensureLoggedIn, middleware.admin.checkPrivileges]; // setupApiRoute(router, 'put', '/', [ - // ...middlewares, - // middleware.checkRequired.bind(null, ['path']), - // middleware.assert.folder + // ...middlewares, + // middleware.checkRequired.bind(null, ['path']), + // middleware.assert.folder // ], controllers.write.files.upload); setupApiRoute(router, 'delete', '/', [ ...middlewares, diff --git a/src/routes/write/flags.js b/src/routes/write/flags.js index 783fa177d4..c713b24dfa 100644 --- a/src/routes/write/flags.js +++ b/src/routes/write/flags.js @@ -11,7 +11,7 @@ module.exports = function () { const middlewares = [middleware.ensureLoggedIn]; setupApiRoute(router, 'post', '/', [...middlewares], controllers.write.flags.create); - // setupApiRoute(router, 'delete', ...); // does not exist + // setupApiRoute(router, 'delete', ...); // does not exist setupApiRoute(router, 'get', '/:flagId', [...middlewares, middleware.assert.flag], controllers.write.flags.get); setupApiRoute(router, 'put', '/:flagId', [...middlewares, middleware.assert.flag], controllers.write.flags.update); diff --git a/src/routes/write/topics.js b/src/routes/write/topics.js index b62124f95b..3a0c7c306e 100644 --- a/src/routes/write/topics.js +++ b/src/routes/write/topics.js @@ -30,7 +30,7 @@ module.exports = function () { setupApiRoute(router, 'put', '/:tid/follow', [...middlewares, middleware.assert.topic], controllers.write.topics.follow); setupApiRoute(router, 'delete', '/:tid/follow', [...middlewares, middleware.assert.topic], controllers.write.topics.unfollow); setupApiRoute(router, 'put', '/:tid/ignore', [...middlewares, middleware.assert.topic], controllers.write.topics.ignore); - setupApiRoute(router, 'delete', '/:tid/ignore', [...middlewares, middleware.assert.topic], controllers.write.topics.unfollow); // intentional, unignore == unfollow + setupApiRoute(router, 'delete', '/:tid/ignore', [...middlewares, middleware.assert.topic], controllers.write.topics.unfollow); // intentional, unignore == unfollow setupApiRoute(router, 'put', '/:tid/tags', [...middlewares, middleware.checkRequired.bind(null, ['tags']), middleware.assert.topic], controllers.write.topics.addTags); setupApiRoute(router, 'delete', '/:tid/tags', [...middlewares, middleware.assert.topic], controllers.write.topics.deleteTags); diff --git a/src/socket.io/flags.js b/src/socket.io/flags.js index ee8bc9ac05..7992aa8541 100644 --- a/src/socket.io/flags.js +++ b/src/socket.io/flags.js @@ -15,7 +15,7 @@ SocketFlags.create = async function (socket, data) { SocketFlags.update = async function (socket, data) { sockets.warnDeprecated(socket, 'PUT /api/v3/flags/:flagId'); - if (!data || !(data.flagId && data.data)) { // check only req'd in socket.io + if (!data || !(data.flagId && data.data)) { // check only req'd in socket.io throw new Error('[[error:invalid-data]]'); } diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js index 7128cfa7d6..e9908a919d 100644 --- a/src/socket.io/posts/tools.js +++ b/src/socket.io/posts/tools.js @@ -28,7 +28,7 @@ module.exports = function (SocketPosts) { canDelete: privileges.posts.canDelete(data.pid, socket.uid), canPurge: privileges.posts.canPurge(data.pid, socket.uid), canFlag: privileges.posts.canFlag(data.pid, socket.uid), - flagged: flags.exists('post', data.pid, socket.uid), // specifically, whether THIS calling user flagged + flagged: flags.exists('post', data.pid, socket.uid), // specifically, whether THIS calling user flagged bookmarked: posts.hasBookmarked(data.pid, socket.uid), postSharing: social.getActivePostSharing(), history: posts.diffs.exists(data.pid), diff --git a/src/topics/unread.js b/src/topics/unread.js index 6627fc8074..f0ab2a5c36 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -84,8 +84,8 @@ module.exports = function (Topics) { }; async function getTids(params) { - const counts = { '': 0, new: 0, watched: 0, unreplied: 0 }; - const tidsByFilter = { '': [], new: [], watched: [], unreplied: [] }; + const counts = { '': 0, new: 0, watched: 0, unreplied: 0 }; + const tidsByFilter = { '': [], new: [], watched: [], unreplied: [] }; if (params.uid <= 0) { return { counts: counts, tids: [], tidsByFilter: tidsByFilter }; diff --git a/src/upgrades/1.6.0/clear-stale-digest-template.js b/src/upgrades/1.6.0/clear-stale-digest-template.js index 3bcd11b49c..0eabe804f6 100644 --- a/src/upgrades/1.6.0/clear-stale-digest-template.js +++ b/src/upgrades/1.6.0/clear-stale-digest-template.js @@ -8,9 +8,9 @@ module.exports = { timestamp: Date.UTC(2017, 8, 6), method: async function () { const matches = [ - '112e541b40023d6530dd44df4b0d9c5d', // digest @ 75917e25b3b5ad7bed8ed0c36433fb35c9ab33eb - '110b8805f70395b0282fd10555059e9f', // digest @ 9b02bb8f51f0e47c6e335578f776ffc17bc03537 - '9538e7249edb369b2a25b03f2bd3282b', // digest @ 3314ab4b83138c7ae579ac1f1f463098b8c2d414 + '112e541b40023d6530dd44df4b0d9c5d', // digest @ 75917e25b3b5ad7bed8ed0c36433fb35c9ab33eb + '110b8805f70395b0282fd10555059e9f', // digest @ 9b02bb8f51f0e47c6e335578f776ffc17bc03537 + '9538e7249edb369b2a25b03f2bd3282b', // digest @ 3314ab4b83138c7ae579ac1f1f463098b8c2d414 ]; const fieldset = await meta.configs.getFields(['email:custom:digest']); const hash = fieldset['email:custom:digest'] ? crypto.createHash('md5').update(fieldset['email:custom:digest']).digest('hex') : null; diff --git a/src/user/auth.js b/src/user/auth.js index 9e4738514a..d8113547e6 100644 --- a/src/user/auth.js +++ b/src/user/auth.js @@ -95,7 +95,7 @@ module.exports = function (User) { const sid = uuidMapping[uuid]; const sessionObj = await getSessionFromStore(sid); const expired = !sessionObj || !sessionObj.hasOwnProperty('passport') || - !sessionObj.passport.hasOwnProperty('user') || + !sessionObj.passport.hasOwnProperty('user') || parseInt(sessionObj.passport.user, 10) !== parseInt(uid, 10); if (expired) { expiredUUIDs.push(uuid); diff --git a/src/user/email.js b/src/user/email.js index a97aa1f38f..251ebab944 100644 --- a/src/user/email.js +++ b/src/user/email.js @@ -65,9 +65,9 @@ UserEmail.expireValidation = async (uid) => { UserEmail.sendValidationEmail = async function (uid, options) { /* - * Options: - * - email, overrides email retrieval - * - force, sends email even if it is too soon to send another + * Options: + * - email, overrides email retrieval + * - force, sends email even if it is too soon to send another */ if (meta.config.sendValidationEmail !== 1) { diff --git a/src/user/index.js b/src/user/index.js index 16096c892c..6a52886011 100644 --- a/src/user/index.js +++ b/src/user/index.js @@ -230,9 +230,9 @@ User.addInterstitials = function (callback) { plugins.hooks.register('core', { hook: 'filter:register.interstitial', method: [ - User.interstitials.email, // Email address (for password reset + digest) - User.interstitials.gdpr, // GDPR information collection/processing consent + email consent - User.interstitials.tou, // Forum Terms of Use + User.interstitials.email, // Email address (for password reset + digest) + User.interstitials.gdpr, // GDPR information collection/processing consent + email consent + User.interstitials.tou, // Forum Terms of Use ], }); diff --git a/src/user/interstitials.js b/src/user/interstitials.js index ac401127d1..101cdd01c8 100644 --- a/src/user/interstitials.js +++ b/src/user/interstitials.js @@ -36,7 +36,7 @@ Interstitials.email = async (data) => { uid: userData.uid, email: formData.email, registration: false, - allowed: true, // change this value to disallow + allowed: true, // change this value to disallow error: '[[error:invalid-email]]', }), ]); @@ -79,7 +79,7 @@ Interstitials.email = async (data) => { uid: null, email: formData.email, registration: true, - allowed: true, // change this value to disallow + allowed: true, // change this value to disallow error: '[[error:invalid-email]]', }); diff --git a/src/user/reset.js b/src/user/reset.js index b6e58e8206..3f83e3812c 100644 --- a/src/user/reset.js +++ b/src/user/reset.js @@ -91,7 +91,7 @@ UserReset.commit = async function (code, password) { // don't verify email if password reset is due to expiry const isPasswordExpired = userData.passwordExpiry && userData.passwordExpiry < Date.now(); if (!isPasswordExpired) { - data['email:confirmed'] = 1; + data['email:confirmed'] = 1; await groups.join('verified-users', uid); await groups.leave('unverified-users', uid); } diff --git a/src/webserver.js b/src/webserver.js index c246272b85..e75c59eb00 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -168,7 +168,7 @@ function setupExpressApp(app) { app.use((req, res, next) => { als.run({ uid: req.uid }, next); }); - app.use(middleware.autoLocale); // must be added after auth middlewares are added + app.use(middleware.autoLocale); // must be added after auth middlewares are added const toobusy = require('toobusy-js'); toobusy.maxLag(meta.config.eventLoopLagThreshold); diff --git a/test/api.js b/test/api.js index fa59ffeda7..f855e157aa 100644 --- a/test/api.js +++ b/test/api.js @@ -33,7 +33,7 @@ describe('API', async () => { let jar; let csrfToken; let setup = false; - const unauthenticatedRoutes = ['/api/login', '/api/register']; // Everything else will be called with the admin user + const unauthenticatedRoutes = ['/api/login', '/api/register']; // Everything else will be called with the admin user const mocks = { head: {}, @@ -73,19 +73,19 @@ describe('API', async () => { { in: 'path', name: 'uuid', - example: '', // to be defined below... + example: '', // to be defined below... }, ], '/posts/{pid}/diffs/{timestamp}': [ { in: 'path', name: 'pid', - example: '', // to be defined below... + example: '', // to be defined below... }, { in: 'path', name: 'timestamp', - example: '', // to be defined below... + example: '', // to be defined below... }, ], }, @@ -116,7 +116,7 @@ describe('API', async () => { for (let x = 0; x < 4; x++) { // eslint-disable-next-line no-await-in-loop - await user.create({ username: 'deleteme', password: '123456' }); // for testing of DELETE /users (uids 5, 6) and DELETE /user/:uid/account (uid 7) + await user.create({ username: 'deleteme', password: '123456' }); // for testing of DELETE /users (uids 5, 6) and DELETE /user/:uid/account (uid 7) } await groups.join('administrators', adminUid); @@ -299,7 +299,7 @@ describe('API', async () => { function generateTests(api, paths, prefix) { // Iterate through all documented paths, make a call to it, // and compare the result body with what is defined in the spec - const pathLib = path; // for calling path module from inside this forEach + const pathLib = path; // for calling path module from inside this forEach paths.forEach((path) => { const context = api.paths[path]; let schema; @@ -393,9 +393,9 @@ describe('API', async () => { method: method, jar: !unauthenticatedRoutes.includes(path) ? jar : undefined, json: true, - followRedirect: false, // all responses are significant (e.g. 302) - simple: false, // don't throw on non-200 (e.g. 302) - resolveWithFullResponse: true, // send full request back (to check statusCode) + followRedirect: false, // all responses are significant (e.g. 302) + simple: false, // don't throw on non-200 (e.g. 302) + resolveWithFullResponse: true, // send full request back (to check statusCode) headers: headers, qs: qs, body: body, @@ -572,7 +572,7 @@ describe('API', async () => { // Compare the response to the schema Object.keys(response).forEach((prop) => { - if (additionalProperties) { // All bets are off + if (additionalProperties) { // All bets are off return; } diff --git a/test/groups.js b/test/groups.js index 98aadadd98..3d8de2f57c 100644 --- a/test/groups.js +++ b/test/groups.js @@ -60,7 +60,7 @@ describe('Groups', () => { // Also create a hidden group await Groups.join('Hidden', 'Test'); // create another group that starts with test for search/sort - await Groups.create({ name: 'Test2', description: 'Foobar!' }); + await Groups.create({ name: 'Test2', description: 'Foobar!' }); testUid = await User.create({ username: 'testuser', diff --git a/test/i18n.js b/test/i18n.js index af066098f9..ed3a86e7ff 100644 --- a/test/i18n.js +++ b/test/i18n.js @@ -19,7 +19,7 @@ describe('i18n', () => { }); it('should contain folders named after the language code', async () => { - const valid = /(?:README.md|^[a-z]{2}(?:-[A-Z]{2})?$|^[a-z]{2}(?:-x-[a-z]+)?$)/; // good luck + const valid = /(?:README.md|^[a-z]{2}(?:-[A-Z]{2})?$|^[a-z]{2}(?:-x-[a-z]+)?$)/; // good luck folders.forEach((folder) => { assert(valid.test(folder)); diff --git a/test/messaging.js b/test/messaging.js index 996ad14bdb..83665b1dc0 100644 --- a/test/messaging.js +++ b/test/messaging.js @@ -17,17 +17,17 @@ const helpers = require('./helpers'); const socketModules = require('../src/socket.io/modules'); describe('Messaging Library', () => { - let fooUid; // the admin - let bazUid; // the user with chat restriction enabled + let fooUid; // the admin + let bazUid; // the user with chat restriction enabled let herpUid; let roomId; before((done) => { // Create 3 users: 1 admin, 2 regular async.series([ - async.apply(User.create, { username: 'foo', password: 'barbar' }), // admin - async.apply(User.create, { username: 'baz', password: 'quuxquux' }), // restricted user - async.apply(User.create, { username: 'herp', password: 'derpderp' }), // regular user + async.apply(User.create, { username: 'foo', password: 'barbar' }), // admin + async.apply(User.create, { username: 'baz', password: 'quuxquux' }), // restricted user + async.apply(User.create, { username: 'herp', password: 'derpderp' }), // regular user ], (err, uids) => { if (err) { return done(err); diff --git a/test/meta.js b/test/meta.js index 86ea5a3637..84452561d4 100644 --- a/test/meta.js +++ b/test/meta.js @@ -19,9 +19,9 @@ describe('meta', () => { Groups.cache.reset(); // Create 3 users: 1 admin, 2 regular async.series([ - async.apply(User.create, { username: 'foo', password: 'barbar' }), // admin - async.apply(User.create, { username: 'baz', password: 'quuxquux' }), // restricted user - async.apply(User.create, { username: 'herp', password: 'derpderp' }), // regular user + async.apply(User.create, { username: 'foo', password: 'barbar' }), // admin + async.apply(User.create, { username: 'baz', password: 'quuxquux' }), // restricted user + async.apply(User.create, { username: 'herp', password: 'derpderp' }), // regular user ], (err, uids) => { if (err) { return done(err); diff --git a/test/posts.js b/test/posts.js index e6fa092536..71dfa74a74 100644 --- a/test/posts.js +++ b/test/posts.js @@ -1514,7 +1514,7 @@ describe('Post\'s', () => { const events = await topics.events.get(tid1, 1); assert(events); - assert.strictEqual(events.length, 1); // should still equal 1 + assert.strictEqual(events.length, 1); // should still equal 1 }); it('should not show backlink events if the feature is disabled', async () => { diff --git a/test/socket.io.js b/test/socket.io.js index fad6591185..f709e86178 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -716,7 +716,7 @@ describe('socket.io', () => { event: async.apply(events.getEvents, '', 0, 0), }, (err, data) => { assert.ifError(err); - assert.strictEqual(data.count, 1); // should still equal 1 + assert.strictEqual(data.count, 1); // should still equal 1 // Event validity assert.strictEqual(data.event.length, 1); diff --git a/test/topics/thumbs.js b/test/topics/thumbs.js index 2cdd1d66a9..8020cfd323 100644 --- a/test/topics/thumbs.js +++ b/test/topics/thumbs.js @@ -175,7 +175,7 @@ describe('Topic thumbs', () => { const score = await db.sortedSetScore(`topic:${tid}:thumbs`, relativeThumbPaths[0]); - assert(isFinite(score)); // exists in set + assert(isFinite(score)); // exists in set assert.strictEqual(score, 2); }); @@ -188,7 +188,7 @@ describe('Topic thumbs', () => { const score = await db.sortedSetScore(`topic:${tid}:thumbs`, relativeThumbPaths[0]); - assert(isFinite(score)); // exists in set + assert(isFinite(score)); // exists in set assert.strictEqual(score, 0); }); diff --git a/test/uploads.js b/test/uploads.js index 4def21ed17..7d7186ca02 100644 --- a/test/uploads.js +++ b/test/uploads.js @@ -243,54 +243,6 @@ describe('Upload Controllers', () => { }); }); - // it('should fail if topic thumbs are disabled', function (done) { - // helpers.uploadFile( - // nconf.get('url') + '/api/topic/thumb/upload', - // path.join(__dirname, '../test/files/test.png'), - // {}, jar, csrf_token, - // function (err, res, body) { - // assert.ifError(err); - // assert.strictEqual(res.statusCode, 404); - // console.log(body); - // assert(body && body.status && body.status.code); - // assert.strictEqual(body.status.code, '[[error:topic-thumbnails-are-disabled]]'); - // done(); - // } - // ); - // }); - - // it('should fail if file is not image', function (done) { - // meta.config.allowTopicsThumbnail = 1; - // helpers.uploadFile( - // nconf.get('url') + '/api/topic/thumb/upload', - // path.join(__dirname, '../test/files/503.html'), - // {}, jar, csrf_token, - // function (err, res, body) { - // assert.ifError(err); - // assert.equal(res.statusCode, 500); - // assert.equal(body.error, '[[error:invalid-file]]'); - // done(); - // } - // ); - // }); - - // it('should upload topic thumb', function (done) { - // meta.config.allowTopicsThumbnail = 1; - // helpers.uploadFile( - // nconf.get('url') + '/api/topic/thumb/upload', - // path.join(__dirname, '../test/files/test.png'), - // {}, jar, csrf_token, - // function (err, res, body) { - // assert.ifError(err); - // assert.equal(res.statusCode, 200); - // assert(Array.isArray(body)); - // assert(body[0].path); - // assert(body[0].url); - // done(); - // } - // ); - // }); - it('should not allow non image uploads', (done) => { socketUser.updateCover({ uid: 1 }, { uid: 1, file: { path: '../../text.txt' } }, (err) => { assert.equal(err.message, '[[error:invalid-data]]'); diff --git a/test/user.js b/test/user.js index 671cc06d20..308d68b4b8 100644 --- a/test/user.js +++ b/test/user.js @@ -869,7 +869,7 @@ describe('User', () => { assert.ifError(err); Object.keys(data).forEach((key) => { if (key === 'email') { - assert.strictEqual(userData.email, 'just@for.updated'); // email remains the same until confirmed + assert.strictEqual(userData.email, 'just@for.updated'); // email remains the same until confirmed } else if (key !== 'password') { assert.equal(data[key], userData[key]); } else { @@ -1500,9 +1500,9 @@ describe('User', () => { function (next) { User.digest.getSubscribers('day', (err, subs) => { assert.ifError(err); - assert.strictEqual(subs.includes(uidIndex.daysub.toString()), true); // daysub does get emailed - assert.strictEqual(subs.includes(uidIndex.weeksub.toString()), false); // weeksub does not get emailed - assert.strictEqual(subs.includes(uidIndex.offsub.toString()), false); // offsub doesn't get emailed + assert.strictEqual(subs.includes(uidIndex.daysub.toString()), true); // daysub does get emailed + assert.strictEqual(subs.includes(uidIndex.weeksub.toString()), false); // weeksub does not get emailed + assert.strictEqual(subs.includes(uidIndex.offsub.toString()), false); // offsub doesn't get emailed next(); }); @@ -1516,9 +1516,9 @@ describe('User', () => { function (next) { User.digest.getSubscribers('week', (err, subs) => { assert.ifError(err); - assert.strictEqual(subs.includes(uidIndex.weeksub.toString()), true); // weeksub gets emailed - assert.strictEqual(subs.includes(uidIndex.daysub.toString()), false); // daysub gets emailed - assert.strictEqual(subs.includes(uidIndex.offsub.toString()), false); // offsub does not get emailed + assert.strictEqual(subs.includes(uidIndex.weeksub.toString()), true); // weeksub gets emailed + assert.strictEqual(subs.includes(uidIndex.daysub.toString()), false); // daysub gets emailed + assert.strictEqual(subs.includes(uidIndex.offsub.toString()), false); // offsub does not get emailed next(); }); diff --git a/test/utils.js b/test/utils.js index b9806ca4c8..3c13ef186c 100644 --- a/test/utils.js +++ b/test/utils.js @@ -259,6 +259,7 @@ describe('Utility Methods', () => { }); it('should return passed in value if invalid', (done) => { + // eslint-disable-next-line no-loss-of-precision const bigInt = -111111111111111111; const result = utils.toISOString(bigInt); assert.equal(bigInt, result);