From 277a7fb8b428a29e918b7e4a28b51899f9d34daf Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Sat, 18 Feb 2017 01:27:46 -0700 Subject: [PATCH] ESlint key-spacing, no-trailing-spaces --- .eslintrc | 6 ++-- Gruntfile.js | 4 +-- app.js | 2 +- install/web.js | 2 +- public/src/admin/admin.js | 16 +++++------ public/src/admin/advanced/errors.js | 4 +-- public/src/admin/appearance/customise.js | 13 ++++----- public/src/admin/appearance/skins.js | 2 +- public/src/admin/appearance/themes.js | 4 +-- public/src/admin/general/dashboard.js | 16 +++++------ public/src/admin/general/navigation.js | 4 +-- public/src/admin/general/social.js | 2 +- public/src/admin/manage/category-analytics.js | 8 +++--- public/src/admin/manage/flags.js | 2 +- public/src/admin/manage/tags.js | 6 ++-- public/src/admin/modules/search.js | 2 +- public/src/ajaxify.js | 2 +- public/src/app.js | 4 +-- public/src/client/account/edit.js | 6 ++-- public/src/client/account/profile.js | 6 ++-- public/src/client/category/tools.js | 6 ++-- public/src/client/chats/messages.js | 2 +- public/src/client/chats/search.js | 4 +-- public/src/client/groups/details.js | 2 +- public/src/client/topic.js | 4 +-- public/src/modules/chat.js | 6 ++-- public/src/modules/helpers.js | 2 +- public/src/modules/iconSelect.js | 2 +- public/src/modules/pictureCropper.js | 8 +++--- public/src/modules/scrollStop.js | 2 +- public/src/modules/taskbar.js | 2 +- public/src/modules/translator.js | 4 +-- public/src/overrides.js | 2 +- public/src/utils.js | 4 +-- src/admin/search.js | 2 +- src/controllers/admin/dashboard.js | 6 ++-- src/controllers/groups.js | 2 +- src/controllers/index.js | 2 +- src/coverPhoto.js | 4 +-- src/database/mongo/hash.js | 2 +- src/database/mongo/list.js | 6 ++-- src/database/mongo/main.js | 2 +- src/database/mongo/sets.js | 4 +-- src/database/mongo/sorted.js | 6 ++-- src/database/mongo/sorted/add.js | 2 +- src/install.js | 4 +-- src/logger.js | 14 +++++----- src/meta/configs.js | 2 +- src/meta/js.js | 2 +- src/reset.js | 4 +-- src/routes/index.js | 4 +-- src/socket.io/user/profile.js | 2 +- src/topics/recent.js | 2 +- src/topics/tools.js | 4 +-- src/topics/unread.js | 2 +- src/user.js | 2 +- src/user/bans.js | 2 +- src/user/jobs.js | 2 +- src/user/picture.js | 4 +-- src/user/settings.js | 2 +- test/database/hash.js | 2 +- test/mocks/databasemock.js | 2 +- test/translator.js | 2 +- test/user.js | 28 +++++++++---------- 64 files changed, 142 insertions(+), 143 deletions(-) diff --git a/.eslintrc b/.eslintrc index 5d0b9f37dc..cea249bb96 100644 --- a/.eslintrc +++ b/.eslintrc @@ -20,6 +20,7 @@ "no-empty": ["error", { "allowEmptyCatch": true }], "prefer-rest-params": "off", "prefer-spread": "off", + "no-underscore-dangle": "off", // "linebreak-style": "off", // "one-var": "off", @@ -95,9 +96,8 @@ "no-mixed-operators": "off", "comma-spacing": "off", "global-require": "off", - "no-trailing-spaces": "off", - "key-spacing": "off", - "no-underscore-dangle": "off", + // "no-trailing-spaces": "off", + // "key-spacing": "off", // "no-multiple-empty-lines": "off", // "spaced-comment": "off", // "space-in-parens": "off", diff --git a/Gruntfile.js b/Gruntfile.js index 86db9c77f2..2e221df277 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -19,7 +19,7 @@ module.exports = function (grunt) { var fromFile = ''; var compiling = ''; var time = Date.now(); - + if (target === 'lessUpdated_Client') { compiling = 'clientCSS'; } else if (target === 'lessUpdated_Admin') { @@ -137,7 +137,7 @@ module.exports = function (grunt) { } else { grunt.registerTask('default', ['watch']); } - + env.NODE_ENV = 'development'; diff --git a/app.js b/app.js index 3dba714fbf..c85e30ef0a 100644 --- a/app.js +++ b/app.js @@ -112,7 +112,7 @@ function loadConfig(callback) { nconf.set('themes_path', path.resolve(__dirname, nconf.get('themes_path'))); nconf.set('core_templates_path', path.join(__dirname, 'src/views')); nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-persona/templates')); - + nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path'))); if (nconf.get('url')) { diff --git a/install/web.js b/install/web.js index 448483d747..2b086dc890 100644 --- a/install/web.js +++ b/install/web.js @@ -120,7 +120,7 @@ function launch(req, res) { async.parallel([ async.apply(fs.unlink(path.join(__dirname, '../public/installer.css'))), - async.apply(fs.unlink(path.join(__dirname, '../public/installer.min.js'))), + async.apply(fs.unlink(path.join(__dirname, '../public/installer.min.js'))), ], function (err) { if (err) { winston.warn('Unable to remove installer files'); diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index 6b71868258..d492f7d831 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -115,7 +115,7 @@ } else { var matches = url.match(/admin\/(.+?)\/(.+?)$/); mainTitle = '[[admin/menu:' + matches[1] + '/' + matches[2] + ']]'; - pageTitle = '[[admin/menu:section-' + + pageTitle = '[[admin/menu:section-' + (matches[1] === 'development' ? 'advanced' : matches[1]) + ']]' + (matches[2] ? (' > ' + mainTitle) : ''); if (matches[2] === 'settings') { @@ -176,18 +176,18 @@ function configureSlidemenu() { var env = utils.findBootstrapEnvironment(); - + var slideout = new Slideout({ panel: document.getElementById('panel'), menu: document.getElementById('menu'), padding: 256, tolerance: 70, }); - + if (env === 'md' || env === 'lg') { slideout.disableTouch(); } - + $('#mobile-menu').on('click', function () { slideout.toggle(); }); @@ -198,14 +198,14 @@ $(window).on('resize', function () { slideout.close(); - + env = utils.findBootstrapEnvironment(); - + if (env === 'md' || env === 'lg') { slideout.disableTouch(); $('#header').css({ position: 'relative', - }); + }); } else { slideout.enableTouch(); $('#header').css({ @@ -222,7 +222,7 @@ } slideout.on('open', onOpeningMenu); - + slideout.on('close', function () { $('#header').css({ top: '0px', diff --git a/public/src/admin/advanced/errors.js b/public/src/admin/advanced/errors.js index 816a145a72..e8ec4b6acb 100644 --- a/public/src/admin/advanced/errors.js +++ b/public/src/admin/advanced/errors.js @@ -71,7 +71,7 @@ define('admin/advanced/errors', ['Chart', 'translator'], function (Chart, transl notFoundCanvas.width = $(notFoundCanvas).parent().width(); tooBusyCanvas.width = $(tooBusyCanvas).parent().width(); - + new Chart(notFoundCanvas.getContext('2d'), { type: 'line', data: data['not-found'], @@ -89,7 +89,7 @@ define('admin/advanced/errors', ['Chart', 'translator'], function (Chart, transl }, }, }); - + new Chart(tooBusyCanvas.getContext('2d'), { type: 'line', data: data.toobusy, diff --git a/public/src/admin/appearance/customise.js b/public/src/admin/appearance/customise.js index b38b391828..eeb8f7c518 100644 --- a/public/src/admin/appearance/customise.js +++ b/public/src/admin/appearance/customise.js @@ -3,23 +3,23 @@ define('admin/appearance/customise', ['admin/settings'], function (Settings) { var Customise = {}; - - Customise.init = function () { + + Customise.init = function () { Settings.prepare(function () { $('#customCSS').text($('#customCSS-holder').val()); $('#customHTML').text($('#customHTML-holder').val()); - + var customCSS = ace.edit("customCSS"); var customHTML = ace.edit("customHTML"); customCSS.setTheme("ace/theme/twilight"); - customCSS.getSession().setMode("ace/mode/css"); + customCSS.getSession().setMode("ace/mode/css"); customCSS.on('change', function (event) { app.flags = app.flags || {}; app.flags._unsaved = true; $('#customCSS-holder').val(customCSS.getValue()); - }); + }); customHTML.setTheme("ace/theme/twilight"); customHTML.getSession().setMode("ace/mode/html"); @@ -28,10 +28,9 @@ define('admin/appearance/customise', ['admin/settings'], function (Settings) { app.flags = app.flags || {}; app.flags._unsaved = true; $('#customHTML-holder').val(customHTML.getValue()); - }); + }); }); }; return Customise; }); - \ No newline at end of file diff --git a/public/src/admin/appearance/skins.js b/public/src/admin/appearance/skins.js index c946faa2da..f7de9997a7 100644 --- a/public/src/admin/appearance/skins.js +++ b/public/src/admin/appearance/skins.js @@ -3,7 +3,7 @@ define('admin/appearance/skins', ['translator'], function (translator) { var Skins = {}; - + Skins.init = function () { // Populate skins from Bootswatch API $.ajax({ diff --git a/public/src/admin/appearance/themes.js b/public/src/admin/appearance/themes.js index ced02666be..d8f96c1c65 100644 --- a/public/src/admin/appearance/themes.js +++ b/public/src/admin/appearance/themes.js @@ -39,7 +39,7 @@ define('admin/appearance/themes', ['translator'], function (translator) { }); } }); - + $('#revert_theme').on('click', function () { bootbox.confirm('[[admin/appearance/themes:revert-confirm]]', function (confirm) { if (confirm) { @@ -72,7 +72,7 @@ define('admin/appearance/themes', ['translator'], function (translator) { if (!themes.length) { instListEl.append($('
  • ').addClass('no-themes').translateHtml('[[admin/appearance/themes:no-themes]]')); - + } else { templates.parse('admin/partials/theme_list', { themes: themes, diff --git a/public/src/admin/general/dashboard.js b/public/src/admin/general/dashboard.js index 2b8709962a..b598618d58 100644 --- a/public/src/admin/general/dashboard.js +++ b/public/src/admin/general/dashboard.js @@ -23,7 +23,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s graphInterval: 15000, realtimeInterval: 1500, }; - + $(window).on('action:ajaxify.start', function (ev, data) { clearInterval(intervals.rooms); clearInterval(intervals.graphs); @@ -229,7 +229,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s }, }, }); - + graphs.registered = new Chart(registeredCtx, { type: 'doughnut', data: { @@ -265,7 +265,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s }, }, }); - + graphs.topics = new Chart(topicsCtx, { type: 'doughnut', data: { @@ -371,7 +371,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s graphs.presence.update(); } - + function updateTopicsGraph(topics) { if (!Object.keys(topics).length) { topics = {0: { @@ -381,26 +381,26 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s } var tids = Object.keys(topics); - + graphs.topics.data.labels = []; graphs.topics.data.datasets[0].data = []; graphs.topics.data.datasets[0].backgroundColor = []; graphs.topics.data.datasets[0].hoverBackgroundColor = []; - + for (var i = 0, ii = tids.length; i < ii; i += 1) { graphs.topics.data.labels.push(topics[tids[i]].title); graphs.topics.data.datasets[0].data.push(topics[tids[i]].value); graphs.topics.data.datasets[0].backgroundColor.push(topicColors[i]); graphs.topics.data.datasets[0].hoverBackgroundColor.push(lighten(topicColors[i], 10)); } - + function buildTopicsLegend() { var legend = $('#topics-legend').html(''); for (var i = 0, ii = tids.length; i < ii; i += 1) { var topic = topics[tids[i]]; var label = topic.value === '0' ? topic.title : ' ' + topic.title + ''; - + legend.append( '
  • ' + '
    ' + diff --git a/public/src/admin/general/navigation.js b/public/src/admin/general/navigation.js index 3181ebacee..855b1d095e 100644 --- a/public/src/admin/general/navigation.js +++ b/public/src/admin/general/navigation.js @@ -21,7 +21,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun stop: drop, }); }); - + $('#active-navigation').sortable().droppable({ accept: $('#available li .drag-item'), }); @@ -81,7 +81,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun li = $(translator.unescape(li)); $('#enabled').append(li); componentHandler.upgradeDom(); - }); + }); }); } diff --git a/public/src/admin/general/social.js b/public/src/admin/general/social.js index 45f02afa66..d1bbccefe4 100644 --- a/public/src/admin/general/social.js +++ b/public/src/admin/general/social.js @@ -12,7 +12,7 @@ define('admin/general/social', [], function () { networks.push($(this).attr('id')); } }); - + socket.emit('admin.social.savePostSharingNetworks', networks, function (err) { if (err) { return app.alertError(err); diff --git a/public/src/admin/manage/category-analytics.js b/public/src/admin/manage/category-analytics.js index c9cf8162f4..3ae9416a1d 100644 --- a/public/src/admin/manage/category-analytics.js +++ b/public/src/admin/manage/category-analytics.js @@ -87,7 +87,7 @@ define('admin/manage/category-analytics', ['Chart'], function (Chart) { dailyCanvas.width = $(dailyCanvas).parent().width(); topicsCanvas.width = $(topicsCanvas).parent().width(); postsCanvas.width = $(postsCanvas).parent().width(); - + new Chart(hourlyCanvas.getContext('2d'), { type: 'line', data: data['pageviews:hourly'], @@ -106,7 +106,7 @@ define('admin/manage/category-analytics', ['Chart'], function (Chart) { }, }, }); - + new Chart(dailyCanvas.getContext('2d'), { type: 'line', data: data['pageviews:daily'], @@ -125,7 +125,7 @@ define('admin/manage/category-analytics', ['Chart'], function (Chart) { }, }, }); - + new Chart(topicsCanvas.getContext('2d'), { type: 'line', data: data['topics:daily'], @@ -144,7 +144,7 @@ define('admin/manage/category-analytics', ['Chart'], function (Chart) { }, }, }); - + new Chart(postsCanvas.getContext('2d'), { type: 'line', data: data['posts:daily'], diff --git a/public/src/admin/manage/flags.js b/public/src/admin/manage/flags.js index eec663ffcb..77a8bb8e0d 100644 --- a/public/src/admin/manage/flags.js +++ b/public/src/admin/manage/flags.js @@ -133,7 +133,7 @@ define('admin/manage/flags', [ } function updateFlagDetails(source) { - // As the flag details are returned in the API, + // As the flag details are returned in the API, // update the form controls to show the correct data // Create reference hash for use in this method diff --git a/public/src/admin/manage/tags.js b/public/src/admin/manage/tags.js index 29fb27ba3e..6a157487c0 100644 --- a/public/src/admin/manage/tags.js +++ b/public/src/admin/manage/tags.js @@ -89,7 +89,7 @@ define('admin/manage/tags', [ var title = tagsToModify.length > 1 ? '[[admin/manage/tags:alerts.editing-multiple]]' : '[[admin/manage/tags:alerts.editing-x, ' + firstTag.find('.tag-item').text() + ']]'; var modal = bootbox.dialog({ - title: title, + title: title, message: firstTag.find('.tag-modal').html(), buttons: { success: { @@ -155,8 +155,8 @@ define('admin/manage/tags', [ function save(tag) { var data = { tag: tag.attr('data-tag'), - bgColor : tag.find('[data-name="bgColor"]').val(), - color : tag.find('[data-name="color"]').val(), + bgColor: tag.find('[data-name="bgColor"]').val(), + color: tag.find('[data-name="color"]').val(), }; socket.emit('admin.tags.update', data, function (err) { diff --git a/public/src/admin/modules/search.js b/public/src/admin/modules/search.js index d485131e6c..f47f5f4827 100644 --- a/public/src/admin/modules/search.js +++ b/public/src/admin/modules/search.js @@ -128,7 +128,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) { menu.toggleClass('state-start-typing', len === 0); menu.toggleClass('state-keep-typing', len > 0 && len < 3); - + if (len >= 3) { menu.prepend(find(dict, value)); diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index a25c79fe1e..ee010cfc47 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -158,7 +158,7 @@ $(document).ready(function () { app.alertError('[[global:please_log_in]]'); app.previousUrl = url; window.location.href = config.relative_path + '/login'; - + } else if (status === 302 || status === 308) { if (data.responseJSON && data.responseJSON.external) { window.location.href = data.responseJSON.external; diff --git a/public/src/app.js b/public/src/app.js index 99b67a2094..a1667eb0a7 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -223,7 +223,7 @@ app.cacheBuster = null; app.createStatusTooltips = function () { if (!utils.isTouchDevice()) { $('body').tooltip({ - selector:'.fa-circle.status', + selector: '.fa-circle.status', placement: 'top', }); } @@ -481,7 +481,7 @@ app.cacheBuster = null; searchButton.on('click', function (e) { if (!config.loggedIn && !config.allowGuestSearching) { app.alert({ - message:'[[error:search-requires-login]]', + message: '[[error:search-requires-login]]', timeout: 3000, }); ajaxify.go('login'); diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js index ddba6b266d..b805404cbc 100644 --- a/public/src/client/account/edit.js +++ b/public/src/client/account/edit.js @@ -241,9 +241,9 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components' if (!url) { return; } - + uploadModal.modal('hide'); - + pictureCropper.handleImageCrop({ url: url, socketMethod: 'user.uploadCroppedPicture', @@ -251,7 +251,7 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components' paramName: 'uid', paramValue: ajaxify.data.theirid, }, onUploadComplete); - + return false; }); }); diff --git a/public/src/client/account/profile.js b/public/src/client/account/profile.js index 1b38dc0bbd..e703b23af5 100644 --- a/public/src/client/account/profile.js +++ b/public/src/client/account/profile.js @@ -21,10 +21,10 @@ define('forum/account/profile', [ socket.removeListener('event:user_status_change', onUserStatusChange); socket.on('event:user_status_change', onUserStatusChange); - + if (!config.usePagination) { - infinitescroll.init(loadMorePosts); - } + infinitescroll.init(loadMorePosts); + } }; function processPage() { diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.js index 814e06691c..d376025b53 100644 --- a/public/src/client/category/tools.js +++ b/public/src/client/category/tools.js @@ -3,9 +3,9 @@ define('forum/category/tools', [ - 'forum/topic/move', - 'topicSelect', - 'components', + 'forum/topic/move', + 'topicSelect', + 'components', 'translator', ], function (move, topicSelect, components, translator) { diff --git a/public/src/client/chats/messages.js b/public/src/client/chats/messages.js index 5aa0585981..e448554a8e 100644 --- a/public/src/client/chats/messages.js +++ b/public/src/client/chats/messages.js @@ -25,7 +25,7 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function message: msg, mid: mid, }); - + if (!mid) { socket.emit('modules.chats.send', { roomId: roomId, diff --git a/public/src/client/chats/search.js b/public/src/client/chats/search.js index e1a7905bc2..ab8b8d54fd 100644 --- a/public/src/client/chats/search.js +++ b/public/src/client/chats/search.js @@ -40,11 +40,11 @@ define('forum/chats/search', ['components'], function (components) { function displayResults(chatsListEl, data) { chatsListEl.empty(); - + data.users = data.users.filter(function (user) { return parseInt(user.uid, 10) !== parseInt(app.user.uid, 10); }); - + if (!data.users.length) { return chatsListEl.translateHtml('
  • [[users:no-users-found]]
  • '); } diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js index baf05e107c..c4f8be092f 100644 --- a/public/src/client/groups/details.js +++ b/public/src/client/groups/details.js @@ -273,7 +273,7 @@ define('forum/groups/details', [ if (!confirm) { return; } - + socket.emit('groups.cover.remove', { groupName: ajaxify.data.group.name, }, function (err) { diff --git a/public/src/client/topic.js b/public/src/client/topic.js index 06462f4d87..106a8e99f1 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -155,10 +155,10 @@ define('forum/topic', [ message: '[[topic:bookmark_instructions]]', timeout: 0, type: 'info', - clickfn : function () { + clickfn: function () { navigator.scrollToPost(parseInt(bookmark - 1, 10), true); }, - closefn : function () { + closefn: function () { localStorage.removeItem('topic:' + tid + ':bookmark'); }, }); diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index c891a67b70..f2e15c57b5 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -187,17 +187,17 @@ define('chat', [ }); chatModal.draggable({ - start:function () { + start: function () { module.bringModalToTop(chatModal); }, - stop:function () { + stop: function () { chatModal.find('#chat-message-input').focus(); }, distance: 10, handle: '.modal-header', }); }); - + scrollStop.apply(chatModal.find('[component="chat/messages"]')); chatModal.find('#chat-close-btn').on('click', function () { diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js index 97dc55dfa8..0fcde40a07 100644 --- a/public/src/modules/helpers.js +++ b/public/src/modules/helpers.js @@ -1,6 +1,6 @@ (function (exports) { "use strict"; - + // export the class if we are in a Node-like system. if (typeof module === 'object' && module.exports === exports) { diff --git a/public/src/modules/iconSelect.js b/public/src/modules/iconSelect.js index 9bbc28369d..29aff83014 100644 --- a/public/src/modules/iconSelect.js +++ b/public/src/modules/iconSelect.js @@ -16,7 +16,7 @@ define('iconSelect', function () { $('#icons .fa-icons .fa.' + selected).addClass('selected'); } catch (err) { selected = ''; - } + } } templates.parse('partials/fontawesome', {}, function (html) { diff --git a/public/src/modules/pictureCropper.js b/public/src/modules/pictureCropper.js index 4a6e7b1388..e70676b021 100644 --- a/public/src/modules/pictureCropper.js +++ b/public/src/modules/pictureCropper.js @@ -57,18 +57,18 @@ define('pictureCropper', ['translator', 'cropper'], function (translator, croppe cropperModal.find('.reset').on('click', function () { cropperTool.reset(); }); - + cropperModal.find('.crop-btn').on('click', function () { $(this).addClass('disabled'); var imageData = data.imageType ? cropperTool.getCroppedCanvas().toDataURL(data.imageType) : cropperTool.getCroppedCanvas().toDataURL(); - + cropperModal.find('#upload-progress-bar').css('width', '100%'); cropperModal.find('#upload-progress-box').show().removeClass('hide'); - + var socketData = {}; socketData[data.paramName] = data.paramValue; socketData.imageData = imageData; - + socket.emit(data.socketMethod, socketData, function (err, imageData) { if (err) { cropperModal.find('#upload-progress-box').hide(); diff --git a/public/src/modules/scrollStop.js b/public/src/modules/scrollStop.js index f8bd7e8868..0fd722ff89 100644 --- a/public/src/modules/scrollStop.js +++ b/public/src/modules/scrollStop.js @@ -17,7 +17,7 @@ define('scrollStop', function () { var scrollTop = this.scrollTop; var scrollHeight = this.scrollHeight; var elementHeight = this.getBoundingClientRect().height; - + if ( (e.originalEvent.deltaY < 0 && scrollTop === 0) || // scroll up (e.originalEvent.deltaY > 0 && (elementHeight + scrollTop) >= scrollHeight) // scroll down diff --git a/public/src/modules/taskbar.js b/public/src/modules/taskbar.js index e797f14ecf..40761ea45a 100644 --- a/public/src/modules/taskbar.js +++ b/public/src/modules/taskbar.js @@ -39,7 +39,7 @@ define('taskbar', function () { taskbar.discard = function (module, uuid) { var btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]'); btnEl.remove(); - + update(); }; diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index 7652ba3837..4caf71ac68 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -155,7 +155,7 @@ while (cursor + 2 <= len) { sliced = str.slice(cursor, cursor + 2); - // found some text after the double bracket, + // found some text after the double bracket, // so this is probably a translation string if (!textBeforeColonFound && validTextRegex.test(sliced[0])) { textBeforeColonFound = true; @@ -174,7 +174,7 @@ cursor += 1; // a space or comma was found before the name // this isn't a translation string, so back out - } else if (!(textBeforeColonFound && colonFound && textAfterColonFound && commaAfterNameFound) && + } else if (!(textBeforeColonFound && colonFound && textAfterColonFound && commaAfterNameFound) && invalidTextRegex.test(sliced[0])) { cursor += 1; lastBreak -= 2; diff --git a/public/src/overrides.js b/public/src/overrides.js index 5ffbdde3b0..9bc95d68c6 100644 --- a/public/src/overrides.js +++ b/public/src/overrides.js @@ -85,7 +85,7 @@ if ('undefined' !== typeof window) { }); } }); - }(jQuery || {fn:{}})); + }(jQuery || {fn: {}})); (function () { // FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245 diff --git a/public/src/utils.js b/public/src/utils.js index eb9fec1e27..96c2dcd310 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -241,9 +241,9 @@ return Date.prototype.toISOString ? new Date(parseInt(timestamp, 10)).toISOString() : timestamp; }, - tags : ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr'], + tags: ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr'], - stripTags : ['abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'base', 'basefont', + stripTags: ['abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'base', 'basefont', 'bdi', 'bdo', 'big', 'blink', 'body', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'command', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', diff --git a/src/admin/search.js b/src/admin/search.js index 4c53815e48..44f9a53a9f 100644 --- a/src/admin/search.js +++ b/src/admin/search.js @@ -137,7 +137,7 @@ function initDict(language, callback) { title = '[[admin/menu:general/dashboard]]'; } else { title = title.match(/admin\/(.+?)\/(.+?)$/); - title = '[[admin/menu:section-' + + title = '[[admin/menu:section-' + (title[1] === 'development' ? 'advanced' : title[1]) + ']]' + (title[2] ? (' > [[admin/menu:' + title[1] + '/' + title[2] + ']]') : ''); diff --git a/src/controllers/admin/dashboard.js b/src/controllers/admin/dashboard.js index 4ca100326b..63ccc5eb7d 100644 --- a/src/controllers/admin/dashboard.js +++ b/src/controllers/admin/dashboard.js @@ -20,14 +20,14 @@ dashboardController.get = function (req, res, next) { { done: !meta.reloadRequired, doneText: '[[admin/general/dashboard:restart-not-required]]', - notDoneText:'[[admin/general/dashboard:restart-required]]', + notDoneText: '[[admin/general/dashboard:restart-required]]', }, { done: plugins.hasListeners('filter:search.query'), doneText: '[[admin/general/dashboard:search-plugin-installed]]', - notDoneText:'[[admin/general/dashboard:search-plugin-not-installed]]', + notDoneText: '[[admin/general/dashboard:search-plugin-not-installed]]', tooltip: '[[admin/general/dashboard:search-plugin-tooltip]]', - link:'/admin/extend/plugins', + link: '/admin/extend/plugins', }, ]; plugins.fireHook('filter:admin.notices', notices, next); diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 442c764d46..e87a9b4361 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -90,7 +90,7 @@ groupsController.details = function (req, res, callback) { posts: function (next) { groups.getLatestMemberPosts(groupName, 10, req.uid, next); }, - isAdmin:function (next) { + isAdmin: function (next) { user.isAdministrator(req.uid, next); }, isGlobalMod: function (next) { diff --git a/src/controllers/index.js b/src/controllers/index.js index 13927824d3..359d2ffa40 100644 --- a/src/controllers/index.js +++ b/src/controllers/index.js @@ -414,7 +414,7 @@ Controllers.handleURIErrors = function (err, req, res, next) { } } - + } else { next(err); } diff --git a/src/coverPhoto.js b/src/coverPhoto.js index 6307110253..0d13098e62 100644 --- a/src/coverPhoto.js +++ b/src/coverPhoto.js @@ -14,9 +14,9 @@ coverPhoto.getDefaultProfileCover = function (uid) { }; function getCover(type, id) { - if (meta.config[type + ':defaultCovers']) { + if (meta.config[type + ':defaultCovers']) { var covers = meta.config[type + ':defaultCovers'].trim().split(/[\s,]+/g); - + if (typeof id === 'string') { id = (id.charCodeAt(0) + id.charCodeAt(1)) % covers.length; } else { diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js index aa655ba658..c59d53c513 100644 --- a/src/database/mongo/hash.js +++ b/src/database/mongo/hash.js @@ -216,7 +216,7 @@ module.exports = function (db, module) { data[field] = ''; }); - db.collection('objects').update({_key: key}, {$unset : data}, function (err) { + db.collection('objects').update({_key: key}, {$unset: data}, function (err) { callback(err); }); }; diff --git a/src/database/mongo/list.js b/src/database/mongo/list.js index c4b4ffbb6c..250d1951ca 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, res) { 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, res) { callback(err); }); }; @@ -87,7 +87,7 @@ module.exports = function (db, module) { return callback(); } - db.collection('objects').findOne({_key:key}, { array: 1}, function (err, data) { + db.collection('objects').findOne({_key: key}, { array: 1}, function (err, data) { if(err || !(data && data.array)) { return callback(err, []); } diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js index 0aebaf75b2..49bb8453bf 100644 --- a/src/database/mongo/main.js +++ b/src/database/mongo/main.js @@ -76,7 +76,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, res) { callback(err); }); }; diff --git a/src/database/mongo/sets.js b/src/database/mongo/sets.js index 262c0761ff..51c0070e3d 100644 --- a/src/database/mongo/sets.js +++ b/src/database/mongo/sets.js @@ -133,7 +133,7 @@ module.exports = function (db, module) { } value = helpers.valueToString(value); - db.collection('objects').find({_key: {$in : sets}, members: value}, {_id:0, members: 0}).toArray(function (err, result) { + db.collection('objects').find({_key: {$in: sets}, members: value}, {_id: 0, members: 0}).toArray(function (err, result) { if (err) { return callback(err); } @@ -205,7 +205,7 @@ module.exports = function (db, module) { module.setRemoveRandom = function (key, callback) { callback = callback || function () {}; - db.collection('objects').findOne({_key:key}, function (err, data) { + db.collection('objects').findOne({_key: key}, function (err, data) { if(err || !data) { return callback(err); } diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js index 56c4a80688..23105bd44a 100644 --- a/src/database/mongo/sorted.js +++ b/src/database/mongo/sorted.js @@ -157,7 +157,7 @@ module.exports = function (db, module) { return callback(); } var pipeline = [ - { $match : { _key : { $in: keys } } } , + { $match: { _key: { $in: keys } } } , { $group: { _id: {_key: '$_key'}, count: { $sum: 1 } } }, { $project: { _id: 1, count: '$count' } }, ]; @@ -244,7 +244,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').findOne({_key: key, value: value}, {fields:{_id: 0, score: 1}}, function (err, result) { + db.collection('objects').findOne({_key: key, value: value}, {fields: {_id: 0, score: 1}}, function (err, result) { callback(err, result ? result.score : null); }); }; @@ -254,7 +254,7 @@ module.exports = function (db, module) { return callback(); } value = helpers.valueToString(value); - db.collection('objects').find({_key:{$in:keys}, value: value}, {_id:0, _key:1, score: 1}).toArray(function (err, result) { + db.collection('objects').find({_key: {$in: keys}, value: value}, {_id: 0, _key: 1, score: 1}).toArray(function (err, result) { if (err) { return callback(err); } diff --git a/src/database/mongo/sorted/add.js b/src/database/mongo/sorted/add.js index 67caed682d..9172003a09 100644 --- a/src/database/mongo/sorted/add.js +++ b/src/database/mongo/sorted/add.js @@ -15,7 +15,7 @@ module.exports = function (db, module) { value = helpers.valueToString(value); - db.collection('objects').update({_key: key, value: value}, {$set: {score: parseFloat(score)}}, {upsert:true, w: 1}, function (err) { + db.collection('objects').update({_key: key, value: value}, {$set: {score: parseFloat(score)}}, {upsert: true, w: 1}, function (err) { if (err && err.message.startsWith('E11000 duplicate key error')) { return process.nextTick(module.sortedSetAdd, key, score, value, callback); } diff --git a/src/install.js b/src/install.js index 19532403a6..4935261c5a 100644 --- a/src/install.js +++ b/src/install.js @@ -263,12 +263,12 @@ function createAdmin(callback) { winston.warn("Passwords did not match, please try again"); return retryPassword(results); } - + if (results.password.length < meta.config.minimumPasswordLength) { winston.warn("Password too short, please try again"); return retryPassword(results); } - + var adminUid; async.waterfall([ function (next) { diff --git a/src/logger.js b/src/logger.js index 29138b2e4d..823c0599db 100644 --- a/src/logger.js +++ b/src/logger.js @@ -17,13 +17,13 @@ var opts = { /* * state used by Logger */ - express : { - app : {}, - set : 0, - ofn : null, + express: { + app: {}, + set: 0, + ofn: null, }, - streams : { - log : { f : process.stdout }, + streams: { + log: { f: process.stdout }, }, }; @@ -124,7 +124,7 @@ var opts = { /* * Always initialize "ofn" (original function) with the original logger function */ - opts.express.ofn = morgan('combined', {stream : opts.streams.log.f}); + opts.express.ofn = morgan('combined', {stream: opts.streams.log.f}); }; Logger.expressLogger = function (req,res,next) { diff --git a/src/meta/configs.js b/src/meta/configs.js index d21b36c6dc..084a4d1463 100644 --- a/src/meta/configs.js +++ b/src/meta/configs.js @@ -25,7 +25,7 @@ module.exports = function (Meta) { if (err) { return next(err); } - + config['cache-buster'] = 'v=' + (buster || Date.now()); Meta.config = config; diff --git a/src/meta/js.js b/src/meta/js.js index 4aaff6f7a9..722d6bdba0 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -89,7 +89,7 @@ module.exports = function (Meta) { }, }, }; - + Meta.js.linkModules = function (callback) { rimraf(path.join(__dirname, '../../build/public/src/modules'), function (err) { if (err) { diff --git a/src/reset.js b/src/reset.js index 43bf8b61b2..05a337869f 100644 --- a/src/reset.js +++ b/src/reset.js @@ -82,7 +82,7 @@ function resetSettings(callback) { function resetTheme(themeId, callback) { var meta = require('./meta'); var fs = require('fs'); - + fs.access('node_modules/' + themeId + '/package.json', function (err, fd) { if (err) { winston.warn('[reset] Theme `%s` is not installed on this forum', themeId); @@ -99,7 +99,7 @@ function resetTheme(themeId, callback) { } callback(); - }); + }); } }); } diff --git a/src/routes/index.js b/src/routes/index.js index 2869a90bdd..80079b5e91 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -154,7 +154,7 @@ module.exports = function (app, middleware, hotswapIds) { if (path.resolve(__dirname, '../../public/uploads') !== nconf.get('upload_path')) { statics.unshift({ route: '/assets/uploads', path: nconf.get('upload_path') }); } - + statics.forEach(function (obj) { app.use(relativePath + obj.route, express.static(obj.path, staticOptions)); }); @@ -180,7 +180,7 @@ module.exports = function (app, middleware, hotswapIds) { ]; app.use(relativePath, function (req, res, next) { if (deprecatedPaths.some(function (path) { return req.path.startsWith(path); })) { - winston.warn('[deprecated] Accessing `' + req.path.slice(1) + '` from `/` is deprecated. ' + + winston.warn('[deprecated] Accessing `' + req.path.slice(1) + '` from `/` is deprecated. ' + 'Use `/assets' + req.path + '` to access this file.'); res.redirect(relativePath + '/assets' + req.path + '?' + meta.config['cache-buster']); } else { diff --git a/src/socket.io/user/profile.js b/src/socket.io/user/profile.js index ed7b868ba2..ef62090939 100644 --- a/src/socket.io/user/profile.js +++ b/src/socket.io/user/profile.js @@ -37,7 +37,7 @@ module.exports = function (SocketUser) { }, ], callback); }; - + SocketUser.uploadCroppedPicture = function (socket, data, callback) { if (!socket.uid) { return callback(new Error('[[error:no-privileges]]')); diff --git a/src/topics/recent.js b/src/topics/recent.js index 4c68ceff9b..8defa37585 100644 --- a/src/topics/recent.js +++ b/src/topics/recent.js @@ -19,7 +19,7 @@ module.exports = function (Topics) { Topics.getRecentTopics = function (cid, uid, start, stop, filter, callback) { var recentTopics = { - nextStart : 0, + nextStart: 0, topics: [], }; diff --git a/src/topics/tools.js b/src/topics/tools.js index 8edf72142e..da29498ec4 100644 --- a/src/topics/tools.js +++ b/src/topics/tools.js @@ -225,7 +225,7 @@ module.exports = function (Topics) { var uniqueCids = _.unique(topicData.map(function (topicData) { return topicData && parseInt(topicData.cid, 10); })); - + if (uniqueCids.length > 1 || !uniqueCids.length || !uniqueCids[0]) { return next(new Error('[[error:invalid-data]]')); } @@ -249,7 +249,7 @@ module.exports = function (Topics) { setImmediate(next); } }, - ], next); + ], next); }, next); }, ], callback); diff --git a/src/topics/unread.js b/src/topics/unread.js index 717cdc8ef5..e76ee22fda 100644 --- a/src/topics/unread.js +++ b/src/topics/unread.js @@ -28,7 +28,7 @@ module.exports = function (Topics) { var unreadTopics = { showSelect: true, - nextStart : 0, + nextStart: 0, topics: [], }; diff --git a/src/user.js b/src/user.js index 3d75eca479..13dd352b1a 100644 --- a/src/user.js +++ b/src/user.js @@ -276,7 +276,7 @@ var meta = require('./meta'); callback(); }); }; - + User.isAdminOrGlobalModOrSelf = function (callerUid, uid, callback) { if (parseInt(callerUid, 10) === parseInt(uid, 10)) { return callback(); diff --git a/src/user/bans.js b/src/user/bans.js index 7af1e36cf0..964a70669d 100644 --- a/src/user/bans.js +++ b/src/user/bans.js @@ -75,7 +75,7 @@ module.exports = function (User) { async.parallel([ async.apply(db.sortedSetRemove.bind(db), 'users:banned:expire', uid), async.apply(db.sortedSetRemove.bind(db), 'users:banned', uid), - async.apply(User.setUserFields, uid, {banned:0, 'banned:expire': 0}), + async.apply(User.setUserFields, uid, {banned: 0, 'banned:expire': 0}), ], function (err) { next(err, false); }); diff --git a/src/user/jobs.js b/src/user/jobs.js index c45fa03dd8..63e6ef8b4b 100644 --- a/src/user/jobs.js +++ b/src/user/jobs.js @@ -63,7 +63,7 @@ module.exports = function (User) { callback(); } - + }; }; diff --git a/src/user/picture.js b/src/user/picture.js index 379834f914..acea101294 100644 --- a/src/user/picture.js +++ b/src/user/picture.js @@ -222,7 +222,7 @@ module.exports = function (User) { } }); }; - + User.uploadCroppedPicture = function (data, callback) { var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1; var url; @@ -231,7 +231,7 @@ module.exports = function (User) { if (!data.imageData) { return callback(new Error('[[error:invalid-data]]')); } - + async.waterfall([ function (next) { var size = data.file ? data.file.size : data.imageData.length; diff --git a/src/user/settings.js b/src/user/settings.js index d76fc92392..5868e1f45c 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -120,7 +120,7 @@ module.exports = function (User) { restrictChat: data.restrictChat, topicSearchEnabled: data.topicSearchEnabled, delayImageLoading: data.delayImageLoading, - homePageRoute : ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''), + homePageRoute: ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''), scrollToMyPost: data.scrollToMyPost, notificationSound: data.notificationSound, incomingChatSound: data.incomingChatSound, diff --git a/test/database/hash.js b/test/database/hash.js index c560b37a44..41428818f0 100644 --- a/test/database/hash.js +++ b/test/database/hash.js @@ -161,7 +161,7 @@ describe('Hash methods', function () { describe('getObjectsFields()', function () { before(function (done) { async.parallel([ - async.apply(db.setObject, 'testObject8', {name: 'baris', age:99}), + async.apply(db.setObject, 'testObject8', {name: 'baris', age: 99}), async.apply(db.setObject, 'testObject9', {name: 'ginger', age: 3}), ], done); }); diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index 256c8117d1..5a87ab69f3 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -5,7 +5,7 @@ (function (module) { 'use strict'; - + var async = require('async'); var winston = require('winston'); diff --git a/test/translator.js b/test/translator.js index e24754d8e8..185f8235f3 100644 --- a/test/translator.js +++ b/test/translator.js @@ -173,7 +173,7 @@ describe('Translator.create()', function () { describe('Translator modules', function () { it('should work before registered', function () { var translator = Translator.create(); - + Translator.registerModule('test-custom-integer-format', function (lang) { return function (key, args) { var num = parseInt(args[0], 10) || 0; diff --git a/test/user.js b/test/user.js index 96d6cfbbfc..958f300113 100644 --- a/test/user.js +++ b/test/user.js @@ -155,7 +155,7 @@ describe('User', function () { it('should not error if a non-newbie user posts if the last post time is 10 < 30 seconds', function (done) { User.setUserFields(testUid, { - lastposttime: +new Date() - (20 * 1000), + lastposttime: +new Date() - (20 * 1000), reputation: 10, }, function () { Topics.post({ @@ -508,7 +508,7 @@ describe('User', function () { done(); }); }); - + it('should return error if profile image uploads disabled', function (done) { meta.config.allowProfileImageUploads = 0; var path = require('path'); @@ -522,7 +522,7 @@ describe('User', function () { done(); }); }); - + it('should return error if profile image is too big', function (done) { meta.config.allowProfileImageUploads = 1; var path = require('path'); @@ -536,7 +536,7 @@ describe('User', function () { done(); }); }); - + it('should return error if profile image file has no extension', function (done) { var path = require('path'); var picture = { @@ -549,7 +549,7 @@ describe('User', function () { done(); }); }); - + it('should return error if no plugins listening for filter:uploadImage when uploading from url', function (done) { var url = nconf.get('url') + '/logo.png'; User.uploadFromUrl(uid, url, function (err, uploadedPicture) { @@ -557,51 +557,51 @@ describe('User', function () { done(); }); }); - + it('should return error if the extension is invalid when uploading from url', function (done) { var url = nconf.get('url') + '/favicon.ico'; - + function filterMethod(data, callback) { data.foo += 5; callback(null, data); } plugins.registerHook('test-plugin', {hook: 'filter:uploadImage', method: filterMethod}); - + User.uploadFromUrl(uid, url, function (err, uploadedPicture) { assert.equal(err.message, '[[error:invalid-image-extension]]'); done(); }); }); - + it('should return error if the file is too big when uploading from url', function (done) { var url = nconf.get('url') + '/logo.png'; meta.config.maximumProfileImageSize = 1; - + function filterMethod(data, callback) { data.foo += 5; callback(null, data); } plugins.registerHook('test-plugin', {hook: 'filter:uploadImage', method: filterMethod}); - + User.uploadFromUrl(uid, url, function (err, uploadedPicture) { assert.equal(err.message, '[[error:file-too-big, ' + meta.config.maximumProfileImageSize + ']]'); done(); }); }); - + it('should upload picture when uploading from url', function (done) { var url = nconf.get('url') + '/logo.png'; meta.config.maximumProfileImageSize = ''; - + function filterMethod(data, callback) { data.foo += 5; callback(null, {url: url}); } plugins.registerHook('test-plugin', {hook: 'filter:uploadImage', method: filterMethod}); - + User.uploadFromUrl(uid, url, function (err, uploadedPicture) { assert.ifError(err); assert.equal(uploadedPicture.url, url);