more linting

v1.18.x
Julian Lam 8 years ago
parent ddea9f534e
commit 6e7b505ea7

@ -16,7 +16,9 @@ define('forum/flags/list', ['components', 'Chart'], function (components, Chart)
// Parse ajaxify data to set form values to reflect current filters // Parse ajaxify data to set form values to reflect current filters
for (var filter in ajaxify.data.filters) { for (var filter in ajaxify.data.filters) {
filtersEl.find('[name="' + filter + '"]').val(ajaxify.data.filters[filter]); if (ajaxify.data.filters.hasOwnProperty(filter)) {
filtersEl.find('[name="' + filter + '"]').val(ajaxify.data.filters[filter]);
}
} }
filtersEl.find('button').on('click', function () { filtersEl.find('button').on('click', function () {

@ -42,16 +42,14 @@ modsController.flags.list = function (req, res, next) {
if (!filters.cid) { if (!filters.cid) {
// If mod and no cid filter, add filter for their modded categories // If mod and no cid filter, add filter for their modded categories
filters.cid = res.locals.cids; filters.cid = res.locals.cids;
} else { } else if (Array.isArray(filters.cid)) {
// Remove cids they do not moderate // Remove cids they do not moderate
if (Array.isArray(filters.cid)) { filters.cid = filters.cid.filter(function (cid) {
filters.cid = filters.cid.filter(function (cid) { return res.locals.cids.indexOf(String(cid)) !== -1;
return res.locals.cids.indexOf(String(cid)) !== -1; });
}); } else if (res.locals.cids.indexOf(String(filters.cid)) === -1) {
} else if (res.locals.cids.indexOf(String(filters.cid)) === -1) { filters.cid = res.locals.cids;
filters.cid = res.locals.cids; hasFilter = false;
hasFilter = false;
}
} }
} }

@ -92,7 +92,7 @@ file.allowedExtensions = function () {
}; };
file.exists = function (path, callback) { file.exists = function (path, callback) {
fs.stat(path, function (err, stat) { fs.stat(path, function (err) {
if (err) { if (err) {
if (err.code === 'ENOENT') { if (err.code === 'ENOENT') {
return callback(null, false); return callback(null, false);

@ -1,7 +1,6 @@
'use strict'; 'use strict';
var async = require('async'); var async = require('async');
var winston = require('winston');
var db = require('./database'); var db = require('./database');
var user = require('./user'); var user = require('./user');
var groups = require('./groups'); var groups = require('./groups');
@ -69,38 +68,40 @@ Flags.list = function (filters, uid, callback) {
if (Object.keys(filters).length > 0) { if (Object.keys(filters).length > 0) {
for (var type in filters) { for (var type in filters) {
switch (type) { if (filters.hasOwnProperty(type)) {
case 'type': switch (type) {
prepareSets('flags:byType:', filters[type]); case 'type':
break; prepareSets('flags:byType:', filters[type]);
break;
case 'state':
prepareSets('flags:byState:', filters[type]); case 'state':
break; prepareSets('flags:byState:', filters[type]);
break;
case 'reporterId':
prepareSets('flags:byReporter:', filters[type]); case 'reporterId':
break; prepareSets('flags:byReporter:', filters[type]);
break;
case 'assignee':
prepareSets('flags:byAssignee:', filters[type]); case 'assignee':
break; prepareSets('flags:byAssignee:', filters[type]);
break;
case 'targetUid':
prepareSets('flags:byTargetUid:', filters[type]); case 'targetUid':
break; prepareSets('flags:byTargetUid:', filters[type]);
break;
case 'cid':
prepareSets('flags:byCid:', filters[type]); case 'cid':
break; prepareSets('flags:byCid:', filters[type]);
break;
case 'quick':
switch (filters.quick) { case 'quick':
case 'mine': switch (filters.quick) {
sets.push('flags:byAssignee:' + uid); case 'mine':
sets.push('flags:byAssignee:' + uid);
break;
}
break; break;
} }
break;
} }
} }
} }
@ -341,7 +342,7 @@ Flags.create = function (type, id, uid, reason, timestamp, callback) {
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byPid:' + id, timestamp, flagId)); // by target pid
} }
async.parallel(tasks, function (err, data) { async.parallel(tasks, function (err) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -479,7 +480,7 @@ Flags.update = function (flagId, uid, changeset, callback) {
// Fire plugin hook // Fire plugin hook
tasks.push(async.apply(plugins.fireHook, 'action:flag.update', { flagId: flagId, changeset: changeset, uid: uid })); tasks.push(async.apply(plugins.fireHook, 'action:flag.update', { flagId: flagId, changeset: changeset, uid: uid }));
async.parallel(tasks, function (err, data) { async.parallel(tasks, function (err) {
return next(err); return next(err);
}); });
}, },

@ -8,7 +8,6 @@ var topics = require('../topics');
var user = require('../user'); var user = require('../user');
var notifications = require('../notifications'); var notifications = require('../notifications');
var plugins = require('../plugins'); var plugins = require('../plugins');
var flags = require('../flags');
module.exports = function (Posts) { module.exports = function (Posts) {
Posts.delete = function (pid, uid, callback) { Posts.delete = function (pid, uid, callback) {

@ -1,17 +1,8 @@
'use strict'; 'use strict';
var async = require('async'); var async = require('async');
var S = require('string');
var user = require('../user'); var user = require('../user');
var groups = require('../groups');
var posts = require('../posts');
var topics = require('../topics');
var privileges = require('../privileges');
var notifications = require('../notifications');
var plugins = require('../plugins');
var meta = require('../meta');
var utils = require('../../public/src/utils');
var flags = require('../flags'); var flags = require('../flags');
var SocketFlags = {}; var SocketFlags = {};

@ -323,7 +323,6 @@ Upgrade.upgrade = function (callback) {
var batch = require('./batch'); var batch = require('./batch');
var posts = require('./posts'); var posts = require('./posts');
var flags = require('./flags'); var flags = require('./flags');
var migrated = 0;
batch.processSortedSet('posts:pid', function (ids, next) { batch.processSortedSet('posts:pid', function (ids, next) {
posts.getPostsByPids(ids, 1, function (err, posts) { posts.getPostsByPids(ids, 1, function (err, posts) {

@ -3,10 +3,8 @@
var async = require('async'); var async = require('async');
var db = require('../database'); var db = require('../database');
var posts = require('../posts');
var plugins = require('../plugins'); var plugins = require('../plugins');
var winston = require('winston'); var winston = require('winston');
var flags = require('../flags');
module.exports = function (User) { module.exports = function (User) {
User.logIP = function (uid, ip) { User.logIP = function (uid, ip) {

@ -487,9 +487,9 @@ describe('Flags', function () {
describe('(websockets)', function () { describe('(websockets)', function () {
var SocketFlags = require('../src/socket.io/flags.js'); var SocketFlags = require('../src/socket.io/flags.js');
var tid, var tid;
pid, var pid;
flag; var flag;
before(function (done) { before(function (done) {
Topics.post({ Topics.post({

Loading…
Cancel
Save