chore: eslint prefer-template

This commit is contained in:
Peter Jaszkowiak
2021-02-03 23:59:08 -07:00
committed by Julian Lam
parent 4ee0f1459d
commit 707b55b6a5
357 changed files with 2425 additions and 2427 deletions

View File

@@ -163,9 +163,9 @@ groupsAPI.leave = async function (caller, data) {
const username = await user.getUserField(data.uid, 'username');
const notification = await notifications.create({
type: 'group-leave',
bodyShort: '[[groups:membership.leave.notification_title, ' + username + ', ' + groupName + ']]',
nid: 'group:' + validator.escape(groupName) + ':uid:' + data.uid + ':group-leave',
path: '/groups/' + slugify(groupName),
bodyShort: `[[groups:membership.leave.notification_title, ${username}, ${groupName}]]`,
nid: `group:${validator.escape(groupName)}:uid:${data.uid}:group-leave`,
path: `/groups/${slugify(groupName)}`,
from: data.uid,
});
const uids = await groups.getOwners(groupName);

View File

@@ -70,7 +70,7 @@ async function logTopicAction(action, req, tid, title) {
return;
}
await events.log({
type: 'topic-' + action,
type: `topic-${action}`,
uid: req.uid,
ip: req.ip,
tid: tid,
@@ -88,7 +88,7 @@ exports.postCommand = async function (caller, command, eventName, notification,
}
if (!data.room_id) {
throw new Error('[[error:invalid-room-id, ' + data.room_id + ' ]]');
throw new Error(`[[error:invalid-room-id, ${data.room_id} ]]`);
}
const [exists, deleted] = await Promise.all([
posts.exists(data.pid),
@@ -111,7 +111,7 @@ exports.postCommand = async function (caller, command, eventName, notification,
filter:post.bookmark
filter:post.unbookmark
*/
const filteredData = await plugins.hooks.fire('filter:post.' + command, {
const filteredData = await plugins.hooks.fire(`filter:post.${command}`, {
data: data,
uid: caller.uid,
});
@@ -121,8 +121,8 @@ exports.postCommand = async function (caller, command, eventName, notification,
async function executeCommand(caller, command, eventName, notification, data) {
const result = await posts[command](data.pid, caller.uid);
if (result && eventName) {
websockets.in('uid_' + caller.uid).emit('posts.' + command, result);
websockets.in(data.room_id).emit('event:' + eventName, result);
websockets.in(`uid_${caller.uid}`).emit(`posts.${command}`, result);
websockets.in(data.room_id).emit(`event:${eventName}`, result);
}
if (result && command === 'upvote') {
socketHelpers.upvote(result, notification);

View File

@@ -50,13 +50,13 @@ postsAPI.edit = async function (caller, data) {
const contentLen = utils.stripHTMLTags(data.content).trim().length;
if (data.title && data.title.length < meta.config.minimumTitleLength) {
throw new Error('[[error:title-too-short, ' + meta.config.minimumTitleLength + ']]');
throw new Error(`[[error:title-too-short, ${meta.config.minimumTitleLength}]]`);
} else if (data.title && data.title.length > meta.config.maximumTitleLength) {
throw new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]');
throw new Error(`[[error:title-too-long, ${meta.config.maximumTitleLength}]]`);
} else if (meta.config.minimumPostLength !== 0 && contentLen < meta.config.minimumPostLength) {
throw new Error('[[error:content-too-short, ' + meta.config.minimumPostLength + ']]');
throw new Error(`[[error:content-too-short, ${meta.config.minimumPostLength}]]`);
} else if (contentLen > meta.config.maximumPostLength) {
throw new Error('[[error:content-too-long, ' + meta.config.maximumPostLength + ']]');
throw new Error(`[[error:content-too-long, ${meta.config.maximumPostLength}]]`);
}
data.uid = caller.uid;
@@ -81,19 +81,19 @@ postsAPI.edit = async function (caller, data) {
returnData.topic = { ...postObj[0].topic, ...editResult.post.topic };
if (!editResult.post.deleted) {
websockets.in('topic_' + editResult.topic.tid).emit('event:post_edited', editResult);
websockets.in(`topic_${editResult.topic.tid}`).emit('event:post_edited', editResult);
return returnData;
}
const memberData = await groups.getMembersOfGroups([
'administrators',
'Global Moderators',
'cid:' + editResult.topic.cid + ':privileges:moderate',
'cid:' + editResult.topic.cid + ':privileges:groups:moderate',
`cid:${editResult.topic.cid}:privileges:moderate`,
`cid:${editResult.topic.cid}:privileges:groups:moderate`,
]);
const uids = _.uniq(_.flatten(memberData).concat(String(caller.uid)));
uids.forEach(uid => websockets.in('uid_' + uid).emit('event:post_edited', editResult));
uids.forEach(uid => websockets.in(`uid_${uid}`).emit('event:post_edited', editResult));
return returnData;
};
@@ -123,7 +123,7 @@ async function deleteOrRestore(caller, data, params) {
await deleteOrRestoreTopicOf(params.command, data.pid, caller);
}
websockets.in('topic_' + postData.tid).emit(params.event, postData);
websockets.in(`topic_${postData.tid}`).emit(params.event, postData);
await events.log({
type: params.type,
@@ -165,7 +165,7 @@ postsAPI.purge = async function (caller, data) {
require('../posts/cache').del(data.pid);
await posts.purge(data.pid, caller.uid);
websockets.in('topic_' + postData.tid).emit('event:post_purged', postData);
websockets.in(`topic_${postData.tid}`).emit('event:post_purged', postData);
const topicData = await topics.getTopicFields(postData.tid, ['title', 'cid']);
await events.log({
@@ -295,5 +295,5 @@ postsAPI.restoreDiff = async (caller, data) => {
}
const edit = await posts.diffs.restore(data.pid, data.since, caller.uid, apiHelpers.buildReqObject(caller));
websockets.in('topic_' + edit.topic.tid).emit('event:post_edited', edit);
websockets.in(`topic_${edit.topic.tid}`).emit('event:post_edited', edit);
};

View File

@@ -117,7 +117,7 @@ usersAPI.updateSettings = async function (caller, data) {
acpLang: defaults.acpLang,
};
// load raw settings without parsing values to booleans
const current = await db.getObject('user:' + data.uid + ':settings');
const current = await db.getObject(`user:${data.uid}:settings`);
const payload = { ...defaults, ...current, ...data.settings };
delete payload.uid;
@@ -144,10 +144,10 @@ usersAPI.follow = async function (caller, data) {
const userData = await user.getUserFields(caller.uid, ['username', 'userslug']);
const notifObj = await notifications.create({
type: 'follow',
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
nid: 'follow:' + data.uid + ':uid:' + caller.uid,
bodyShort: `[[notifications:user_started_following_you, ${userData.username}]]`,
nid: `follow:${data.uid}:uid:${caller.uid}`,
from: caller.uid,
path: '/uid/' + data.uid + '/followers',
path: `/uid/${data.uid}/followers`,
mergeId: 'notifications:user_started_following_you',
});
if (!notifObj) {
@@ -173,13 +173,13 @@ usersAPI.ban = async function (caller, data) {
}
const banData = await user.bans.ban(data.uid, data.until, data.reason);
await db.setObjectField('uid:' + data.uid + ':ban:' + banData.timestamp, 'fromUid', caller.uid);
await db.setObjectField(`uid:${data.uid}:ban:${banData.timestamp}`, 'fromUid', caller.uid);
if (!data.reason) {
data.reason = await translator.translate('[[user:info.banned-no-reason]]');
}
sockets.in('uid_' + data.uid).emit('event:banned', {
sockets.in(`uid_${data.uid}`).emit('event:banned', {
until: data.until,
reason: validator.escape(String(data.reason || '')),
});
@@ -213,7 +213,7 @@ usersAPI.unban = async function (caller, data) {
await user.bans.unban(data.uid);
sockets.in('uid_' + data.uid).emit('event:unbanned');
sockets.in(`uid_${data.uid}`).emit('event:unbanned');
await events.log({
type: 'user-unban',