Eslint no-lonely-if

v1.18.x
Peter Jaszkowiak 8 years ago
parent 57f89663aa
commit 144fa8698c

@ -51,6 +51,7 @@
"no-script-url": "off", "no-script-url": "off",
"no-use-before-define": "off", "no-use-before-define": "off",
"default-case": "off", "default-case": "off",
"new-cap": "off",
// "linebreak-style": "off", // "linebreak-style": "off",
// "one-var": "off", // "one-var": "off",
@ -67,9 +68,8 @@
"eqeqeq": "off", "eqeqeq": "off",
"camelcase": "off", "camelcase": "off",
"no-negated-condition": "off", "no-negated-condition": "off",
"one-var-declaration-per-line": "off", // "one-var-declaration-per-line": "off",
"new-cap": "off", // "no-lonely-if": "off",
"no-lonely-if": "off",
// "radix": "off", // "radix": "off",
// "no-else-return": "off", // "no-else-return": "off",
// "no-useless-escape": "off", // "no-useless-escape": "off",

@ -351,10 +351,8 @@ $(document).ready(function () {
// Special handling for urls with hashes // Special handling for urls with hashes
if (window.location.pathname === this.pathname && this.hash.length) { if (window.location.pathname === this.pathname && this.hash.length) {
window.location.hash = this.hash; window.location.hash = this.hash;
} else { } else if (ajaxify.go(pathname)) {
if (ajaxify.go(pathname)) { e.preventDefault();
e.preventDefault();
}
} }
} else if (window.location.pathname !== '/outgoing') { } else if (window.location.pathname !== '/outgoing') {
if (config.openOutgoingLinksInNewTab && $.contains(contentEl, this)) { if (config.openOutgoingLinksInNewTab && $.contains(contentEl, this)) {

@ -311,22 +311,20 @@ define('forum/chats', [
data.message.self = data.self; data.message.self = data.self;
messages.appendChatMessage($('.expanded-chat .chat-content'), data.message); messages.appendChatMessage($('.expanded-chat .chat-content'), data.message);
} else { } else if (ajaxify.currentPage.startsWith('chats')) {
if (ajaxify.currentPage.startsWith('chats')) { var roomEl = $('[data-roomid=' + data.roomId + ']');
var roomEl = $('[data-roomid=' + data.roomId + ']');
if (roomEl.length > 0) {
if (roomEl.length > 0) { roomEl.addClass('unread');
roomEl.addClass('unread'); } else {
} else { var recentEl = components.get('chat/recent');
var recentEl = components.get('chat/recent'); templates.parse('partials/chats/recent_room', {
templates.parse('partials/chats/recent_room', { rooms: { roomId: data.roomId, lastUser: data.message.fromUser, usernames: data.message.fromUser.username, unread: true },
rooms: { roomId: data.roomId, lastUser: data.message.fromUser, usernames: data.message.fromUser.username, unread: true }, }, function (html) {
}, function (html) { translator.translate(html, function (translated) {
translator.translate(html, function (translated) {
recentEl.prepend(translated); recentEl.prepend(translated);
});
}); });
} });
} }
} }
}); });

@ -510,20 +510,18 @@ define('settings', function () {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(err); callback(err);
} else if (err) {
app.alert({
title: 'Error while saving settings',
type: 'error',
timeout: 2500,
});
} else { } else {
if (err) { app.alert({
app.alert({ title: 'Settings Saved',
title: 'Error while saving settings', type: 'success',
type: 'error', timeout: 2500,
timeout: 2500, });
});
} else {
app.alert({
title: 'Settings Saved',
type: 'success',
timeout: 2500,
});
}
} }
}); });
} }

@ -38,14 +38,12 @@ helpers.notAllowed = function (req, res, error) {
title: '[[global:403.title]]', title: '[[global:403.title]]',
}); });
} }
} else if (res.locals.isAPI) {
req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, '');
res.status(401).json('not-authorized');
} else { } else {
if (res.locals.isAPI) { req.session.returnTo = nconf.get('relative_path') + req.url;
req.session.returnTo = nconf.get('relative_path') + req.url.replace(/^\/api/, ''); res.redirect(nconf.get('relative_path') + '/login');
res.status(401).json('not-authorized');
} else {
req.session.returnTo = nconf.get('relative_path') + req.url;
res.redirect(nconf.get('relative_path') + '/login');
}
} }
}); });
}; };

@ -241,12 +241,10 @@ module.exports = function (Groups) {
} }
if (Groups.isPrivilegeGroup(groupName) && parseInt(groupData.memberCount, 10) === 0) { if (Groups.isPrivilegeGroup(groupName) && parseInt(groupData.memberCount, 10) === 0) {
Groups.destroy(groupName, next); Groups.destroy(groupName, next);
} else if (parseInt(groupData.hidden, 10) !== 1) {
db.sortedSetAdd('groups:visible:memberCount', groupData.memberCount, groupName, next);
} else { } else {
if (parseInt(groupData.hidden, 10) !== 1) { next();
db.sortedSetAdd('groups:visible:memberCount', groupData.memberCount, groupName, next);
} else {
next();
}
} }
}, },
function (next) { function (next) {

@ -18,10 +18,8 @@ module.exports = function (Meta) {
Meta.sounds.init = function (callback) { Meta.sounds.init = function (callback) {
if (nconf.get('isPrimary') === 'true') { if (nconf.get('isPrimary') === 'true') {
setupSounds(callback); setupSounds(callback);
} else { } else if (typeof callback === 'function') {
if (typeof callback === 'function') { callback();
callback();
}
} }
}; };

@ -190,12 +190,10 @@ var middleware;
winston.warn('[plugins] Skipping ' + pluginTemplate + ' by plugin ' + plugin.id); winston.warn('[plugins] Skipping ' + pluginTemplate + ' by plugin ' + plugin.id);
} }
}); });
} else if (err) {
winston.error(err);
} else { } else {
if (err) { winston.warn('[plugins/' + plugin.id + '] A templates directory was defined for this plugin, but was not found.');
winston.error(err);
} else {
winston.warn('[plugins/' + plugin.id + '] A templates directory was defined for this plugin, but was not found.');
}
} }
next(false); next(false);

@ -28,12 +28,10 @@ module.exports = function (privileges) {
privileges.users.isModerator = function (uid, cid, callback) { privileges.users.isModerator = function (uid, cid, callback) {
if (Array.isArray(cid)) { if (Array.isArray(cid)) {
isModeratorOfCategories(cid, uid, callback); isModeratorOfCategories(cid, uid, callback);
} else if (Array.isArray(uid)) {
isModeratorsOfCategory(cid, uid, callback);
} else { } else {
if (Array.isArray(uid)) { isModeratorOfCategory(cid, uid, callback);
isModeratorsOfCategory(cid, uid, callback);
} else {
isModeratorOfCategory(cid, uid, callback);
}
} }
}; };

@ -133,14 +133,12 @@ function resetPlugin(pluginId, callback) {
], function (err) { ], function (err) {
if (err) { if (err) {
winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message); winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message);
} else if (active) {
winston.info('[reset] Plugin `%s` disabled', pluginId);
} else { } else {
if (active) { winston.warn('[reset] Plugin `%s` was not active on this forum', pluginId);
winston.info('[reset] Plugin `%s` disabled', pluginId); winston.info('[reset] No action taken.');
} else { err = new Error('plugin-not-active');
winston.warn('[reset] Plugin `%s` was not active on this forum', pluginId);
winston.info('[reset] No action taken.');
err = new Error('plugin-not-active');
}
} }
callback(err); callback(err);

@ -46,12 +46,10 @@ module.exports = function (SocketTopics) {
if (reverse) { if (reverse) {
start = results.topic.postcount - start; start = results.topic.postcount - start;
} }
} else if (reverse) {
start = results.topic.postcount - start - infScrollPostsPerPage - 1;
} else { } else {
if (reverse) { start = start - infScrollPostsPerPage - 1;
start = results.topic.postcount - start - infScrollPostsPerPage - 1;
} else {
start = start - infScrollPostsPerPage - 1;
}
} }
var stop = start + (infScrollPostsPerPage - 1); var stop = start + (infScrollPostsPerPage - 1);

Loading…
Cancel
Save