Fix eslint rules (#5117)

* Fix semi linter rule

* Fix semi-spacing linter rule

* Fix no-undef-init linter rule

* Fix space-before-blocks linter rule
This commit is contained in:
Sergii Paryzhskyi
2016-10-25 21:34:47 +02:00
committed by Julian Lam
parent 727710fbd9
commit e515b791da
53 changed files with 132 additions and 139 deletions

View File

@@ -48,7 +48,6 @@
"no-extend-native": "off",
"no-shadow-restricted-names": "off",
"no-extra-boolean-cast": "off",
"no-undef-init": "off",
"no-script-url": "off",
"no-path-concat": "off",
"no-unused-expressions": "off",
@@ -66,7 +65,6 @@
"padded-blocks": "off",
"eol-last": "off",
"lines-around-directive": "off",
"space-before-blocks": "off",
"no-restricted-syntax": "off",
"vars-on-top": "off",
"no-prototype-builtins": "off",
@@ -80,7 +78,6 @@
"keyword-spacing": "off",
"no-plusplus": "off",
"no-mixed-operators": "off",
"semi": "off",
"comma-spacing": "off",
"global-require": "off",
"no-trailing-spaces": "off",
@@ -97,7 +94,6 @@
"no-console": "off",
"space-unary-ops": "off",
"import/no-dynamic-require": "off",
"semi-spacing": "off",
"no-bitwise": "off",
"no-empty": "off",
"array-bracket-spacin": "off",

2
app.js
View File

@@ -251,7 +251,7 @@ function setup() {
install.setup(function (err, data) {
var separator = ' ';
if (process.stdout.columns > 10) {
for(var x = 0,cols = process.stdout.columns - 10;x < cols;x++) {
for(var x = 0,cols = process.stdout.columns - 10; x < cols; x++) {
separator += '=';
}
}

View File

@@ -14,7 +14,7 @@
bootbox.alert({
closeButton: false,
message: translated,
callback: function (){
callback: function () {
window.location.reload();
}
});

View File

@@ -11,7 +11,7 @@ define('admin/appearance/skins', function () {
url: 'https://bootswatch.com/api/3.json'
}).done(Skins.render);
$('#skins').on('click', function (e){
$('#skins').on('click', function (e) {
var target = $(e.target);
if (!target.attr('data-action')) {
@@ -72,7 +72,7 @@ define('admin/appearance/skins', function () {
if (config['theme:src']) {
var skin = config['theme:src']
.match(/latest\/(\S+)\/bootstrap.min.css/)[1]
.replace(/(^|\s)([a-z])/g , function (m,p1,p2){return p1 + p2.toUpperCase();});
.replace(/(^|\s)([a-z])/g , function (m,p1,p2) {return p1 + p2.toUpperCase();});
highlightSelectedTheme(skin);
}

View File

@@ -5,7 +5,7 @@ define('admin/appearance/themes', function () {
var Themes = {};
Themes.init = function () {
$('#installed_themes').on('click', function (e){
$('#installed_themes').on('click', function (e) {
var target = $(e.target),
action = target.attr('data-action');

View File

@@ -273,7 +273,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function (semver, Chart)
adjustPieCharts();
$('[data-action="updateGraph"]').on('click', function () {
var until = undefined;
var until;
switch($(this).attr('data-until')) {
case 'last-month':
var lastMonth = new Date();

View File

@@ -2,7 +2,7 @@
/*global define*/
define('admin/general/languages', ['admin/settings'], function (Settings) {
var Languages = {}
var Languages = {};
Languages.init = function () {
Settings.prepare();

View File

@@ -77,7 +77,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) {
li = $(translator.unescape(li));
$('#enabled').append(li);
componentHandler.upgradeDom()
componentHandler.upgradeDom();
});
}

View File

@@ -5,8 +5,8 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
var Categories = {}, newCategoryId = -1, sortables;
Categories.init = function () {
socket.emit('admin.categories.getAll', function (error, payload){
if(error){
socket.emit('admin.categories.getAll', function (error, payload) {
if(error) {
return app.alertError(error.message);
}
@@ -85,7 +85,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
});
};
Categories.render = function (categories){
Categories.render = function (categories) {
var container = $('.categories');
if (!categories || !categories.length) {
@@ -124,7 +124,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
var isCategoryUpdate = (newCategoryId != -1);
//Update needed?
if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate){
if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) {
var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid],
modified = {}, i = 0, list = parentCategory.toArray(), len = list.length;
@@ -134,7 +134,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
};
}
if (isCategoryUpdate){
if (isCategoryUpdate) {
modified[e.item.dataset.cid].parentCid = newCategoryId;
}
@@ -151,7 +151,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
* @param container {object} parent jquery element for the list
* @param parentId {number} parent category identifier
*/
function renderList(categories, container, parentId){
function renderList(categories, container, parentId) {
// Translate category names if needed
var count = 0;
categories.forEach(function (category, idx, parent) {
@@ -179,7 +179,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
container.append(html);
// Handle and children categories in this level have
for(var x = 0,numCategories = categories.length;x < numCategories;x++) {
for(var x = 0,numCategories = categories.length; x < numCategories; x++) {
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
}

View File

@@ -235,7 +235,7 @@ define('admin/manage/category', [
privs.push(el.getAttribute('data-privilege'));
}
});
for(var x = 0,numPrivs = privs.length;x < numPrivs;x++) {
for(var x = 0,numPrivs = privs.length; x < numPrivs; x++) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
inputs.each(function (idx, el) {
if (!el.checked) {

View File

@@ -59,7 +59,7 @@ define(function () {
value = $input.val().toLowerCase(),
menuItems = $('#acp-search .dropdown-menu').html('');
function toUpperCase(txt){
function toUpperCase(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}

View File

@@ -2,7 +2,7 @@
/* global define, socket */
define('admin/settings/general', ['admin/settings'], function (Settings) {
var Module = {}
var Module = {};
Module.init = function () {
$('button[data-action="removeLogo"]').on('click', function () {

View File

@@ -122,7 +122,7 @@ $(document).ready(function () {
var payload = {
url: url
}
};
$(window).trigger('action:ajaxify.start', payload);

View File

@@ -33,7 +33,7 @@ app.cacheBuster = null;
app.handleSearch();
}
$('body').on('click', '#new_topic', function (){
$('body').on('click', '#new_topic', function () {
app.newTopic();
});
@@ -41,7 +41,7 @@ app.cacheBuster = null;
components.get('user/logout').on('click', app.logout);
});
Visibility.change(function (event, state){
Visibility.change(function (event, state) {
if (state === 'visible') {
app.isFocused = true;
app.alternatingTitle('');
@@ -428,7 +428,7 @@ app.cacheBuster = null;
$('#search-form').on('submit', dismissSearch);
searchInput.on('blur', dismissSearch);
function dismissSearch(){
function dismissSearch() {
searchFields.addClass('hidden');
searchButton.removeClass('hidden');
}

View File

@@ -13,7 +13,7 @@ define('forum/compose', [], function () {
container: container
});
}
}
};
return Compose;
});

View File

@@ -60,7 +60,7 @@ define('forum/groups/list', ['forum/infinitescroll'], function (infinitescroll)
$('[component="groups/container"]').attr('data-nextstart', data.nextStart);
}
});
}
};
Groups.search = function () {
var groupsEl = $('#groups-list'),

View File

@@ -22,7 +22,7 @@ define('autocomplete', function () {
if (result && result.users) {
var names = result.users.map(function (user) {
var username = $('<div/>').html(user.username).text()
var username = $('<div/>').html(user.username).text();
return user && {
label: username,
value: username,

View File

@@ -19,7 +19,7 @@ define('sounds', ['buzz'], function (buzz) {
}
eventSoundMapping = mapping;
});
}
};
function loadData(callback) {
socket.emit('modules.sounds.getData', function (err, data) {

View File

@@ -88,7 +88,7 @@ if ('undefined' !== typeof window) {
});
}(jQuery || {fn:{}}));
(function (){
(function () {
// FIX FOR #1245 - https://github.com/NodeBB/NodeBB/issues/1245
// from http://stackoverflow.com/questions/15931962/bootstrap-dropdown-disappear-with-right-click-on-firefox
// obtain a reference to the original handler

View File

@@ -309,7 +309,7 @@
labels = [],
tmpDate;
for(var x = 29;x >= 0;x--) {
for(var x = 29; x >= 0; x--) {
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate());
}
@@ -443,7 +443,7 @@
};
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (prefix){
String.prototype.startsWith = function (prefix) {
if (this.length < prefix.length) {
return false;
}

View File

@@ -29,7 +29,7 @@ var async = require('async'),
}
// custom done condition
options.doneIf = typeof options.doneIf === 'function' ? options.doneIf : function (){};
options.doneIf = typeof options.doneIf === 'function' ? options.doneIf : function () {};
var batch = options.batch || DEFAULT_BATCH_SIZE;
var start = 0;

View File

@@ -301,7 +301,7 @@ var privileges = require('./privileges');
category.parentCid = 0;
}
if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)){
if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)) {
tree.push(category);
category.children = Categories.getTree(categories, category.cid);
}
@@ -318,7 +318,7 @@ var privileges = require('./privileges');
var bullet = level ? '&bull; ' : '';
category.value = category.cid;
category.text = level + bullet + category.name
category.text = level + bullet + category.name;
categoriesData.push(category);
category.children.forEach(function (child) {
@@ -349,7 +349,7 @@ var privileges = require('./privileges');
Categories.filterIgnoringUids = function (cid, uids, callback) {
async.waterfall([
function (next){
function (next) {
db.sortedSetScores('cid:' + cid + ':ignorers', uids, next);
},
function (scores, next) {

View File

@@ -89,7 +89,7 @@ module.exports = function (Categories) {
db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next);
}
},
function (next){
function (next) {
Categories.updateRecentTid(cid, postData.tid, next);
},
function (next) {

View File

@@ -52,7 +52,7 @@ groupsController.list = function (req, res, next) {
groupsController.get = function (req, res, callback) {
var groupName = req.params.name;
async.waterfall([
function (next){
function (next) {
groups.exists(groupName, next);
},
function (exists, next) {

View File

@@ -57,7 +57,7 @@ function getNodeInfo(callback) {
platform: os.platform(),
arch: os.arch(),
release: os.release(),
load: os.loadavg().map(function (load){ return load.toFixed(2); }).join(', ')
load: os.loadavg().map(function (load) { return load.toFixed(2); }).join(', ')
}
};

View File

@@ -55,7 +55,7 @@ topicsController.get = function (req, res, callback) {
if (!res.locals.isAPI && (!req.params.slug || results.topic.slug !== tid + '/' + req.params.slug) && (results.topic.slug && results.topic.slug !== tid + '/')) {
var url = '/topic/' + results.topic.slug;
if (req.params.post_index){
if (req.params.post_index) {
url += '/' + req.params.post_index;
}
if (currentPage > 1) {

View File

@@ -65,7 +65,7 @@ module.exports = function (Groups) {
function (uploadData, next) {
Groups.setGroupField(data.groupName, 'cover:thumb:url', uploadData.url, next);
},
function (next){
function (next) {
fs.unlink(tempPath, next); // Delete temporary file
}
], function (err) {

View File

@@ -131,7 +131,7 @@ module.exports = function (Groups) {
} else {
return 0;
}
})
});
next(null, results);
}
], callback);

View File

@@ -10,7 +10,7 @@ HotSwap.prepare = function (app) {
HotSwap.find = function (id) {
if (stack) {
for(var x = 0,numEntries = stack.length;x < numEntries;x++) {
for(var x = 0,numEntries = stack.length; x < numEntries; x++) {
if (stack[x].handle.hotswapId === id) {
return x;
}

View File

@@ -43,7 +43,7 @@ module.exports = function (middleware) {
};
var isAllowed = function (url) {
for(var x = 0,numAllowed = allowedRoutes.length,route;x < numAllowed;x++) {
for(var x = 0,numAllowed = allowedRoutes.length,route; x < numAllowed; x++) {
route = new RegExp(allowedRoutes[x]);
if (route.test(url)) {
return true;

View File

@@ -161,6 +161,3 @@ module.exports = function (middleware) {
};
};

View File

@@ -107,9 +107,9 @@ var middleware;
return next();
}
plugins = plugins.filter(function (plugin){
plugins = plugins.filter(function (plugin) {
return plugin && typeof plugin === 'string';
}).map(function (plugin){
}).map(function (plugin) {
return path.join(__dirname, '../node_modules/', plugin);
});
@@ -122,7 +122,7 @@ var middleware;
if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') {
process.stdout.write('\n');
winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.');
for(var x = 0,numPlugins = Plugins.versionWarning.length;x < numPlugins;x++) {
for(var x = 0,numPlugins = Plugins.versionWarning.length; x < numPlugins; x++) {
process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n');
}
process.stdout.write('\n');
@@ -329,7 +329,7 @@ var middleware;
pluginArray.sort(function (a, b) {
if (a.name > b.name ) {
return 1;
} else if (a.name < b.name ){
} else if (a.name < b.name ) {
return -1;
} else {
return 0;
@@ -348,20 +348,20 @@ var middleware;
async.apply(fs.readdir, npmPluginPath),
function (dirs, next) {
dirs = dirs.filter(function (dir){
dirs = dirs.filter(function (dir) {
return dir.startsWith('nodebb-plugin-') ||
dir.startsWith('nodebb-widget-') ||
dir.startsWith('nodebb-rewards-') ||
dir.startsWith('nodebb-theme-');
}).map(function (dir){
}).map(function (dir) {
return path.join(npmPluginPath, dir);
});
async.filter(dirs, function (dir, callback){
fs.stat(dir, function (err, stats){
async.filter(dirs, function (dir, callback) {
fs.stat(dir, function (err, stats) {
callback(!err && stats.isDirectory());
});
}, function (plugins){
}, function (plugins) {
next(null, plugins);
});
},

View File

@@ -66,7 +66,7 @@ module.exports = function (privileges) {
memberData.forEach(function (member) {
member.privileges = {};
for(var x = 0,numPrivs = userPrivileges.length;x < numPrivs;x++) {
for(var x = 0,numPrivs = userPrivileges.length; x < numPrivs; x++) {
member.privileges[userPrivileges[x]] = memberSets[x].indexOf(parseInt(member.uid, 10)) !== -1;
}
});
@@ -117,7 +117,7 @@ module.exports = function (privileges) {
var memberData = groupNames.map(function (member) {
memberPrivs = {};
for(var x = 0,numPrivs = groupPrivileges.length;x < numPrivs;x++) {
for(var x = 0,numPrivs = groupPrivileges.length; x < numPrivs; x++) {
memberPrivs[groupPrivileges[x]] = memberSets[x].indexOf(member) !== -1;
}
return {

View File

@@ -364,7 +364,7 @@ function sendFeed(feed, res) {
res.type('xml').set('Content-Length', Buffer.byteLength(xml)).send(xml);
}
module.exports = function (app, middleware, controllers){
module.exports = function (app, middleware, controllers) {
app.get('/topic/:topic_id.rss', generateForTopic);
app.get('/category/:category_id.rss', generateForCategory);
app.get('/recent.rss', generateForRecent);

View File

@@ -98,7 +98,7 @@ module.exports = function (app, middleware, hotswapIds) {
var ensureLoggedIn = require('connect-ensure-login');
if (Array.isArray(hotswapIds) && hotswapIds.length) {
for(var idx,x = 0;x < hotswapIds.length;x++) {
for(var idx,x = 0; x < hotswapIds.length; x++) {
idx = routers.push(express.Router()) - 1;
routers[idx].hotswapId = hotswapIds[x];
}
@@ -135,7 +135,7 @@ module.exports = function (app, middleware, hotswapIds) {
userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers);
for(var x = 0;x < routers.length;x++) {
for(var x = 0; x < routers.length; x++) {
app.use(relativePath, routers[x]);
}

View File

@@ -37,7 +37,7 @@ sitemap.render = function (callback) {
numPages = Math.ceil(tids.length / numTopics);
}
for(var x = 1;x <= numPages;x++) {
for(var x = 1; x <= numPages; x++) {
returnData.topics.push(x);
}

View File

@@ -25,7 +25,7 @@ Categories.getAll = function (socket, data, callback) {
//Hook changes, there is no req, and res
plugins.fireHook('filter:admin.categories.get', {categories: categories}, next);
},
function (result, next){
function (result, next) {
next(null, categories.getTree(result.categories, 0));
}
], function (err, categoriesTree) {

View File

@@ -167,5 +167,5 @@ module.exports = function (SocketPosts) {
},
async.apply(posts.updateFlagData)
], callback);
}
};
};

View File

@@ -21,7 +21,7 @@ module.exports = function (SocketPosts) {
privileges.posts.canMove(data.pid, socket.uid, next);
},
function (canMove, next) {
if (!canMove){
if (!canMove) {
return next(new Error('[[error:no-privileges]]'));
}

View File

@@ -122,6 +122,6 @@ module.exports = function (SocketUser) {
}
callback(null, data.list.pictures);
})
});
};
};

View File

@@ -393,7 +393,7 @@ var social = require('./social');
});
}, next);
}
], function (err){
], function (err) {
callback(err);
});
};

View File

@@ -147,10 +147,10 @@ module.exports = function (Topics) {
Topics.filterIgnoringUids = function (tid, uids, callback) {
async.waterfall([
function (next){
function (next) {
db.isSetMembers('tid:' + tid + ':ignorers', uids, next);
},
function (isMembers, next){
function (isMembers, next) {
var readingUids = uids.filter(function (uid, index) {
return uid && isMembers[index];
});

View File

@@ -56,7 +56,7 @@ module.exports = function (Topics) {
Topics.create({uid: results.postData.uid, title: title, cid: cid}, next);
},
function (results, next) {
Topics.updateTopicBookmarks(fromTid, pids, function (){ next( null, results );} );
Topics.updateTopicBookmarks(fromTid, pids, function () { next( null, results );} );
},
function (_tid, next) {
function move(pid, next) {

View File

@@ -37,7 +37,7 @@ module.exports = function (User) {
expiry_readable: new Date(parseInt(expiry, 10)).toString().replace(/:/g, '%3A'),
reason: validator.escape(String(reason))
});
})
});
};
User.getModerationHistory = function (uid, callback) {

View File

@@ -138,7 +138,7 @@ module.exports = function (User) {
db.delete('invitation:email:' + email, callback);
}
], function (err) {
next(err)
next(err);
});
}
], callback);

View File

@@ -81,7 +81,7 @@ describe('authentication', function () {
}, function (err, response, body) {
assert.ifError(err);
assert.equal(body, 'not-authorized');
done()
done();
});
});
});
@@ -119,7 +119,7 @@ describe('authentication', function () {
assert(body);
assert.equal(body.username, 'regular');
assert.equal(body.email, 'regular@nodebb.org');
done()
done();
});
});
});

View File

@@ -7,7 +7,7 @@ var db = require('./mocks/databasemock');
describe('Test database', function () {
it('should work', function () {
assert.doesNotThrow(function (){
assert.doesNotThrow(function () {
require('./mocks/databasemock');
});
});

View File

@@ -33,7 +33,7 @@
var testDbConfig = nconf.get('test_database');
var productionDbConfig = nconf.get(dbType);
if (!testDbConfig){
if (!testDbConfig) {
errorText = 'test_database is not defined';
winston.info(
'\n===========================================================\n' +

View File

@@ -67,7 +67,7 @@ describe('Plugins', function () {
plugins.registerHook('test-plugin', {hook: 'static:test.hook', method: actionMethod});
plugins.fireHook('static:test.hook', {bar: 'test'}, function (err) {
assert.ifError(err);
done()
done();
});
});

View File

@@ -252,14 +252,14 @@ describe('Topic\'s', function () {
});
});
describe('.ignore', function (){
describe('.ignore', function () {
var newTid;
var uid;
var newTopic;
before(function (done){
before(function (done) {
uid = topic.userId;
async.waterfall([
function (done){
function (done) {
topics.post({uid: topic.userId, title: 'Topic to be ignored', content: 'Just ignore me, please!', cid: topic.categoryId}, function (err, result) {
if (err) {
return done(err);
@@ -270,43 +270,43 @@ describe('Topic\'s', function () {
done();
});
},
function (done){
function (done) {
topics.markUnread( newTid, uid, done );
}
],done);
});
it('should not appear in the unread list', function (done){
it('should not appear in the unread list', function (done) {
async.waterfall([
function (done){
function (done) {
topics.ignore( newTid, uid, done );
},
function (done){
function (done) {
topics.getUnreadTopics(0, uid, 0, -1, '', done );
},
function (results, done){
function (results, done) {
var topics = results.topics;
var tids = topics.map( function (topic){ return topic.tid; } );
var tids = topics.map( function (topic) { return topic.tid; } );
assert.equal(tids.indexOf(newTid), -1, 'The topic appeared in the unread list.');
done();
}
], done);
});
it('should not appear as unread in the recent list', function (done){
it('should not appear as unread in the recent list', function (done) {
async.waterfall([
function (done){
function (done) {
topics.ignore( newTid, uid, done );
},
function (done){
function (done) {
topics.getLatestTopics( uid, 0, -1, 'year', done );
},
function (results, done){
function (results, done) {
var topics = results.topics;
var topic;
var i;
for(i = 0; i < topics.length; ++i){
if( topics[i].tid == newTid ){
for(i = 0; i < topics.length; ++i) {
if( topics[i].tid == newTid ) {
assert.equal(false, topics[i].unread, 'ignored topic was marked as unread in recent list');
return done();
}
@@ -317,40 +317,40 @@ describe('Topic\'s', function () {
], done);
});
it('should appear as unread again when marked as reading', function (done){
it('should appear as unread again when marked as reading', function (done) {
async.waterfall([
function (done){
function (done) {
topics.ignore( newTid, uid, done );
},
function (done){
function (done) {
topics.follow( newTid, uid, done );
},
function (done){
function (done) {
topics.getUnreadTopics(0, uid, 0, -1, '', done );
},
function (results, done){
function (results, done) {
var topics = results.topics;
var tids = topics.map( function (topic){ return topic.tid; } );
var tids = topics.map( function (topic) { return topic.tid; } );
assert.notEqual(tids.indexOf(newTid), -1, 'The topic did not appear in the unread list.');
done();
}
], done);
});
it('should appear as unread again when marked as following', function (done){
it('should appear as unread again when marked as following', function (done) {
async.waterfall([
function (done){
function (done) {
topics.ignore( newTid, uid, done );
},
function (done){
function (done) {
topics.follow( newTid, uid, done );
},
function (done){
function (done) {
topics.getUnreadTopics(0, uid, 0, -1, '', done );
},
function (results, done){
function (results, done) {
var topics = results.topics;
var tids = topics.map( function (topic){ return topic.tid; } );
var tids = topics.map( function (topic) { return topic.tid; } );
assert.notEqual(tids.indexOf(newTid), -1, 'The topic did not appear in the unread list.');
done();
}
@@ -360,12 +360,12 @@ describe('Topic\'s', function () {
describe('.fork', function (){
describe('.fork', function () {
var newTopic;
var replies = [];
var topicPids;
var originalBookmark = 5;
function postReply( next ){
function postReply( next ) {
topics.reply({uid: topic.userId, content: 'test post ' + replies.length, tid: newTopic.tid},
function (err, result) {
assert.equal(err, null, 'was created with error');
@@ -379,30 +379,30 @@ describe('Topic\'s', function () {
before( function (done) {
async.waterfall(
[
function (next){
function (next) {
groups.join('administrators', topic.userId, next);
},
function ( next ){
function ( next ) {
topics.post({uid: topic.userId, title: topic.title, content: topic.content, cid: topic.categoryId}, function (err, result) {
assert.ifError( err );
newTopic = result.topicData;
next();
});
},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){ postReply( next );},
function ( next ){
topicPids = replies.map( function ( reply ){ return reply.pid; } );
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) { postReply( next );},
function ( next ) {
topicPids = replies.map( function ( reply ) { return reply.pid; } );
topics.setUserBookmark( newTopic.tid, topic.userId, originalBookmark, next );
}],
done );
@@ -413,9 +413,9 @@ describe('Topic\'s', function () {
done();
});
it('should not update the user\'s bookmark', function (done){
it('should not update the user\'s bookmark', function (done) {
async.waterfall([
function (next){
function (next) {
topics.createTopicFromPosts(
topic.userId,
'Fork test, no bookmark update',
@@ -423,19 +423,19 @@ describe('Topic\'s', function () {
newTopic.tid,
next );
},
function ( forkedTopicData, next){
function ( forkedTopicData, next) {
topics.getUserBookmark( newTopic.tid, topic.userId, next );
},
function ( bookmark, next ){
function ( bookmark, next ) {
assert.equal( originalBookmark, bookmark );
next();
}
],done);
});
it('should update the user\'s bookmark ', function (done){
it('should update the user\'s bookmark ', function (done) {
async.waterfall([
function (next){
function (next) {
topics.createTopicFromPosts(
topic.userId,
'Fork test, no bookmark update',
@@ -443,10 +443,10 @@ describe('Topic\'s', function () {
newTopic.tid,
next );
},
function ( forkedTopicData, next){
function ( forkedTopicData, next) {
topics.getUserBookmark( newTopic.tid, topic.userId, next );
},
function ( bookmark, next ){
function ( bookmark, next ) {
assert.equal( originalBookmark - 2, bookmark );
next();
}

View File

@@ -7,8 +7,8 @@ var Translator = shim.Translator;
require('../src/languages').init(function () {});
describe('translator shim', function (){
describe('.translate()', function (){
describe('translator shim', function () {
describe('.translate()', function () {
it('should translate correctly', function (done) {
shim.translate('[[global:pagination.out_of, (foobar), [[global:home]]]]', function (translated) {
assert.strictEqual(translated, '(foobar) out of Home');
@@ -18,8 +18,8 @@ describe('translator shim', function (){
});
});
describe('new Translator(language)', function (){
describe('.translate()', function (){
describe('new Translator(language)', function () {
describe('.translate()', function () {
it('should handle basic translations', function (done) {
var translator = new Translator('en_GB');
@@ -165,7 +165,7 @@ describe('new Translator(language)', function (){
});
});
describe('Translator.create()', function (){
describe('Translator.create()', function () {
it('should return an instance of Translator', function (done) {
var translator = Translator.create('en_GB');

View File

@@ -49,7 +49,7 @@ describe('User', function () {
describe('.create(), when created', function () {
it('should be created properly', function (done) {
User.create({username: userData.username, password: userData.password, email: userData.email}, function (error,userId){
User.create({username: userData.username, password: userData.password, email: userData.email}, function (error,userId) {
assert.equal(error, null, 'was created with error');
assert.ok(userId);

View File

@@ -7,7 +7,7 @@ var utils = require('./../public/src/utils.js');
describe('Utility Methods', function () {
describe('username validation', function () {
it('accepts latin-1 characters', function (){
it('accepts latin-1 characters', function () {
var username = "John\"'-. Doeäâèéë1234";
assert(utils.isUserNameValid(username), 'invalid username');
});
@@ -29,7 +29,7 @@ describe('Utility Methods', function () {
});
describe('UUID generation', function () {
it('return unique random value every time', function (){
it('return unique random value every time', function () {
var uuid1 = utils.generateUUID(),
uuid2 = utils.generateUUID();
assert.notEqual(uuid1, uuid2, 'matches');