ESlint key-spacing, no-trailing-spaces

v1.18.x
Peter Jaszkowiak 8 years ago
parent 34e233fe1d
commit 277a7fb8b4

@ -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",

@ -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';

@ -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')) {

@ -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');

@ -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',

@ -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,

@ -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;
});

@ -3,7 +3,7 @@
define('admin/appearance/skins', ['translator'], function (translator) {
var Skins = {};
Skins.init = function () {
// Populate skins from Bootswatch API
$.ajax({

@ -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($('<li/ >').addClass('no-themes').translateHtml('[[admin/appearance/themes:no-themes]]'));
} else {
templates.parse('admin/partials/theme_list', {
themes: themes,

@ -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 : '<a title="' + topic.title + '"href="' + RELATIVE_PATH + '/topic/' + tids[i] + '" target="_blank"> ' + topic.title + '</a>';
legend.append(
'<li>' +
'<div style="background-color: ' + topicColors[i] + ';"></div>' +

@ -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();
});
});
});
}

@ -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);

@ -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'],

@ -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

@ -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) {

@ -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));

@ -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;

@ -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');

@ -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;
});
});

@ -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() {

@ -3,9 +3,9 @@
define('forum/category/tools', [
'forum/topic/move',
'topicSelect',
'components',
'forum/topic/move',
'topicSelect',
'components',
'translator',
], function (move, topicSelect, components, translator) {

@ -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,

@ -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('<li><div><span>[[users:no-users-found]]</span></div></li>');
}

@ -273,7 +273,7 @@ define('forum/groups/details', [
if (!confirm) {
return;
}
socket.emit('groups.cover.remove', {
groupName: ajaxify.data.group.name,
}, function (err) {

@ -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');
},
});

@ -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 () {

@ -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) {

@ -16,7 +16,7 @@ define('iconSelect', function () {
$('#icons .fa-icons .fa.' + selected).addClass('selected');
} catch (err) {
selected = '';
}
}
}
templates.parse('partials/fontawesome', {}, function (html) {

@ -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();

@ -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

@ -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();
};

@ -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;

@ -85,7 +85,7 @@ if ('undefined' !== typeof window) {
});
}
});
}(jQuery || {fn:{}}));
}(jQuery || {fn: {}}));
(function () {
// FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245

@ -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',

@ -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] + ']]') : '');

@ -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);

@ -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) {

@ -414,7 +414,7 @@ Controllers.handleURIErrors = function (err, req, res, next) {
}
}
} else {
next(err);
}

@ -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 {

@ -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);
});
};

@ -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, []);
}

@ -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);
});
};

@ -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);
}

@ -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);
}

@ -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);
}

@ -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) {

@ -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) {

@ -25,7 +25,7 @@ module.exports = function (Meta) {
if (err) {
return next(err);
}
config['cache-buster'] = 'v=' + (buster || Date.now());
Meta.config = config;

@ -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) {

@ -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();
});
});
}
});
}

@ -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 {

@ -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]]'));

@ -19,7 +19,7 @@ module.exports = function (Topics) {
Topics.getRecentTopics = function (cid, uid, start, stop, filter, callback) {
var recentTopics = {
nextStart : 0,
nextStart: 0,
topics: [],
};

@ -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);

@ -28,7 +28,7 @@ module.exports = function (Topics) {
var unreadTopics = {
showSelect: true,
nextStart : 0,
nextStart: 0,
topics: [],
};

@ -276,7 +276,7 @@ var meta = require('./meta');
callback();
});
};
User.isAdminOrGlobalModOrSelf = function (callerUid, uid, callback) {
if (parseInt(callerUid, 10) === parseInt(uid, 10)) {
return callback();

@ -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);
});

@ -63,7 +63,7 @@ module.exports = function (User) {
callback();
}
};
};

@ -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;

@ -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,

@ -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);
});

@ -5,7 +5,7 @@
(function (module) {
'use strict';
var async = require('async');
var winston = require('winston');

@ -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;

@ -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);

Loading…
Cancel
Save