Skip to content

Commit

Permalink
chore: eslint function-paren-newline
Browse files Browse the repository at this point in the history
  • Loading branch information
pitaj authored and julianlam committed Feb 8, 2021
1 parent dab3b23 commit 62869ba
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 32 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
// "object-curly-newline": ["error", { "consistent": true, "multiline": true }],
"object-curly-newline": "off",
// require consistent linebreaks inline function parenthesis (arguments or params)
// "function-paren-newline": ["error", "consistent"],
"function-paren-newline": "off",
"function-paren-newline": ["error", "consistent"],
// only require const if all parts of destructuring can be const
"prefer-const": ["error", { "destructuring": "all" }],
// don't require destructuring when assigning
Expand Down
16 changes: 9 additions & 7 deletions public/src/admin/manage/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,15 @@ define('admin/manage/users', [

bootbox.confirm(confirmMsg, function (confirm) {
if (confirm) {
Promise.all(uids.map(uid => api.del(`/users/${uid}${path}`, {})
.then(() => {
if (path !== '/content') {
removeRow(uid);
}
})
)).then(() => {
Promise.all(
uids.map(
uid => api.del(`/users/${uid}${path}`, {}).then(() => {
if (path !== '/content') {
removeRow(uid);
}
})
)
).then(() => {
if (path !== '/content') {
app.alertSuccess('[[admin/manage/users:alerts.delete-success]]');
} else {
Expand Down
9 changes: 5 additions & 4 deletions public/src/client/topic/threadTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,11 @@ define('forum/topic/threadTools', [
var icon = $('.topic-header [component="topic/pinned"]');
icon.toggleClass('hidden', !data.pinned);
if (data.pinned) {
icon.translateAttr('title', data.pinExpiry && data.pinExpiryISO ?
'[[topic:pinned-with-expiry, ' + data.pinExpiryISO + ']]' :
'[[topic:pinned]]'
);
icon.translateAttr('title', (
data.pinExpiry && data.pinExpiryISO ?
'[[topic:pinned-with-expiry, ' + data.pinExpiryISO + ']]' :
'[[topic:pinned]]'
));
}
ajaxify.data.pinned = data.pinned;

Expand Down
9 changes: 5 additions & 4 deletions public/src/modules/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ define('api', () => {
function doAjax(cb) {
$.ajax(options)
.done((res) => {
cb(null,
res && res.hasOwnProperty('status') && res.hasOwnProperty('response') ?
res.response : (res || {})
);
cb(null, (
res &&
res.hasOwnProperty('status') &&
res.hasOwnProperty('response') ? res.response : (res || {})
));
})
.fail((ev) => {
let errMessage;
Expand Down
7 changes: 5 additions & 2 deletions src/api/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ async function deleteOrRestore(caller, data, params) {
async function deleteOrRestoreTopicOf(command, pid, caller) {
const topic = await posts.getTopicFields(pid, ['tid', 'cid', 'deleted']);
// command: delete/restore
await apiHelpers.doTopicAction(command,
await apiHelpers.doTopicAction(
command,
topic.deleted ? 'event:topic_restored' : 'event:topic_deleted',
caller,
{ tids: [topic.tid], cid: topic.cid }
Expand Down Expand Up @@ -178,7 +179,9 @@ postsAPI.purge = async function (caller, data) {
});

if (isMainAndLast) {
await apiHelpers.doTopicAction('purge', 'event:topic_purged',
await apiHelpers.doTopicAction(
'purge',
'event:topic_purged',
caller,
{ tids: [postData.tid], cid: topicData.cid }
);
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/admin/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ groupsController.get = async function (req, res, next) {

async function getGroupNames() {
const groupNames = await db.getSortedSetRange('groups:createtime', 0, -1);
return groupNames.filter(name => name !== 'registered-users' &&
return groupNames.filter(name => (
name !== 'registered-users' &&
name !== 'verified-users' &&
name !== 'unverified-users' &&
name !== groups.BANNED_USERS &&
!groups.isPrivilegeGroup(name)
);
));
}

groupsController.getCSV = async function (req, res) {
Expand Down
4 changes: 2 additions & 2 deletions src/database/postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ postgresModule.info = async function (db) {
const res = await db.query(`
SELECT true "postgres",
current_setting('server_version') "version",
EXTRACT(EPOCH FROM NOW() - pg_postmaster_start_time()) * 1000 "uptime"`
);
EXTRACT(EPOCH FROM NOW() - pg_postmaster_start_time()) * 1000 "uptime"
`);
return res.rows[0];
};

Expand Down
3 changes: 2 additions & 1 deletion src/groups/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = function (Groups) {
}
const keys = [];
groupNames.forEach((groupName) => {
keys.push(`group:${groupName}`,
keys.push(
`group:${groupName}`,
`group:${groupName}:members`,
`group:${groupName}:pending`,
`group:${groupName}:invited`,
Expand Down
3 changes: 2 additions & 1 deletion src/groups/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ module.exports = function (Groups) {
const visibleGroups = groupData.filter(groupData => groupData && !groupData.hidden);

if (visibleGroups.length) {
await db.sortedSetAdd('groups:visible:memberCount',
await db.sortedSetAdd(
'groups:visible:memberCount',
visibleGroups.map(groupData => groupData.memberCount),
visibleGroups.map(groupData => groupData.name)
);
Expand Down
4 changes: 3 additions & 1 deletion src/groups/leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ module.exports = function (Groups) {
promises.push(Groups.destroy, emptyPrivilegeGroups);
}
if (visibleGroups.length) {
promises.push(db.sortedSetAdd, 'groups:visible:memberCount',
promises.push(
db.sortedSetAdd,
'groups:visible:memberCount',
visibleGroups.map(groupData => groupData.memberCount),
visibleGroups.map(groupData => groupData.name)
);
Expand Down
12 changes: 8 additions & 4 deletions src/upgrades/1.14.1/readd_deleted_recent_topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ module.exports = {
}
});

await db.sortedSetAdd('topics:recent',
await db.sortedSetAdd(
'topics:recent',
topicData.map(t => t.lastposttime || 0),
topicData.map(t => t.tid)
);

await db.sortedSetAdd('topics:views',
await db.sortedSetAdd(
'topics:views',
topicData.map(t => t.viewcount || 0),
topicData.map(t => t.tid)
);

await db.sortedSetAdd('topics:posts',
await db.sortedSetAdd(
'topics:posts',
topicData.map(t => t.postcount || 0),
topicData.map(t => t.tid)
);

await db.sortedSetAdd('topics:votes',
await db.sortedSetAdd(
'topics:votes',
topicData.map(t => t.votes || 0),
topicData.map(t => t.tid)
);
Expand Down
6 changes: 4 additions & 2 deletions src/user/jobs/export-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ async function getRoomMessages(uid, roomId) {
let data = [];
await batch.processSortedSet(`uid:${uid}:chat:room:${roomId}:mids`, async (mids) => {
const messageData = await db.getObjects(mids.map(mid => `message:${mid}`));
data = data.concat(messageData.filter(m => m && m.fromuid === uid && !m.system)
.map(m => ({ content: m.content, timestamp: m.timestamp }))
data = data.concat(
messageData
.filter(m => m && m.fromuid === uid && !m.system)
.map(m => ({ content: m.content, timestamp: m.timestamp }))
);
}, { batch: 500, interval: 1000 });
return data;
Expand Down

0 comments on commit 62869ba

Please sign in to comment.