`);
+ }
$(singleIconEl).html(
`
`
@@ -87,14 +91,18 @@ export default Component.extend({
style += `background-color: #${flairBackgroundHexColor};`;
}
- if (flairHexColor) style += `color: #${flairHexColor};`;
+ if (flairHexColor) {
+ style += `color: #${flairHexColor};`;
+ }
return htmlSafe(style);
},
@discourseComputed("model.flairBackgroundHexColor")
flairPreviewClasses(flairBackgroundHexColor) {
- if (flairBackgroundHexColor) return "rounded";
+ if (flairBackgroundHexColor) {
+ return "rounded";
+ }
},
@discourseComputed("flairPreviewImage")
diff --git a/app/assets/javascripts/discourse/app/components/group-selector.js b/app/assets/javascripts/discourse/app/components/group-selector.js
index b956fb6802..2516de122c 100644
--- a/app/assets/javascripts/discourse/app/components/group-selector.js
+++ b/app/assets/javascripts/discourse/app/components/group-selector.js
@@ -15,8 +15,9 @@ export default Component.extend({
@observes("groupNames")
_update() {
- if (this.canReceiveUpdates === "true")
+ if (this.canReceiveUpdates === "true") {
this._initializeAutocomplete({ updateData: true });
+ }
},
@on("didInsertElement")
@@ -49,7 +50,9 @@ export default Component.extend({
},
dataSource: (term) => {
return this.groupFinder(term).then((groups) => {
- if (!selectedGroups) return groups;
+ if (!selectedGroups) {
+ return groups;
+ }
return groups.filter((group) => {
return !selectedGroups.any((s) => s === group.name);
diff --git a/app/assets/javascripts/discourse/app/components/groups-form-profile-fields.js b/app/assets/javascripts/discourse/app/components/groups-form-profile-fields.js
index 16d69d8433..e6c2af54ba 100644
--- a/app/assets/javascripts/discourse/app/components/groups-form-profile-fields.js
+++ b/app/assets/javascripts/discourse/app/components/groups-form-profile-fields.js
@@ -32,7 +32,9 @@ export default Component.extend({
@observes("nameInput")
_validateName() {
- if (this.nameInput === this.get("model.name")) return;
+ if (this.nameInput === this.get("model.name")) {
+ return;
+ }
if (this.nameInput === undefined) {
return this._failedInputValidation();
@@ -63,7 +65,9 @@ export default Component.extend({
},
checkGroupName: discourseDebounce(function () {
- if (isEmpty(this.nameInput)) return;
+ if (isEmpty(this.nameInput)) {
+ return;
+ }
Group.checkName(this.nameInput)
.then((response) => {
@@ -99,7 +103,9 @@ export default Component.extend({
this.set("disableSave", true);
const options = { failed: true };
- if (reason) options.reason = reason;
+ if (reason) {
+ options.reason = reason;
+ }
this.set("basicNameValidation", EmberObject.create(options));
},
});
diff --git a/app/assets/javascripts/discourse/app/components/image-uploader.js b/app/assets/javascripts/discourse/app/components/image-uploader.js
index e30bbe8e30..c292d20641 100644
--- a/app/assets/javascripts/discourse/app/components/image-uploader.js
+++ b/app/assets/javascripts/discourse/app/components/image-uploader.js
@@ -54,7 +54,9 @@ export default Component.extend(UploadMixin, {
@discourseComputed("imageUrl")
imageBaseName(imageUrl) {
- if (isEmpty(imageUrl)) return;
+ if (isEmpty(imageUrl)) {
+ return;
+ }
return imageUrl.split("/").slice(-1)[0];
},
@@ -86,7 +88,9 @@ export default Component.extend(UploadMixin, {
},
_applyLightbox() {
- if (this.imageUrl) next(() => lightbox(this.element, this.siteSettings));
+ if (this.imageUrl) {
+ next(() => lightbox(this.element, this.siteSettings));
+ }
},
actions: {
diff --git a/app/assets/javascripts/discourse/app/components/invite-link-panel.js b/app/assets/javascripts/discourse/app/components/invite-link-panel.js
index 93d7d7355e..793b742617 100644
--- a/app/assets/javascripts/discourse/app/components/invite-link-panel.js
+++ b/app/assets/javascripts/discourse/app/components/invite-link-panel.js
@@ -30,9 +30,15 @@ export default Component.extend({
@discourseComputed("isStaff", "inviteModel.saving", "maxRedemptionAllowed")
disabled(isStaff, saving, canInviteTo, maxRedemptionAllowed) {
- if (saving) return true;
- if (!isStaff) return true;
- if (maxRedemptionAllowed < 2) return true;
+ if (saving) {
+ return true;
+ }
+ if (!isStaff) {
+ return true;
+ }
+ if (maxRedemptionAllowed < 2) {
+ return true;
+ }
return false;
},
diff --git a/app/assets/javascripts/discourse/app/components/invite-panel.js b/app/assets/javascripts/discourse/app/components/invite-panel.js
index 5fdf581557..703195ae9a 100644
--- a/app/assets/javascripts/discourse/app/components/invite-panel.js
+++ b/app/assets/javascripts/discourse/app/components/invite-panel.js
@@ -57,8 +57,12 @@ export default Component.extend({
saving,
can_invite_to
) {
- if (saving) return true;
- if (isEmpty(emailOrUsername)) return true;
+ if (saving) {
+ return true;
+ }
+ if (isEmpty(emailOrUsername)) {
+ return true;
+ }
const emailTrimmed = emailOrUsername.trim();
@@ -77,7 +81,9 @@ export default Component.extend({
return true;
}
- if (can_invite_to) return false;
+ if (can_invite_to) {
+ return false;
+ }
return false;
},
@@ -98,9 +104,15 @@ export default Component.extend({
groupIds,
hasCustomMessage
) {
- if (hasCustomMessage) return true;
- if (saving) return true;
- if (isEmpty(emailOrUsername)) return true;
+ if (hasCustomMessage) {
+ return true;
+ }
+ if (saving) {
+ return true;
+ }
+ if (isEmpty(emailOrUsername)) {
+ return true;
+ }
const email = emailOrUsername.trim();
diff --git a/app/assets/javascripts/discourse/app/components/quote-button.js b/app/assets/javascripts/discourse/app/components/quote-button.js
index 0d075dbf54..6665453a3a 100644
--- a/app/assets/javascripts/discourse/app/components/quote-button.js
+++ b/app/assets/javascripts/discourse/app/components/quote-button.js
@@ -16,7 +16,9 @@ import { alias } from "@ember/object/computed";
function getQuoteTitle(element) {
const titleEl = element.querySelector(".title");
- if (!titleEl) return;
+ if (!titleEl) {
+ return;
+ }
return titleEl.textContent.trim().replace(/:$/, "");
}
diff --git a/app/assets/javascripts/discourse/app/components/search-advanced-options.js b/app/assets/javascripts/discourse/app/components/search-advanced-options.js
index ecea3238a9..4667653051 100644
--- a/app/assets/javascripts/discourse/app/components/search-advanced-options.js
+++ b/app/assets/javascripts/discourse/app/components/search-advanced-options.js
@@ -162,14 +162,20 @@ export default Component.extend({
findSearchTerms() {
const searchTerm = escapeExpression(this.searchTerm);
- if (!searchTerm) return [];
+ if (!searchTerm) {
+ return [];
+ }
const blocks = searchTerm.match(REGEXP_BLOCKS);
- if (!blocks) return [];
+ if (!blocks) {
+ return [];
+ }
let result = [];
blocks.forEach((block) => {
- if (block.length !== 0) result.push(block);
+ if (block.length !== 0) {
+ result.push(block);
+ }
});
return result;
@@ -177,11 +183,15 @@ export default Component.extend({
filterBlocks(regexPrefix) {
const blocks = this.findSearchTerms();
- if (!blocks) return [];
+ if (!blocks) {
+ return [];
+ }
let result = [];
blocks.forEach((block) => {
- if (block.search(regexPrefix) !== -1) result.push(block);
+ if (block.search(regexPrefix) !== -1) {
+ result.push(block);
+ }
});
return result;
@@ -256,7 +266,9 @@ export default Component.extend({
},
setSearchedTermValueForTags() {
- if (!this.siteSettings.tagging_enabled) return;
+ if (!this.siteSettings.tagging_enabled) {
+ return;
+ }
const match = this.filterBlocks(REGEXP_TAGS_PREFIX);
const tags = this.get("searchedTerms.tags");
@@ -455,36 +467,42 @@ export default Component.extend({
const slug = categoryFilter.slug;
if (categoryFilter.parentCategory) {
const parentSlug = categoryFilter.parentCategory.slug;
- if (slugCategoryMatches)
+ if (slugCategoryMatches) {
searchTerm = searchTerm.replace(
slugCategoryMatches[0],
`#${parentSlug}:${slug}`
);
- else if (idCategoryMatches)
+ } else if (idCategoryMatches) {
searchTerm = searchTerm.replace(
idCategoryMatches[0],
`category:${id}`
);
- else searchTerm += ` #${parentSlug}:${slug}`;
+ } else {
+ searchTerm += ` #${parentSlug}:${slug}`;
+ }
this._updateSearchTerm(searchTerm);
} else {
- if (slugCategoryMatches)
+ if (slugCategoryMatches) {
searchTerm = searchTerm.replace(slugCategoryMatches[0], `#${slug}`);
- else if (idCategoryMatches)
+ } else if (idCategoryMatches) {
searchTerm = searchTerm.replace(
idCategoryMatches[0],
`category:${id}`
);
- else searchTerm += ` #${slug}`;
+ } else {
+ searchTerm += ` #${slug}`;
+ }
this._updateSearchTerm(searchTerm);
}
} else {
- if (slugCategoryMatches)
+ if (slugCategoryMatches) {
searchTerm = searchTerm.replace(slugCategoryMatches[0], "");
- if (idCategoryMatches)
+ }
+ if (idCategoryMatches) {
searchTerm = searchTerm.replace(idCategoryMatches[0], "");
+ }
this._updateSearchTerm(searchTerm);
}
diff --git a/app/assets/javascripts/discourse/app/components/second-factor-input.js b/app/assets/javascripts/discourse/app/components/second-factor-input.js
index 98ae605703..f1a2ac9fcd 100644
--- a/app/assets/javascripts/discourse/app/components/second-factor-input.js
+++ b/app/assets/javascripts/discourse/app/components/second-factor-input.js
@@ -5,20 +5,31 @@ import { SECOND_FACTOR_METHODS } from "discourse/models/user";
export default Component.extend({
@discourseComputed("secondFactorMethod")
type(secondFactorMethod) {
- if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) return "tel";
- if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) return "text";
+ if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
+ return "tel";
+ }
+ if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) {
+ return "text";
+ }
},
@discourseComputed("secondFactorMethod")
pattern(secondFactorMethod) {
- if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) return "[0-9]{6}";
- if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE)
+ if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
+ return "[0-9]{6}";
+ }
+ if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) {
return "[a-z0-9]{16}";
+ }
},
@discourseComputed("secondFactorMethod")
maxlength(secondFactorMethod) {
- if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) return "6";
- if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) return "32";
+ if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
+ return "6";
+ }
+ if (secondFactorMethod === SECOND_FACTOR_METHODS.BACKUP_CODE) {
+ return "32";
+ }
},
});
diff --git a/app/assets/javascripts/discourse/app/components/site-header.js b/app/assets/javascripts/discourse/app/components/site-header.js
index d69bfbd20c..3784dcf4b4 100644
--- a/app/assets/javascripts/discourse/app/components/site-header.js
+++ b/app/assets/javascripts/discourse/app/components/site-header.js
@@ -161,7 +161,9 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
const $header = $("header.d-header");
if (this.docAt === null) {
- if (!($header && $header.length === 1)) return;
+ if (!($header && $header.length === 1)) {
+ return;
+ }
this.docAt = $header.offset().top;
}
diff --git a/app/assets/javascripts/discourse/app/components/tag-info.js b/app/assets/javascripts/discourse/app/components/tag-info.js
index 15cb3a3f30..5dc585f2d5 100644
--- a/app/assets/javascripts/discourse/app/components/tag-info.js
+++ b/app/assets/javascripts/discourse/app/components/tag-info.js
@@ -89,7 +89,9 @@ export default Component.extend({
bootbox.confirm(
I18n.t("tagging.delete_synonym_confirm", { tag_name: tag.text }),
(result) => {
- if (!result) return;
+ if (!result) {
+ return;
+ }
tag
.destroyRecord()
@@ -106,7 +108,9 @@ export default Component.extend({
tag_name: this.tagInfo.name,
}),
(result) => {
- if (!result) return;
+ if (!result) {
+ return;
+ }
ajax(`/tag/${this.tagInfo.name}/synonyms`, {
type: "POST",
diff --git a/app/assets/javascripts/discourse/app/components/text-field.js b/app/assets/javascripts/discourse/app/components/text-field.js
index 35c1f8bc11..1a90c69340 100644
--- a/app/assets/javascripts/discourse/app/components/text-field.js
+++ b/app/assets/javascripts/discourse/app/components/text-field.js
@@ -82,7 +82,9 @@ export default TextField.extend({
@discourseComputed("placeholderKey")
placeholder: {
get() {
- if (this._placeholder) return this._placeholder;
+ if (this._placeholder) {
+ return this._placeholder;
+ }
return this.placeholderKey ? I18n.t(this.placeholderKey) : "";
},
set(value) {
diff --git a/app/assets/javascripts/discourse/app/components/time-input.js b/app/assets/javascripts/discourse/app/components/time-input.js
index e40b9edd03..0163ee1dd9 100644
--- a/app/assets/javascripts/discourse/app/components/time-input.js
+++ b/app/assets/javascripts/discourse/app/components/time-input.js
@@ -150,10 +150,18 @@ export default Component.extend({
if (typeof time === "string" && time.length) {
let [hours, minutes] = time.split(":");
if (hours && minutes) {
- if (hours < 0) hours = 0;
- if (hours > 23) hours = 23;
- if (minutes < 0) minutes = 0;
- if (minutes > 59) minutes = 59;
+ if (hours < 0) {
+ hours = 0;
+ }
+ if (hours > 23) {
+ hours = 23;
+ }
+ if (minutes < 0) {
+ minutes = 0;
+ }
+ if (minutes > 59) {
+ minutes = 59;
+ }
this.onChange({
hours: parseInt(hours, 10),
diff --git a/app/assets/javascripts/discourse/app/components/topic-list.js b/app/assets/javascripts/discourse/app/components/topic-list.js
index d6e19135fb..178fe9c82d 100644
--- a/app/assets/javascripts/discourse/app/components/topic-list.js
+++ b/app/assets/javascripts/discourse/app/components/topic-list.js
@@ -59,13 +59,17 @@ export default Component.extend(LoadMore, {
scrolled() {
this._super(...arguments);
let onScroll = this.onScroll;
- if (!onScroll) return;
+ if (!onScroll) {
+ return;
+ }
onScroll.call(this);
},
scrollToLastPosition() {
- if (!this.scrollOnLoad) return;
+ if (!this.scrollOnLoad) {
+ return;
+ }
let scrollTo = this.session.get("topicListScrollPosition");
if (scrollTo && scrollTo >= 0) {
diff --git a/app/assets/javascripts/discourse/app/components/topic-progress.js b/app/assets/javascripts/discourse/app/components/topic-progress.js
index 6bfb92a076..1fa674c713 100644
--- a/app/assets/javascripts/discourse/app/components/topic-progress.js
+++ b/app/assets/javascripts/discourse/app/components/topic-progress.js
@@ -145,7 +145,9 @@ export default Component.extend({
_dock() {
const $wrapper = $(this.element);
- if (!$wrapper || $wrapper.length === 0) return;
+ if (!$wrapper || $wrapper.length === 0) {
+ return;
+ }
const $html = $("html");
const offset = window.pageYOffset || $html.scrollTop();
diff --git a/app/assets/javascripts/discourse/app/components/topic-timer-info.js b/app/assets/javascripts/discourse/app/components/topic-timer-info.js
index 177b5d9d6e..da3ce4e7e2 100644
--- a/app/assets/javascripts/discourse/app/components/topic-timer-info.js
+++ b/app/assets/javascripts/discourse/app/components/topic-timer-info.js
@@ -41,7 +41,9 @@ export default Component.extend({
const topicStatus = this.topicClosed ? "close" : "open";
const topicStatusKnown = this.topicClosed !== undefined;
- if (topicStatusKnown && topicStatus === this.statusType) return;
+ if (topicStatusKnown && topicStatus === this.statusType) {
+ return;
+ }
const statusUpdateAt = moment(this.executeAt);
const duration = moment.duration(statusUpdateAt - moment());
diff --git a/app/assets/javascripts/discourse/app/controllers/change-timestamp.js b/app/assets/javascripts/discourse/app/controllers/change-timestamp.js
index 81bd5e5b0a..309555915f 100644
--- a/app/assets/javascripts/discourse/app/controllers/change-timestamp.js
+++ b/app/assets/javascripts/discourse/app/controllers/change-timestamp.js
@@ -32,7 +32,9 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("saving", "date", "validTimestamp")
buttonDisabled(saving, date, validTimestamp) {
- if (saving || validTimestamp) return true;
+ if (saving || validTimestamp) {
+ return true;
+ }
return isEmpty(date);
},
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 37421ae7a4..5e6ecde349 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -223,15 +223,20 @@ export default Controller.extend({
@discourseComputed("model.action", "isWhispering")
saveIcon(modelAction, isWhispering) {
- if (isWhispering) return "far-eye-slash";
+ if (isWhispering) {
+ return "far-eye-slash";
+ }
return SAVE_ICONS[modelAction];
},
@discourseComputed("model.action", "isWhispering", "model.editConflict")
saveLabel(modelAction, isWhispering, editConflict) {
- if (editConflict) return "composer.overwrite_edit";
- else if (isWhispering) return "composer.create_whisper";
+ if (editConflict) {
+ return "composer.overwrite_edit";
+ } else if (isWhispering) {
+ return "composer.create_whisper";
+ }
return SAVE_LABELS[modelAction];
},
@@ -361,13 +366,21 @@ export default Controller.extend({
openComposer(options, post, topic) {
this.open(options).then(() => {
let url;
- if (post) url = post.url;
- if (!post && topic) url = topic.url;
+ if (post) {
+ url = post.url;
+ }
+ if (!post && topic) {
+ url = topic.url;
+ }
let topicTitle;
- if (topic) topicTitle = topic.title;
+ if (topic) {
+ topicTitle = topic.title;
+ }
- if (!url || !topicTitle) return;
+ if (!url || !topicTitle) {
+ return;
+ }
url = `${location.protocol}//${location.host}${url}`;
const link = `[${escapeExpression(topicTitle)}](${url})`;
@@ -613,7 +626,9 @@ export default Controller.extend({
disableSubmit: or("model.loading", "isUploading"),
save(force) {
- if (this.disableSubmit) return;
+ if (this.disableSubmit) {
+ return;
+ }
// Clear the warning state if we're not showing the checkbox anymore
if (!this.showWarning) {
@@ -851,7 +866,9 @@ export default Controller.extend({
composerModel.draftKey === opts.draftKey
) {
composerModel.set("composeState", Composer.OPEN);
- if (!opts.action) return resolve();
+ if (!opts.action) {
+ return resolve();
+ }
}
// If it's a different draft, cancel it and try opening again.
diff --git a/app/assets/javascripts/discourse/app/controllers/create-account.js b/app/assets/javascripts/discourse/app/controllers/create-account.js
index 5fe14eacc5..b0afe35163 100644
--- a/app/assets/javascripts/discourse/app/controllers/create-account.js
+++ b/app/assets/javascripts/discourse/app/controllers/create-account.js
@@ -70,7 +70,9 @@ export default Controller.extend(
@discourseComputed("formSubmitted")
submitDisabled() {
- if (this.formSubmitted) return true;
+ if (this.formSubmitted) {
+ return true;
+ }
return false;
},
@@ -78,8 +80,12 @@ export default Controller.extend(
@discourseComputed("userFields", "hasAtLeastOneLoginButton")
modalBodyClasses(userFields, hasAtLeastOneLoginButton) {
const classes = [];
- if (userFields) classes.push("has-user-fields");
- if (hasAtLeastOneLoginButton) classes.push("has-alt-auth");
+ if (userFields) {
+ classes.push("has-user-fields");
+ }
+ if (hasAtLeastOneLoginButton) {
+ classes.push("has-alt-auth");
+ }
return classes.join(" ");
},
diff --git a/app/assets/javascripts/discourse/app/controllers/discovery/topics.js b/app/assets/javascripts/discourse/app/controllers/discovery/topics.js
index bbef581447..cea98abd74 100644
--- a/app/assets/javascripts/discourse/app/controllers/discovery/topics.js
+++ b/app/assets/javascripts/discourse/app/controllers/discovery/topics.js
@@ -136,7 +136,9 @@ const controllerOpts = {
@discourseComputed("allLoaded", "model.topics.length")
footerMessage(allLoaded, topicsLength) {
- if (!allLoaded) return;
+ if (!allLoaded) {
+ return;
+ }
const category = this.category;
if (category) {
diff --git a/app/assets/javascripts/discourse/app/controllers/edit-category.js b/app/assets/javascripts/discourse/app/controllers/edit-category.js
index f654c7094b..5be7ee4f3c 100644
--- a/app/assets/javascripts/discourse/app/controllers/edit-category.js
+++ b/app/assets/javascripts/discourse/app/controllers/edit-category.js
@@ -58,9 +58,15 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("saving", "model.name", "model.color", "deleting")
disabled(saving, name, color, deleting) {
- if (saving || deleting) return true;
- if (!name) return true;
- if (!color) return true;
+ if (saving || deleting) {
+ return true;
+ }
+ if (!name) {
+ return true;
+ }
+ if (!color) {
+ return true;
+ }
return false;
},
@@ -77,7 +83,9 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("saving", "model.id")
saveLabel(saving, id) {
- if (saving) return "saving";
+ if (saving) {
+ return "saving";
+ }
return id ? "category.save" : "category.create";
},
diff --git a/app/assets/javascripts/discourse/app/controllers/exception.js b/app/assets/javascripts/discourse/app/controllers/exception.js
index d85a899be7..badf33afc8 100644
--- a/app/assets/javascripts/discourse/app/controllers/exception.js
+++ b/app/assets/javascripts/discourse/app/controllers/exception.js
@@ -34,10 +34,14 @@ export default Controller.extend({
@discourseComputed
isNetwork() {
// never made it on the wire
- if (this.get("thrown.readyState") === 0) return true;
+ if (this.get("thrown.readyState") === 0) {
+ return true;
+ }
// timed out
- if (this.get("thrown.jqTextStatus") === "timeout") return true;
+ if (this.get("thrown.jqTextStatus") === "timeout") {
+ return true;
+ }
return false;
},
diff --git a/app/assets/javascripts/discourse/app/controllers/feature-topic.js b/app/assets/javascripts/discourse/app/controllers/feature-topic.js
index 173ba1ecd7..8bf3bb9638 100644
--- a/app/assets/javascripts/discourse/app/controllers/feature-topic.js
+++ b/app/assets/javascripts/discourse/app/controllers/feature-topic.js
@@ -37,8 +37,12 @@ export default Controller.extend(ModalFunctionality, {
)
unPinMessage(categoryLink, pinnedGlobally, pinnedUntil) {
let name = "topic.feature_topic.unpin";
- if (pinnedGlobally) name += "_globally";
- if (moment(pinnedUntil) > moment()) name += "_until";
+ if (pinnedGlobally) {
+ name += "_globally";
+ }
+ if (moment(pinnedUntil) > moment()) {
+ name += "_until";
+ }
const until = moment(pinnedUntil).format("LL");
return I18n.t(name, { categoryLink, until });
diff --git a/app/assets/javascripts/discourse/app/controllers/flag.js b/app/assets/javascripts/discourse/app/controllers/flag.js
index a2e7d87293..b2b81d6061 100644
--- a/app/assets/javascripts/discourse/app/controllers/flag.js
+++ b/app/assets/javascripts/discourse/app/controllers/flag.js
@@ -88,7 +88,9 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("selected.is_custom_flag", "message.length")
submitEnabled() {
const selected = this.selected;
- if (!selected) return false;
+ if (!selected) {
+ return false;
+ }
if (selected.get("is_custom_flag")) {
const len = this.get("message.length") || 0;
diff --git a/app/assets/javascripts/discourse/app/controllers/forgot-password.js b/app/assets/javascripts/discourse/app/controllers/forgot-password.js
index 1a274da48b..3da342f8f4 100644
--- a/app/assets/javascripts/discourse/app/controllers/forgot-password.js
+++ b/app/assets/javascripts/discourse/app/controllers/forgot-password.js
@@ -39,7 +39,9 @@ export default Controller.extend(ModalFunctionality, {
},
resetPassword() {
- if (this.submitDisabled) return false;
+ if (this.submitDisabled) {
+ return false;
+ }
this.set("disabled", true);
this.clearFlash();
diff --git a/app/assets/javascripts/discourse/app/controllers/full-page-search.js b/app/assets/javascripts/discourse/app/controllers/full-page-search.js
index 89c158172a..032b438c8e 100644
--- a/app/assets/javascripts/discourse/app/controllers/full-page-search.js
+++ b/app/assets/javascripts/discourse/app/controllers/full-page-search.js
@@ -312,7 +312,9 @@ export default Controller.extend({
search() {
this.set("page", 1);
this._search();
- if (this.site.mobileView) this.set("expanded", false);
+ if (this.site.mobileView) {
+ this.set("expanded", false);
+ }
},
toggleAdvancedSearch() {
diff --git a/app/assets/javascripts/discourse/app/controllers/group-manage-logs.js b/app/assets/javascripts/discourse/app/controllers/group-manage-logs.js
index 9c881c69e3..48cd8e2d6b 100644
--- a/app/assets/javascripts/discourse/app/controllers/group-manage-logs.js
+++ b/app/assets/javascripts/discourse/app/controllers/group-manage-logs.js
@@ -56,7 +56,9 @@ export default Controller.extend({
@action
loadMore() {
- if (this.get("model.all_loaded")) return;
+ if (this.get("model.all_loaded")) {
+ return;
+ }
this.set("loading", true);
diff --git a/app/assets/javascripts/discourse/app/controllers/login.js b/app/assets/javascripts/discourse/app/controllers/login.js
index d3d5fa0d3c..94468d4bae 100644
--- a/app/assets/javascripts/discourse/app/controllers/login.js
+++ b/app/assets/javascripts/discourse/app/controllers/login.js
@@ -70,8 +70,12 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("awaitingApproval", "hasAtLeastOneLoginButton")
modalBodyClasses(awaitingApproval, hasAtLeastOneLoginButton) {
const classes = ["login-modal"];
- if (awaitingApproval) classes.push("awaiting-approval");
- if (hasAtLeastOneLoginButton) classes.push("has-alt-auth");
+ if (awaitingApproval) {
+ classes.push("awaiting-approval");
+ }
+ if (hasAtLeastOneLoginButton) {
+ classes.push("has-alt-auth");
+ }
return classes.join(" ");
},
@@ -183,7 +187,9 @@ export default Controller.extend(ModalFunctionality, {
"hidden-login-form"
);
const applyHiddenFormInputValue = (value, key) => {
- if (!hiddenLoginForm) return;
+ if (!hiddenLoginForm) {
+ return;
+ }
hiddenLoginForm.querySelector(`input[name=${key}]`).value = value;
};
@@ -332,7 +338,9 @@ export default Controller.extend(ModalFunctionality, {
showModal("login");
next(() => {
- if (callback) callback();
+ if (callback) {
+ callback();
+ }
this.flash(errorMsg, className || "success");
});
};
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/account.js b/app/assets/javascripts/discourse/app/controllers/preferences/account.js
index 7a2d57375f..f033cdc1f7 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/account.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/account.js
@@ -296,7 +296,9 @@ export default Controller.extend(CanCheckEmails, {
}
)
.then(() => {
- if (!token) logout(); // All sessions revoked
+ if (!token) {
+ logout();
+ } // All sessions revoked
})
.catch(popupAjaxError);
},
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/email.js b/app/assets/javascripts/discourse/app/controllers/preferences/email.js
index 53a2cf6c7d..f18ed92c99 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/email.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/email.js
@@ -35,8 +35,12 @@ export default Controller.extend({
@discourseComputed("saving", "new")
saveButtonText(saving, isNew) {
- if (saving) return I18n.t("saving");
- if (isNew) return I18n.t("user.add_email.add");
+ if (saving) {
+ return I18n.t("saving");
+ }
+ if (isNew) {
+ return I18n.t("user.add_email.add");
+ }
return I18n.t("user.change");
},
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
index 54137cb6df..ba3b14f2cb 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/interface.js
@@ -381,9 +381,13 @@ export default Controller.extend({
});
const darkStylesheet = document.querySelector("link#cs-preview-dark"),
lightStylesheet = document.querySelector("link#cs-preview-light");
- if (darkStylesheet) darkStylesheet.remove();
+ if (darkStylesheet) {
+ darkStylesheet.remove();
+ }
- if (lightStylesheet) lightStylesheet.remove();
+ if (lightStylesheet) {
+ lightStylesheet.remove();
+ }
},
},
});
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/second-factor.js b/app/assets/javascripts/discourse/app/controllers/preferences/second-factor.js
index ca565e79df..c1746d4ed9 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/second-factor.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/second-factor.js
@@ -93,7 +93,9 @@ export default Controller.extend(CanCheckEmails, {
actions: {
confirmPassword() {
- if (!this.password) return;
+ if (!this.password) {
+ return;
+ }
this.markDirty();
this.loadSecondFactors();
this.set("password", null);
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/username.js b/app/assets/javascripts/discourse/app/controllers/preferences/username.js
index ba78a7a7be..707b08e745 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/username.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/username.js
@@ -38,8 +38,12 @@ export default Controller.extend({
this.set("taken", false);
this.set("errorMessage", null);
- if (isEmpty(this.newUsername)) return;
- if (this.unchanged) return;
+ if (isEmpty(this.newUsername)) {
+ return;
+ }
+ if (this.unchanged) {
+ return;
+ }
User.checkUsername(newUsername, undefined, this.get("model.id")).then(
(result) => {
@@ -55,7 +59,9 @@ export default Controller.extend({
@discourseComputed("saving")
saveButtonText(saving) {
- if (saving) return I18n.t("saving");
+ if (saving) {
+ return I18n.t("saving");
+ }
return I18n.t("user.change");
},
diff --git a/app/assets/javascripts/discourse/app/controllers/tags-show.js b/app/assets/javascripts/discourse/app/controllers/tags-show.js
index aa7e3ee56c..86d8258da9 100644
--- a/app/assets/javascripts/discourse/app/controllers/tags-show.js
+++ b/app/assets/javascripts/discourse/app/controllers/tags-show.js
@@ -166,7 +166,9 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
}
bootbox.confirm(confirmText, (result) => {
- if (!result) return;
+ if (!result) {
+ return;
+ }
this.tag
.destroyRecord()
diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js
index e74cc34ba0..03f90ce7cf 100644
--- a/app/assets/javascripts/discourse/app/controllers/topic.js
+++ b/app/assets/javascripts/discourse/app/controllers/topic.js
@@ -242,7 +242,9 @@ export default Controller.extend(bufferedProperty("model"), {
},
_loadPostIds(post) {
- if (this.loadingPostIds) return;
+ if (this.loadingPostIds) {
+ return;
+ }
const postStream = this.get("model.postStream");
const url = `/t/${this.get("model.id")}/post_ids.json`;
@@ -805,7 +807,9 @@ export default Controller.extend(bufferedProperty("model"), {
(result) => {
if (result) {
// If all posts are selected, it's the same thing as deleting the topic
- if (this.selectedAllPosts) return this.deleteTopic();
+ if (this.selectedAllPosts) {
+ return this.deleteTopic();
+ }
Post.deleteMany(this.selectedPostIds);
this.get("model.postStream.posts").forEach(
@@ -1317,7 +1321,9 @@ export default Controller.extend(bufferedProperty("model"), {
topic.reload().then(() => {
this.send("postChangedRoute", topic.get("post_number") || 1);
this.appEvents.trigger("header:update-topic", topic);
- if (data.refresh_stream) postStream.refresh();
+ if (data.refresh_stream) {
+ postStream.refresh();
+ }
});
return;
@@ -1413,14 +1419,18 @@ export default Controller.extend(bufferedProperty("model"), {
_scrollToPost: discourseDebounce(function (postNumber) {
const $post = $(`.topic-post article#post_${postNumber}`);
- if ($post.length === 0 || isElementInViewport($post)) return;
+ if ($post.length === 0 || isElementInViewport($post)) {
+ return;
+ }
$("html, body").animate({ scrollTop: $post.offset().top }, 1000);
}, 500),
unsubscribe() {
// never unsubscribe when navigating from topic to topic
- if (!this.get("model.id")) return;
+ if (!this.get("model.id")) {
+ return;
+ }
this.messageBus.unsubscribe("/topic/*");
},
diff --git a/app/assets/javascripts/discourse/app/controllers/user-topics-list.js b/app/assets/javascripts/discourse/app/controllers/user-topics-list.js
index b92738b052..1480d4633e 100644
--- a/app/assets/javascripts/discourse/app/controllers/user-topics-list.js
+++ b/app/assets/javascripts/discourse/app/controllers/user-topics-list.js
@@ -44,7 +44,9 @@ export default Controller.extend({
unsubscribe() {
const channel = this.channel;
- if (channel) this.messageBus.unsubscribe(channel);
+ if (channel) {
+ this.messageBus.unsubscribe(channel);
+ }
this._resetTracking();
this.set("channel", null);
},
diff --git a/app/assets/javascripts/discourse/app/helpers/category-link.js b/app/assets/javascripts/discourse/app/helpers/category-link.js
index 906c40d8b2..63e8bc695d 100644
--- a/app/assets/javascripts/discourse/app/helpers/category-link.js
+++ b/app/assets/javascripts/discourse/app/helpers/category-link.js
@@ -47,8 +47,9 @@ export function categoryBadgeHTML(category, opts) {
(!opts.allowUncategorized &&
get(category, "id") === Site.currentProp("uncategorized_category_id") &&
siteSettings.suppress_uncategorized_badge)
- )
+ ) {
return "";
+ }
const depth = (opts.depth || 1) + 1;
if (opts.recursive && depth <= siteSettings.max_category_nesting) {
diff --git a/app/assets/javascripts/discourse/app/helpers/cold-age-class.js b/app/assets/javascripts/discourse/app/helpers/cold-age-class.js
index 2383774eae..06f269e3b6 100644
--- a/app/assets/javascripts/discourse/app/helpers/cold-age-class.js
+++ b/app/assets/javascripts/discourse/app/helpers/cold-age-class.js
@@ -19,12 +19,15 @@ registerUnbound("cold-age-class", function (dt, params) {
epochDays = daysSinceEpoch(new Date(dt));
let siteSettings = helperContext().siteSettings;
- if (nowDays - epochDays > siteSettings.cold_age_days_high)
+ if (nowDays - epochDays > siteSettings.cold_age_days_high) {
return className + " coldmap-high";
- if (nowDays - epochDays > siteSettings.cold_age_days_medium)
+ }
+ if (nowDays - epochDays > siteSettings.cold_age_days_medium) {
return className + " coldmap-med";
- if (nowDays - epochDays > siteSettings.cold_age_days_low)
+ }
+ if (nowDays - epochDays > siteSettings.cold_age_days_low) {
return className + " coldmap-low";
+ }
return className;
});
diff --git a/app/assets/javascripts/discourse/app/initializers/badging.js b/app/assets/javascripts/discourse/app/initializers/badging.js
index 835bc6ca8e..f5a73b6436 100644
--- a/app/assets/javascripts/discourse/app/initializers/badging.js
+++ b/app/assets/javascripts/discourse/app/initializers/badging.js
@@ -4,10 +4,14 @@ export default {
after: "message-bus",
initialize(container) {
- if (!navigator.setAppBadge) return; // must have the Badging API
+ if (!navigator.setAppBadge) {
+ return;
+ } // must have the Badging API
const user = container.lookup("current-user:main");
- if (!user) return; // must be logged in
+ if (!user) {
+ return;
+ } // must be logged in
this.notifications =
user.unread_notifications + user.unread_high_priority_notifications;
diff --git a/app/assets/javascripts/discourse/app/initializers/localization.js b/app/assets/javascripts/discourse/app/initializers/localization.js
index 20bf681dfd..266aaf7066 100644
--- a/app/assets/javascripts/discourse/app/initializers/localization.js
+++ b/app/assets/javascripts/discourse/app/initializers/localization.js
@@ -7,7 +7,9 @@ export default {
isVerboseLocalizationEnabled(container) {
const siteSettings = container.lookup("site-settings:main");
- if (siteSettings.verbose_localization) return true;
+ if (siteSettings.verbose_localization) {
+ return true;
+ }
try {
return sessionStorage && sessionStorage.getItem("verbose_localization");
@@ -33,7 +35,9 @@ export default {
let i = 0;
for (; i < segs.length - 1; i++) {
- if (!(segs[i] in node)) node[segs[i]] = {};
+ if (!(segs[i] in node)) {
+ node[segs[i]] = {};
+ }
node = node[segs[i]];
}
diff --git a/app/assets/javascripts/discourse/app/initializers/post-decorations.js b/app/assets/javascripts/discourse/app/initializers/post-decorations.js
index 83bd7a1327..bdc1354636 100644
--- a/app/assets/javascripts/discourse/app/initializers/post-decorations.js
+++ b/app/assets/javascripts/discourse/app/initializers/post-decorations.js
@@ -57,8 +57,9 @@ export default {
api.decorateCookedElement(
(elem) => {
elem.querySelectorAll("video").forEach((video) => {
- if (video.poster && video.poster !== "" && !video.autoplay)
+ if (video.poster && video.poster !== "" && !video.autoplay) {
return;
+ }
const source = video.querySelector("source");
if (source) {
diff --git a/app/assets/javascripts/discourse/app/initializers/signup-cta.js b/app/assets/javascripts/discourse/app/initializers/signup-cta.js
index d08743bc00..48df8e19d0 100644
--- a/app/assets/javascripts/discourse/app/initializers/signup-cta.js
+++ b/app/assets/javascripts/discourse/app/initializers/signup-cta.js
@@ -18,12 +18,24 @@ export default {
screenTrack.keyValueStore = keyValueStore;
// Preconditions
- if (user) return; // must not be logged in
- if (keyValueStore.get("anon-cta-never")) return; // "never show again"
- if (!siteSettings.allow_new_registrations) return;
- if (siteSettings.invite_only) return;
- if (siteSettings.login_required) return;
- if (!siteSettings.enable_signup_cta) return;
+ if (user) {
+ return;
+ } // must not be logged in
+ if (keyValueStore.get("anon-cta-never")) {
+ return;
+ } // "never show again"
+ if (!siteSettings.allow_new_registrations) {
+ return;
+ }
+ if (siteSettings.invite_only) {
+ return;
+ }
+ if (siteSettings.login_required) {
+ return;
+ }
+ if (!siteSettings.enable_signup_cta) {
+ return;
+ }
function checkSignupCtaRequirements() {
if (session.get("showSignupCta")) {
diff --git a/app/assets/javascripts/discourse/app/lib/after-transition.js b/app/assets/javascripts/discourse/app/lib/after-transition.js
index fbb78b82d3..16c57b53cf 100644
--- a/app/assets/javascripts/discourse/app/lib/after-transition.js
+++ b/app/assets/javascripts/discourse/app/lib/after-transition.js
@@ -26,7 +26,9 @@ var transitionEnd = (function () {
export default function (element, callback) {
return $(element).on(transitionEnd, (event) => {
- if (event.target !== event.currentTarget) return;
+ if (event.target !== event.currentTarget) {
+ return;
+ }
return callback(event);
});
}
diff --git a/app/assets/javascripts/discourse/app/lib/ajax.js b/app/assets/javascripts/discourse/app/lib/ajax.js
index 4f0ec22b4d..79fba4949c 100644
--- a/app/assets/javascripts/discourse/app/lib/ajax.js
+++ b/app/assets/javascripts/discourse/app/lib/ajax.js
@@ -129,7 +129,9 @@ export function ajax() {
}
// If it's a parsererror, don't reject
- if (xhr.status === 200) return args.success(xhr);
+ if (xhr.status === 200) {
+ return args.success(xhr);
+ }
// Fill in some extra info
xhr.jqTextStatus = textStatus;
@@ -149,9 +151,12 @@ export function ajax() {
// We default to JSON on GET. If we don't, sometimes if the server doesn't return the proper header
// it will not be parsed as an object.
- if (!args.type) args.type = "GET";
- if (!args.dataType && args.type.toUpperCase() === "GET")
+ if (!args.type) {
+ args.type = "GET";
+ }
+ if (!args.dataType && args.type.toUpperCase() === "GET") {
args.dataType = "json";
+ }
if (args.dataType === "script") {
args.headers["Discourse-Script"] = true;
diff --git a/app/assets/javascripts/discourse/app/lib/autocomplete.js b/app/assets/javascripts/discourse/app/lib/autocomplete.js
index 8a360248bf..b9b32f6ff5 100644
--- a/app/assets/javascripts/discourse/app/lib/autocomplete.js
+++ b/app/assets/javascripts/discourse/app/lib/autocomplete.js
@@ -45,7 +45,9 @@ let inputTimeout;
export default function (options) {
const autocompletePlugin = this;
- if (this.length === 0) return;
+ if (this.length === 0) {
+ return;
+ }
if (options === "destroy" || options.updateData) {
cancel(inputTimeout);
@@ -58,7 +60,9 @@ export default function (options) {
$(window).off("click.autocomplete");
- if (options === "destroy") return;
+ if (options === "destroy") {
+ return;
+ }
}
if (options && options.cancel && this.data("closeAutocomplete")) {
@@ -263,7 +267,9 @@ export default function (options) {
if (div) {
div.hide().remove();
}
- if (autocompleteOptions.length === 0) return;
+ if (autocompleteOptions.length === 0) {
+ return;
+ }
div = $(options.template({ options: autocompleteOptions }));
@@ -295,7 +301,9 @@ export default function (options) {
});
hOffset = 10;
- if (options.treatAsTextarea) vOffset = -32;
+ if (options.treatAsTextarea) {
+ vOffset = -32;
+ }
}
div.css({
@@ -366,7 +374,9 @@ export default function (options) {
}
function updateAutoComplete(r) {
- if (completeStart === null || r === SKIP) return;
+ if (completeStart === null || r === SKIP) {
+ return;
+ }
if (r && r.then && typeof r.then === "function") {
if (div) {
@@ -419,7 +429,9 @@ export default function (options) {
});
function performAutocomplete(e) {
- if ([keys.esc, keys.enter].indexOf(e.which) !== -1) return true;
+ if ([keys.esc, keys.enter].indexOf(e.which) !== -1) {
+ return true;
+ }
let cp = caretPosition(me[0]);
const key = me[0].value[cp - 1];
@@ -483,7 +495,9 @@ export default function (options) {
if (!options.key) {
completeStart = 0;
}
- if (e.which === keys.shift) return;
+ if (e.which === keys.shift) {
+ return;
+ }
if (completeStart === null && e.which === keys.backSpace && options.key) {
c = caretPosition(me[0]);
c -= 1;
@@ -537,7 +551,9 @@ export default function (options) {
switch (e.which) {
case keys.enter:
case keys.tab:
- if (!autocompleteOptions) return true;
+ if (!autocompleteOptions) {
+ return true;
+ }
if (
selectedOption >= 0 &&
(userToComplete = autocompleteOptions[selectedOption])
diff --git a/app/assets/javascripts/discourse/app/lib/autosize.js b/app/assets/javascripts/discourse/app/lib/autosize.js
index 52f6f5a385..9e5f573802 100644
--- a/app/assets/javascripts/discourse/app/lib/autosize.js
+++ b/app/assets/javascripts/discourse/app/lib/autosize.js
@@ -18,7 +18,9 @@ const set =
})();
function assign(ta, { setOverflowX = true, setOverflowY = true } = {}) {
- if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || set.has(ta)) return;
+ if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || set.has(ta)) {
+ return;
+ }
let heightOffset = null;
let overflowY = null;
@@ -165,14 +167,18 @@ function assign(ta, { setOverflowX = true, setOverflowY = true } = {}) {
}
function exportDestroy(ta) {
- if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) return;
+ if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) {
+ return;
+ }
const evt = document.createEvent("Event");
evt.initEvent("autosize:destroy", true, false);
ta.dispatchEvent(evt);
}
function exportUpdate(ta) {
- if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) return;
+ if (!(ta && ta.nodeName && ta.nodeName === "TEXTAREA")) {
+ return;
+ }
const evt = document.createEvent("Event");
evt.initEvent("autosize:update", true, false);
ta.dispatchEvent(evt);
diff --git a/app/assets/javascripts/discourse/app/lib/category-hashtags.js b/app/assets/javascripts/discourse/app/lib/category-hashtags.js
index 7f015c7d49..2aa56c3bbc 100644
--- a/app/assets/javascripts/discourse/app/lib/category-hashtags.js
+++ b/app/assets/javascripts/discourse/app/lib/category-hashtags.js
@@ -23,7 +23,9 @@ export function categoryHashtagTriggerRule(textarea, opts) {
line = line.slice(0, line.length - 1);
// Don't trigger autocomplete when backspacing into a `#category |` => `#category|`
- if (/^#{1}\w+/.test(line)) return false;
+ if (/^#{1}\w+/.test(line)) {
+ return false;
+ }
}
// Don't trigger autocomplete when ATX-style headers are used
diff --git a/app/assets/javascripts/discourse/app/lib/category-tag-search.js b/app/assets/javascripts/discourse/app/lib/category-tag-search.js
index f780c537d0..460e4770cb 100644
--- a/app/assets/javascripts/discourse/app/lib/category-tag-search.js
+++ b/app/assets/javascripts/discourse/app/lib/category-tag-search.js
@@ -73,9 +73,13 @@ export function search(term, siteSettings) {
oldSearch = null;
}
- if (new Date() - cacheTime > 30000) cache = {};
+ if (new Date() - cacheTime > 30000) {
+ cache = {};
+ }
const cached = cache[term];
- if (cached) return cached;
+ if (cached) {
+ return cached;
+ }
const limit = 5;
var categories = Category.search(term, { limit });
diff --git a/app/assets/javascripts/discourse/app/lib/discourse-location.js b/app/assets/javascripts/discourse/app/lib/discourse-location.js
index 4fbb387811..0dff2254c3 100644
--- a/app/assets/javascripts/discourse/app/lib/discourse-location.js
+++ b/app/assets/javascripts/discourse/app/lib/discourse-location.js
@@ -182,7 +182,9 @@ const DiscourseLocation = EmberObject.extend({
// Ignore initial page load popstate event in Chrome
if (!popstateFired) {
popstateFired = true;
- if (url === this._previousURL) return;
+ if (url === this._previousURL) {
+ return;
+ }
}
popstateCallbacks.forEach((cb) => cb(url));
diff --git a/app/assets/javascripts/discourse/app/lib/eyeline.js b/app/assets/javascripts/discourse/app/lib/eyeline.js
index 239a72e068..9190bf05dc 100644
--- a/app/assets/javascripts/discourse/app/lib/eyeline.js
+++ b/app/assets/javascripts/discourse/app/lib/eyeline.js
@@ -62,19 +62,29 @@ Eyeline.prototype.update = function () {
let markSeen = false;
// Make sure the element is visible
- if (!$elem.is(":visible")) return true;
+ if (!$elem.is(":visible")) {
+ return true;
+ }
// It's seen if...
// ...the element is vertically within the top and botom
- if (elemTop <= docViewBottom && elemTop >= docViewTop) markSeen = true;
+ if (elemTop <= docViewBottom && elemTop >= docViewTop) {
+ markSeen = true;
+ }
// ...the element top is above the top and the bottom is below the bottom (large elements)
- if (elemTop <= docViewTop && elemBottom >= docViewBottom) markSeen = true;
+ if (elemTop <= docViewTop && elemBottom >= docViewBottom) {
+ markSeen = true;
+ }
// ...we're at the bottom and the bottom of the element is visible (large bottom elements)
- if (atBottom && elemBottom >= docViewTop) markSeen = true;
+ if (atBottom && elemBottom >= docViewTop) {
+ markSeen = true;
+ }
- if (!markSeen) return true;
+ if (!markSeen) {
+ return true;
+ }
// If you hit the bottom we mark all the elements as seen. Otherwise, just the first one
if (!atBottom) {
diff --git a/app/assets/javascripts/discourse/app/lib/formatter.js b/app/assets/javascripts/discourse/app/lib/formatter.js
index 1fbe19c59d..6415fa08a5 100644
--- a/app/assets/javascripts/discourse/app/lib/formatter.js
+++ b/app/assets/javascripts/discourse/app/lib/formatter.js
@@ -29,13 +29,17 @@ export function toTitleCase(str) {
}
export function longDate(dt) {
- if (!dt) return;
+ if (!dt) {
+ return;
+ }
return moment(dt).format(I18n.t("dates.long_with_year"));
}
// suppress year, if current year
export function longDateNoYear(dt) {
- if (!dt) return;
+ if (!dt) {
+ return;
+ }
if (new Date().getFullYear() !== dt.getFullYear()) {
return moment(dt).format(I18n.t("dates.long_date_with_year"));
@@ -58,8 +62,12 @@ export function updateRelativeAge(elems) {
}
export function autoUpdatingRelativeAge(date, options) {
- if (!date) return "";
- if (+date === +new Date(0)) return "";
+ if (!date) {
+ return "";
+ }
+ if (+date === +new Date(0)) {
+ return "";
+ }
options = options || {};
let format = options.format || "tiny";
@@ -316,7 +324,9 @@ export function number(val) {
let formattedNumber;
val = Math.round(parseFloat(val));
- if (isNaN(val)) val = 0;
+ if (isNaN(val)) {
+ val = 0;
+ }
if (val > 999999) {
formattedNumber = I18n.toNumber(val / 1000000, { precision: 1 });
diff --git a/app/assets/javascripts/discourse/app/lib/highlight-html.js b/app/assets/javascripts/discourse/app/lib/highlight-html.js
index 4839dac9c6..3e7ffd8774 100644
--- a/app/assets/javascripts/discourse/app/lib/highlight-html.js
+++ b/app/assets/javascripts/discourse/app/lib/highlight-html.js
@@ -47,7 +47,9 @@ export default function (node, words, opts = {}) {
.filter(Boolean)
.map((word) => word.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"));
- if (!words.length) return node;
+ if (!words.length) {
+ return node;
+ }
const pattern = `(${words.join(" ")})`;
let flag;
diff --git a/app/assets/javascripts/discourse/app/lib/highlight-search.js b/app/assets/javascripts/discourse/app/lib/highlight-search.js
index bf2ce000c1..cbba3540dd 100644
--- a/app/assets/javascripts/discourse/app/lib/highlight-search.js
+++ b/app/assets/javascripts/discourse/app/lib/highlight-search.js
@@ -13,7 +13,9 @@ export default function (elem, term, opts = {}) {
.map((w) => w.replace(/^"(.*)"$/, "$1"));
const highlightOpts = {};
- if (!opts.defaultClassName) highlightOpts.className = CLASS_NAME;
+ if (!opts.defaultClassName) {
+ highlightOpts.className = CLASS_NAME;
+ }
highlightHTML(elem, words, highlightOpts);
}
}
diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
index 3bb535f5e9..0eddd8bfe8 100644
--- a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
+++ b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
@@ -614,8 +614,12 @@ export default {
// Try scrolling to post above or below.
if ($selected.length !== 0) {
- if (direction === -1 && index === 0) return;
- if (direction === 1 && index === $articles.length - 1) return;
+ if (direction === -1 && index === 0) {
+ return;
+ }
+ if (direction === 1 && index === $articles.length - 1) {
+ return;
+ }
}
$article = $articles.eq(index + direction);
diff --git a/app/assets/javascripts/discourse/app/lib/offset-calculator.js b/app/assets/javascripts/discourse/app/lib/offset-calculator.js
index 2a1ed66c01..c8e43d6302 100644
--- a/app/assets/javascripts/discourse/app/lib/offset-calculator.js
+++ b/app/assets/javascripts/discourse/app/lib/offset-calculator.js
@@ -13,7 +13,9 @@ export default function offsetCalculator() {
const min = minimumOffset();
// on mobile, just use the header
- if ($("html").hasClass("mobile-view")) return min;
+ if ($("html").hasClass("mobile-view")) {
+ return min;
+ }
const $window = $(window);
const windowHeight = $window.height();
@@ -21,7 +23,9 @@ export default function offsetCalculator() {
const topicBottomOffsetTop = $("#topic-bottom").offset().top;
// the footer is bigger than the window, we can scroll down past the last post
- if (documentHeight - windowHeight > topicBottomOffsetTop) return min;
+ if (documentHeight - windowHeight > topicBottomOffsetTop) {
+ return min;
+ }
const scrollTop = $window.scrollTop();
const visibleBottomHeight = scrollTop + windowHeight - topicBottomOffsetTop;
diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.js b/app/assets/javascripts/discourse/app/lib/plugin-api.js
index e1812ff6e7..56fa57a29e 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-api.js
+++ b/app/assets/javascripts/discourse/app/lib/plugin-api.js
@@ -302,7 +302,9 @@ class PluginApi {
} else if (result.emoji) {
iconBody = result.emoji.split("|").map((name) => {
let widgetAttrs = { name };
- if (result.emojiTitle) widgetAttrs.title = true;
+ if (result.emojiTitle) {
+ widgetAttrs.title = true;
+ }
return dec.attach("emoji", widgetAttrs);
});
}
diff --git a/app/assets/javascripts/discourse/app/lib/preload-store.js b/app/assets/javascripts/discourse/app/lib/preload-store.js
index 04fb837d82..9fe7ca3788 100644
--- a/app/assets/javascripts/discourse/app/lib/preload-store.js
+++ b/app/assets/javascripts/discourse/app/lib/preload-store.js
@@ -45,7 +45,9 @@ export default {
},
remove(key) {
- if (this.data[key]) delete this.data[key];
+ if (this.data[key]) {
+ delete this.data[key];
+ }
},
reset() {
diff --git a/app/assets/javascripts/discourse/app/lib/push-notifications.js b/app/assets/javascripts/discourse/app/lib/push-notifications.js
index 59c14defba..40d4f27a2c 100644
--- a/app/assets/javascripts/discourse/app/lib/push-notifications.js
+++ b/app/assets/javascripts/discourse/app/lib/push-notifications.js
@@ -21,8 +21,12 @@ function userAgentVersionChecker(agent, version, mobileView) {
const uaMatch = navigator.userAgent.match(
new RegExp(`${agent}\/(\\d+)\\.\\d`)
);
- if (uaMatch && mobileView) return false;
- if (!uaMatch || parseInt(uaMatch[1], 10) < version) return false;
+ if (uaMatch && mobileView) {
+ return false;
+ }
+ if (!uaMatch || parseInt(uaMatch[1], 10) < version) {
+ return false;
+ }
return true;
}
@@ -77,8 +81,12 @@ export function isPushNotificationsEnabled(user, mobileView) {
}
export function register(user, mobileView, router, appEvents) {
- if (!isPushNotificationsSupported(mobileView)) return;
- if (Notification.permission === "denied" || !user) return;
+ if (!isPushNotificationsSupported(mobileView)) {
+ return;
+ }
+ if (Notification.permission === "denied" || !user) {
+ return;
+ }
navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
serviceWorkerRegistration.pushManager
@@ -106,7 +114,9 @@ export function register(user, mobileView, router, appEvents) {
}
export function subscribe(callback, applicationServerKey, mobileView) {
- if (!isPushNotificationsSupported(mobileView)) return;
+ if (!isPushNotificationsSupported(mobileView)) {
+ return;
+ }
navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
serviceWorkerRegistration.pushManager
@@ -116,7 +126,9 @@ export function subscribe(callback, applicationServerKey, mobileView) {
})
.then((subscription) => {
sendSubscriptionToServer(subscription, true);
- if (callback) callback();
+ if (callback) {
+ callback();
+ }
})
.catch((e) => {
// eslint-disable-next-line no-console
@@ -126,7 +138,9 @@ export function subscribe(callback, applicationServerKey, mobileView) {
}
export function unsubscribe(user, callback, mobileView) {
- if (!isPushNotificationsSupported(mobileView)) return;
+ if (!isPushNotificationsSupported(mobileView)) {
+ return;
+ }
keyValueStore.setItem(userSubscriptionKey(user), "");
navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
@@ -149,6 +163,8 @@ export function unsubscribe(user, callback, mobileView) {
console.error(e);
});
- if (callback) callback();
+ if (callback) {
+ callback();
+ }
});
}
diff --git a/app/assets/javascripts/discourse/app/lib/quote.js b/app/assets/javascripts/discourse/app/lib/quote.js
index 3a04577c76..d965833a6e 100644
--- a/app/assets/javascripts/discourse/app/lib/quote.js
+++ b/app/assets/javascripts/discourse/app/lib/quote.js
@@ -12,7 +12,9 @@ export function buildQuote(post, contents, opts = {}) {
`topic:${opts.topic || post.topic_id}`,
];
- if (opts.full) params.push("full:true");
+ if (opts.full) {
+ params.push("full:true");
+ }
return `[quote="${params.join(", ")}"]\n${contents.trim()}\n[/quote]\n\n`;
}
diff --git a/app/assets/javascripts/discourse/app/lib/reports-loader.js b/app/assets/javascripts/discourse/app/lib/reports-loader.js
index 53c6350201..675f296ef9 100644
--- a/app/assets/javascripts/discourse/app/lib/reports-loader.js
+++ b/app/assets/javascripts/discourse/app/lib/reports-loader.js
@@ -37,8 +37,12 @@ export default {
},
_processQueue() {
- if (_queue.length === 0) return;
- if (_processing >= MAX_CONCURRENCY) return;
+ if (_queue.length === 0) {
+ return;
+ }
+ if (_processing >= MAX_CONCURRENCY) {
+ return;
+ }
_processing++;
diff --git a/app/assets/javascripts/discourse/app/lib/screen-track.js b/app/assets/javascripts/discourse/app/lib/screen-track.js
index ec17c138f6..028d63e3a7 100644
--- a/app/assets/javascripts/discourse/app/lib/screen-track.js
+++ b/app/assets/javascripts/discourse/app/lib/screen-track.js
@@ -168,8 +168,9 @@ export default class {
if (
error.status === 405 &&
error.responseJSON.error_type === "read_only"
- )
+ ) {
return;
+ }
})
.finally(() => {
this._inProgress = false;
diff --git a/app/assets/javascripts/discourse/app/lib/search.js b/app/assets/javascripts/discourse/app/lib/search.js
index 2bf4c36cc0..fe5d7a6cf0 100644
--- a/app/assets/javascripts/discourse/app/lib/search.js
+++ b/app/assets/javascripts/discourse/app/lib/search.js
@@ -133,14 +133,21 @@ export function translateResults(results, opts) {
}
export function searchForTerm(term, opts) {
- if (!opts) opts = {};
+ if (!opts) {
+ opts = {};
+ }
// Only include the data we have
const data = { term: term };
- if (opts.typeFilter) data.type_filter = opts.typeFilter;
- if (opts.searchForId) data.search_for_id = true;
- if (opts.restrictToArchetype)
+ if (opts.typeFilter) {
+ data.type_filter = opts.typeFilter;
+ }
+ if (opts.searchForId) {
+ data.search_for_id = true;
+ }
+ if (opts.restrictToArchetype) {
data.restrict_to_archetype = opts.restrictToArchetype;
+ }
if (opts.searchContext) {
data.search_context = {
diff --git a/app/assets/javascripts/discourse/app/lib/to-markdown.js b/app/assets/javascripts/discourse/app/lib/to-markdown.js
index 8c35f87ca0..78e16d5901 100644
--- a/app/assets/javascripts/discourse/app/lib/to-markdown.js
+++ b/app/assets/javascripts/discourse/app/lib/to-markdown.js
@@ -284,7 +284,9 @@ export class Tag {
const pAttr = (e.parent && e.parent.attributes) || {};
let src = attr.src || pAttr.src;
const base62SHA1 = attr["data-base62-sha1"];
- if (base62SHA1) src = `upload://${base62SHA1}`;
+ if (base62SHA1) {
+ src = `upload://${base62SHA1}`;
+ }
const cssClass = attr.class || pAttr.class;
if (cssClass && cssClass.includes("emoji")) {
diff --git a/app/assets/javascripts/discourse/app/lib/uploads.js b/app/assets/javascripts/discourse/app/lib/uploads.js
index b064635e4a..92e2677e9e 100644
--- a/app/assets/javascripts/discourse/app/lib/uploads.js
+++ b/app/assets/javascripts/discourse/app/lib/uploads.js
@@ -48,13 +48,17 @@ export function validateUploadedFiles(files, opts) {
}
function validateUploadedFile(file, opts) {
- if (opts.skipValidation) return true;
+ if (opts.skipValidation) {
+ return true;
+ }
opts = opts || {};
let user = opts.user;
let staff = user && user.staff;
- if (!authorizesOneOrMoreExtensions(staff, opts.siteSettings)) return false;
+ if (!authorizesOneOrMoreExtensions(staff, opts.siteSettings)) {
+ return false;
+ }
const name = file && file.name;
@@ -190,7 +194,9 @@ export function authorizesAllExtensions(staff, siteSettings) {
}
export function authorizesOneOrMoreExtensions(staff, siteSettings) {
- if (authorizesAllExtensions(staff, siteSettings)) return true;
+ if (authorizesAllExtensions(staff, siteSettings)) {
+ return true;
+ }
return (
siteSettings.authorized_extensions.split("|").filter((ext) => ext).length >
@@ -199,7 +205,9 @@ export function authorizesOneOrMoreExtensions(staff, siteSettings) {
}
export function authorizesOneOrMoreImageExtensions(staff, siteSettings) {
- if (authorizesAllExtensions(staff, siteSettings)) return true;
+ if (authorizesAllExtensions(staff, siteSettings)) {
+ return true;
+ }
return imagesExtensions(staff, siteSettings).length > 0;
}
diff --git a/app/assets/javascripts/discourse/app/lib/utilities.js b/app/assets/javascripts/discourse/app/lib/utilities.js
index b44924bec2..b661ff1881 100644
--- a/app/assets/javascripts/discourse/app/lib/utilities.js
+++ b/app/assets/javascripts/discourse/app/lib/utilities.js
@@ -187,7 +187,9 @@ export function caretPosition(el) {
if (document.selection) {
el.focus();
r = document.selection.createRange();
- if (!r) return 0;
+ if (!r) {
+ return 0;
+ }
re = el.createTextRange();
rc = re.duplicate();
@@ -293,7 +295,9 @@ export function isiPad() {
}
export function safariHacksDisabled() {
- if (iOSWithVisualViewport()) return false;
+ if (iOSWithVisualViewport()) {
+ return false;
+ }
let pref = localStorage.getItem("safari-hacks-disabled");
let result = false;
diff --git a/app/assets/javascripts/discourse/app/mixins/mobile-scroll-direction.js b/app/assets/javascripts/discourse/app/mixins/mobile-scroll-direction.js
index 28ad7c2398..556831fb33 100644
--- a/app/assets/javascripts/discourse/app/mixins/mobile-scroll-direction.js
+++ b/app/assets/javascripts/discourse/app/mixins/mobile-scroll-direction.js
@@ -12,11 +12,14 @@ export default Mixin.create({
const delta = Math.floor(offset - this._lastScroll);
// This is a tiny scroll, so we ignore it.
- if (delta <= MOBILE_SCROLL_TOLERANCE && delta >= -MOBILE_SCROLL_TOLERANCE)
+ if (delta <= MOBILE_SCROLL_TOLERANCE && delta >= -MOBILE_SCROLL_TOLERANCE) {
return;
+ }
// don't calculate when resetting offset (i.e. going to /latest or to next topic in suggested list)
- if (offset === 0) return;
+ if (offset === 0) {
+ return;
+ }
const prevDirection = this.mobileScrollDirection;
const currDirection = delta > 0 ? "down" : null;
diff --git a/app/assets/javascripts/discourse/app/models/action-summary.js b/app/assets/javascripts/discourse/app/models/action-summary.js
index c5a14cdeb1..7680d13110 100644
--- a/app/assets/javascripts/discourse/app/models/action-summary.js
+++ b/app/assets/javascripts/discourse/app/models/action-summary.js
@@ -32,7 +32,9 @@ export default RestModel.extend({
// Perform this action
act(post, opts) {
- if (!opts) opts = {};
+ if (!opts) {
+ opts = {};
+ }
// Mark it as acted
this.setProperties({
diff --git a/app/assets/javascripts/discourse/app/models/badge.js b/app/assets/javascripts/discourse/app/models/badge.js
index 29aec68d4d..894f3fb09d 100644
--- a/app/assets/javascripts/discourse/app/models/badge.js
+++ b/app/assets/javascripts/discourse/app/models/badge.js
@@ -55,7 +55,9 @@ const Badge = RestModel.extend({
},
destroy() {
- if (this.newBadge) return Promise.resolve();
+ if (this.newBadge) {
+ return Promise.resolve();
+ }
return ajax(`/admin/badges/${this.id}`, {
type: "DELETE",
diff --git a/app/assets/javascripts/discourse/app/models/bookmark.js b/app/assets/javascripts/discourse/app/models/bookmark.js
index ab7f18ecb0..0c416b15ba 100644
--- a/app/assets/javascripts/discourse/app/models/bookmark.js
+++ b/app/assets/javascripts/discourse/app/models/bookmark.js
@@ -27,7 +27,9 @@ const Bookmark = RestModel.extend({
},
destroy() {
- if (this.newBookmark) return Promise.resolve();
+ if (this.newBookmark) {
+ return Promise.resolve();
+ }
return ajax(this.url, {
type: "DELETE",
diff --git a/app/assets/javascripts/discourse/app/models/category.js b/app/assets/javascripts/discourse/app/models/category.js
index 0cd60e3e52..5d1c8ce2f2 100644
--- a/app/assets/javascripts/discourse/app/models/category.js
+++ b/app/assets/javascripts/discourse/app/models/category.js
@@ -123,7 +123,9 @@ const Category = RestModel.extend({
const notificationLevelString = Object.keys(NotificationLevels).find(
(key) => NotificationLevels[key] === notificationLevel
);
- if (notificationLevelString) return notificationLevelString.toLowerCase();
+ if (notificationLevelString) {
+ return notificationLevelString.toLowerCase();
+ }
},
@discourseComputed("name")
@@ -314,7 +316,9 @@ Category.reopenClass({
},
slugFor(category, separator = "/", depth = 3) {
- if (!category) return "";
+ if (!category) {
+ return "";
+ }
const parentCategory = get(category, "parentCategory");
let result = "";
@@ -454,7 +458,9 @@ Category.reopenClass({
category = Category.findSingleBySlug(slug);
// If we have a parent category, we need to enforce it
- if (category && category.get("parentCategory")) return;
+ if (category && category.get("parentCategory")) {
+ return;
+ }
}
// In case the slug didn't work, try to find it by id instead.
@@ -529,7 +535,9 @@ Category.reopenClass({
(category.get("name").toLowerCase().indexOf(term) > 0 ||
category.get("slug").toLowerCase().indexOf(slugTerm) > 0)
) {
- if (data.indexOf(category) === -1) data.push(category);
+ if (data.indexOf(category) === -1) {
+ data.push(category);
+ }
}
}
}
diff --git a/app/assets/javascripts/discourse/app/models/composer.js b/app/assets/javascripts/discourse/app/models/composer.js
index 066c23a0a7..7a7054bece 100644
--- a/app/assets/javascripts/discourse/app/models/composer.js
+++ b/app/assets/javascripts/discourse/app/models/composer.js
@@ -392,15 +392,21 @@ const Composer = RestModel.extend({
isStaffUser
) {
// can't submit while loading
- if (loading) return true;
+ if (loading) {
+ return true;
+ }
// title is required when
// - creating a new topic/private message
// - editing the 1st post
- if (canEditTitle && !this.titleLengthValid) return true;
+ if (canEditTitle && !this.titleLengthValid) {
+ return true;
+ }
// reply is always required
- if (missingReplyCharacters > 0) return true;
+ if (missingReplyCharacters > 0) {
+ return true;
+ }
if (
this.site.can_tag_topics &&
@@ -445,8 +451,12 @@ const Composer = RestModel.extend({
@discourseComputed("minimumTitleLength", "titleLength", "post.static_doc")
titleLengthValid(minTitleLength, titleLength, staticDoc) {
- if (this.user.admin && staticDoc && titleLength > 0) return true;
- if (titleLength < minTitleLength) return false;
+ if (this.user.admin && staticDoc && titleLength > 0) {
+ return true;
+ }
+ if (titleLength < minTitleLength) {
+ return false;
+ }
return titleLength <= this.siteSettings.max_topic_title_length;
},
@@ -672,7 +682,9 @@ const Composer = RestModel.extend({
open(opts) {
let promise = Promise.resolve();
- if (!opts) opts = {};
+ if (!opts) {
+ opts = {};
+ }
this.set("loading", true);
const replyBlank = isEmpty(this.reply);
@@ -686,7 +698,9 @@ const Composer = RestModel.extend({
this.set("reply", "");
}
- if (!opts.draftKey) throw new Error("draft key is required");
+ if (!opts.draftKey) {
+ throw new Error("draft key is required");
+ }
if (opts.draftSequence === null) {
throw new Error("draft sequence is required");
@@ -1045,7 +1059,9 @@ const Composer = RestModel.extend({
const category = composer.site.categories.find(
(x) => x.id === (parseInt(createdPost.category, 10) || 1)
);
- if (category) category.incrementProperty("topic_count");
+ if (category) {
+ category.incrementProperty("topic_count");
+ }
}
composer.clearState();
@@ -1094,14 +1110,20 @@ const Composer = RestModel.extend({
},
saveDraft() {
- if (this.draftSaving) return Promise.resolve();
+ if (this.draftSaving) {
+ return Promise.resolve();
+ }
// Do not save when drafts are disabled
- if (this.disableDrafts) return Promise.resolve();
+ if (this.disableDrafts) {
+ return Promise.resolve();
+ }
if (this.canEditTitle) {
// Save title and/or post body
- if (!this.title && !this.reply) return Promise.resolve();
+ if (!this.title && !this.reply) {
+ return Promise.resolve();
+ }
if (
this.title &&
@@ -1113,11 +1135,14 @@ const Composer = RestModel.extend({
}
} else {
// Do not save when there is no reply
- if (!this.reply) return Promise.resolve();
+ if (!this.reply) {
+ return Promise.resolve();
+ }
// Do not save when the reply's length is too small
- if (this.replyLength < this.siteSettings.min_post_length)
+ if (this.replyLength < this.siteSettings.min_post_length) {
return Promise.resolve();
+ }
}
this.setProperties({
diff --git a/app/assets/javascripts/discourse/app/models/invite.js b/app/assets/javascripts/discourse/app/models/invite.js
index 4b839c525d..aa72a55e8e 100644
--- a/app/assets/javascripts/discourse/app/models/invite.js
+++ b/app/assets/javascripts/discourse/app/models/invite.js
@@ -35,11 +35,17 @@ Invite.reopenClass({
},
findInvitedBy(user, filter, search, offset) {
- if (!user) Promise.resolve();
+ if (!user) {
+ Promise.resolve();
+ }
const data = {};
- if (!isNone(filter)) data.filter = filter;
- if (!isNone(search)) data.search = search;
+ if (!isNone(filter)) {
+ data.filter = filter;
+ }
+ if (!isNone(search)) {
+ data.search = search;
+ }
data.offset = offset || 0;
let path;
@@ -58,7 +64,9 @@ Invite.reopenClass({
},
findInvitedCount(user) {
- if (!user) Promise.resolve();
+ if (!user) {
+ Promise.resolve();
+ }
return ajax(
userPath(`${user.username_lower}/invited_count.json`)
diff --git a/app/assets/javascripts/discourse/app/models/login-method.js b/app/assets/javascripts/discourse/app/models/login-method.js
index c951d53ace..3b1ca37b2a 100644
--- a/app/assets/javascripts/discourse/app/models/login-method.js
+++ b/app/assets/javascripts/discourse/app/models/login-method.js
@@ -77,7 +77,9 @@ LoginMethod.reopenClass({
let methods;
export function findAll() {
- if (methods) return methods;
+ if (methods) {
+ return methods;
+ }
methods = [];
diff --git a/app/assets/javascripts/discourse/app/models/nav-item.js b/app/assets/javascripts/discourse/app/models/nav-item.js
index f7b5da8ca0..63dfbb5893 100644
--- a/app/assets/javascripts/discourse/app/models/nav-item.js
+++ b/app/assets/javascripts/discourse/app/models/nav-item.js
@@ -164,8 +164,12 @@ NavItem.reopenClass({
}
}
- if (!Category.list() && filterType === "categories") return null;
- if (!Site.currentProp("top_menu_items").includes(filterType)) return null;
+ if (!Category.list() && filterType === "categories") {
+ return null;
+ }
+ if (!Site.currentProp("top_menu_items").includes(filterType)) {
+ return null;
+ }
var args = { name: filterType, hasIcon: filterType === "unread" };
if (opts.category) {
@@ -228,7 +232,9 @@ NavItem.reopenClass({
ExtraNavItem.create(deepMerge({}, context, descriptor))
)
.filter((item) => {
- if (!item.customFilter) return true;
+ if (!item.customFilter) {
+ return true;
+ }
return item.customFilter(category, args);
});
diff --git a/app/assets/javascripts/discourse/app/models/post-stream.js b/app/assets/javascripts/discourse/app/models/post-stream.js
index 041350de1a..340b1b2c6f 100644
--- a/app/assets/javascripts/discourse/app/models/post-stream.js
+++ b/app/assets/javascripts/discourse/app/models/post-stream.js
@@ -384,7 +384,9 @@ export default RestModel.extend({
});
} else {
const postIds = this.nextWindow;
- if (isEmpty(postIds)) return Promise.resolve();
+ if (isEmpty(postIds)) {
+ return Promise.resolve();
+ }
this.set("loadingBelow", true);
postsWithPlaceholders.appending(postIds);
@@ -425,7 +427,9 @@ export default RestModel.extend({
});
} else {
const postIds = this.previousWindow;
- if (isEmpty(postIds)) return Promise.resolve();
+ if (isEmpty(postIds)) {
+ return Promise.resolve();
+ }
this.set("loadingAbove", true);
return this.findPostsByIds(postIds.reverse())
@@ -844,7 +848,9 @@ export default RestModel.extend({
}
const val = timelineLookup[high] || timelineLookup[low];
- if (val) return val[1];
+ if (val) {
+ return val[1];
+ }
},
// Find a postId for a postNumber, respecting gaps
diff --git a/app/assets/javascripts/discourse/app/models/post.js b/app/assets/javascripts/discourse/app/models/post.js
index c29bc873ed..512cf9ea8c 100644
--- a/app/assets/javascripts/discourse/app/models/post.js
+++ b/app/assets/javascripts/discourse/app/models/post.js
@@ -85,7 +85,9 @@ const Post = RestModel.extend({
@discourseComputed("link_counts.@each.internal")
internalLinks() {
- if (isEmpty(this.link_counts)) return null;
+ if (isEmpty(this.link_counts)) {
+ return null;
+ }
return this.link_counts.filterBy("internal").filterBy("title");
},
diff --git a/app/assets/javascripts/discourse/app/models/site.js b/app/assets/javascripts/discourse/app/models/site.js
index 1c43350a6a..24e483db42 100644
--- a/app/assets/javascripts/discourse/app/models/site.js
+++ b/app/assets/javascripts/discourse/app/models/site.js
@@ -32,7 +32,9 @@ const Site = RestModel.extend({
@discourseComputed("post_action_types.[]")
flagTypes() {
const postActionTypes = this.post_action_types;
- if (!postActionTypes) return [];
+ if (!postActionTypes) {
+ return [];
+ }
return postActionTypes.filterBy("is_flag", true);
},
diff --git a/app/assets/javascripts/discourse/app/models/tag-group.js b/app/assets/javascripts/discourse/app/models/tag-group.js
index a6cf72629a..d34ddcf7d2 100644
--- a/app/assets/javascripts/discourse/app/models/tag-group.js
+++ b/app/assets/javascripts/discourse/app/models/tag-group.js
@@ -5,7 +5,9 @@ import PermissionType from "discourse/models/permission-type";
export default RestModel.extend({
@discourseComputed("permissions")
permissionName(permissions) {
- if (!permissions) return "public";
+ if (!permissions) {
+ return "public";
+ }
if (permissions["everyone"] === PermissionType.FULL) {
return "public";
diff --git a/app/assets/javascripts/discourse/app/models/topic-list.js b/app/assets/javascripts/discourse/app/models/topic-list.js
index a565df7911..57ee578f09 100644
--- a/app/assets/javascripts/discourse/app/models/topic-list.js
+++ b/app/assets/javascripts/discourse/app/models/topic-list.js
@@ -138,14 +138,18 @@ const TopicList = RestModel.extend({
i++;
});
- if (storeInSession) Session.currentProp("topicList", this);
+ if (storeInSession) {
+ Session.currentProp("topicList", this);
+ }
});
},
});
TopicList.reopenClass({
topicsFrom(store, result, opts) {
- if (!result) return;
+ if (!result) {
+ return;
+ }
opts = opts || {};
let listKey = opts.listKey || "topics";
diff --git a/app/assets/javascripts/discourse/app/models/topic-timer.js b/app/assets/javascripts/discourse/app/models/topic-timer.js
index d6e1638ea4..e6d108a608 100644
--- a/app/assets/javascripts/discourse/app/models/topic-timer.js
+++ b/app/assets/javascripts/discourse/app/models/topic-timer.js
@@ -17,9 +17,15 @@ TopicTimer.reopenClass({
status_type: statusType,
};
- if (basedOnLastPost) data.based_on_last_post = basedOnLastPost;
- if (categoryId) data.category_id = categoryId;
- if (duration) data.duration = duration;
+ if (basedOnLastPost) {
+ data.based_on_last_post = basedOnLastPost;
+ }
+ if (categoryId) {
+ data.category_id = categoryId;
+ }
+ if (duration) {
+ data.duration = duration;
+ }
return ajax({
url: `/t/${topicId}/timer`,
diff --git a/app/assets/javascripts/discourse/app/models/topic.js b/app/assets/javascripts/discourse/app/models/topic.js
index 95f09a6776..39b8b264f0 100644
--- a/app/assets/javascripts/discourse/app/models/topic.js
+++ b/app/assets/javascripts/discourse/app/models/topic.js
@@ -778,7 +778,9 @@ Topic.reopenClass({
type: "POST",
data: opts,
}).then((result) => {
- if (result.success) return result;
+ if (result.success) {
+ return result;
+ }
promise.reject(new Error("error changing ownership of posts"));
});
return promise;
@@ -789,7 +791,9 @@ Topic.reopenClass({
type: "PUT",
data: { timestamp },
}).then((result) => {
- if (result.success) return result;
+ if (result.success) {
+ return result;
+ }
promise.reject(new Error("error updating timestamp of topic"));
});
return promise;
diff --git a/app/assets/javascripts/discourse/app/models/user-draft.js b/app/assets/javascripts/discourse/app/models/user-draft.js
index ea9254d4f2..0bf9a1116c 100644
--- a/app/assets/javascripts/discourse/app/models/user-draft.js
+++ b/app/assets/javascripts/discourse/app/models/user-draft.js
@@ -22,7 +22,9 @@ export default RestModel.extend({
@discourseComputed("topic_id")
postUrl(topicId) {
- if (!topicId) return;
+ if (!topicId) {
+ return;
+ }
return postUrl(this.slug, this.topic_id, this.post_number);
},
diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js
index 1e4beddfe1..98baf09ec0 100644
--- a/app/assets/javascripts/discourse/app/models/user.js
+++ b/app/assets/javascripts/discourse/app/models/user.js
@@ -519,9 +519,14 @@ const User = RestModel.extend({
if (result && result.user_action) {
const ua = result.user_action;
- if ((this.get("stream.filter") || ua.action_type) !== ua.action_type)
+ if (
+ (this.get("stream.filter") || ua.action_type) !== ua.action_type
+ ) {
return;
- if (!this.get("stream.filter") && !this.inAllStream(ua)) return;
+ }
+ if (!this.get("stream.filter") && !this.inAllStream(ua)) {
+ return;
+ }
ua.title = emojiUnescape(escapeExpression(ua.title));
const action = UserAction.collapseStream([UserAction.create(ua)]);
@@ -564,7 +569,9 @@ const User = RestModel.extend({
// The user's stat count, excluding PMs.
@discourseComputed("statsExcludingPms.@each.count")
statsCountNonPM() {
- if (isEmpty(this.statsExcludingPms)) return 0;
+ if (isEmpty(this.statsExcludingPms)) {
+ return 0;
+ }
let count = 0;
this.statsExcludingPms.forEach((val) => {
if (this.inAllStream(val)) {
@@ -577,7 +584,9 @@ const User = RestModel.extend({
// The user's stats, excluding PMs.
@discourseComputed("stats.@each.isPM")
statsExcludingPms() {
- if (isEmpty(this.stats)) return [];
+ if (isEmpty(this.stats)) {
+ return [];
+ }
return this.stats.rejectBy("isPM");
},
@@ -591,7 +600,9 @@ const User = RestModel.extend({
}
const useCardRoute = options && options.forCard;
- if (options) delete options.forCard;
+ if (options) {
+ delete options.forCard;
+ }
const path = useCardRoute
? `${user.get("username")}/card.json`
@@ -602,7 +613,9 @@ const User = RestModel.extend({
if (!isEmpty(json.user.stats)) {
json.user.stats = User.groupStats(
json.user.stats.map((s) => {
- if (s.count) s.count = parseInt(s.count, 10);
+ if (s.count) {
+ s.count = parseInt(s.count, 10);
+ }
return UserActionStat.create(s);
})
);
diff --git a/app/assets/javascripts/discourse/app/routes/about.js b/app/assets/javascripts/discourse/app/routes/about.js
index abfd99dbba..4a9897ce70 100644
--- a/app/assets/javascripts/discourse/app/routes/about.js
+++ b/app/assets/javascripts/discourse/app/routes/about.js
@@ -9,10 +9,14 @@ export default DiscourseRoute.extend({
let activeModerators = [];
const yearAgo = moment().locale("en").utc().subtract(1, "year");
result.about.admins.forEach((r) => {
- if (moment(r.last_seen_at) > yearAgo) activeAdmins.push(r);
+ if (moment(r.last_seen_at) > yearAgo) {
+ activeAdmins.push(r);
+ }
});
result.about.moderators.forEach((r) => {
- if (moment(r.last_seen_at) > yearAgo) activeModerators.push(r);
+ if (moment(r.last_seen_at) > yearAgo) {
+ activeModerators.push(r);
+ }
});
result.about.admins = activeAdmins;
result.about.moderators = activeModerators;
diff --git a/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js b/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js
index 2fccbef350..4de94e625b 100644
--- a/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js
+++ b/app/assets/javascripts/discourse/app/routes/build-group-messages-route.js
@@ -11,7 +11,9 @@ export default (type) => {
const groupName = this.modelFor("group").get("name");
const username = this.currentUser.get("username_lower");
let filter = `topics/private-messages-group/${username}/${groupName}`;
- if (this._isArchive()) filter = `${filter}/archive`;
+ if (this._isArchive()) {
+ filter = `${filter}/archive`;
+ }
return this.store.findFiltered("topicList", { filter });
},
@@ -20,7 +22,9 @@ export default (type) => {
const groupName = this.modelFor("group").get("name");
let channel = `/private-messages/group/${groupName}`;
- if (this._isArchive()) channel = `${channel}/archive`;
+ if (this._isArchive()) {
+ channel = `${channel}/archive`;
+ }
this.controllerFor("user-topics-list").subscribe(channel);
this.controllerFor("user-topics-list").setProperties({
diff --git a/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js b/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js
index 871b12fcf4..022d12de16 100644
--- a/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js
+++ b/app/assets/javascripts/discourse/app/routes/user-private-messages-group.js
@@ -7,8 +7,9 @@ export default createPMRoute("groups", "private-messages-groups").extend({
titleToken() {
const groupName = this.groupName;
- if (groupName)
+ if (groupName) {
return [groupName.capitalize(), I18n.t("user.private_messages")];
+ }
},
model(params) {
diff --git a/app/assets/javascripts/discourse/app/routes/user.js b/app/assets/javascripts/discourse/app/routes/user.js
index f8eccf679b..c95ead4969 100644
--- a/app/assets/javascripts/discourse/app/routes/user.js
+++ b/app/assets/javascripts/discourse/app/routes/user.js
@@ -58,7 +58,9 @@ export default DiscourseRoute.extend({
},
serialize(model) {
- if (!model) return {};
+ if (!model) {
+ return {};
+ }
return { username: (model.username || "").toLowerCase() };
},
diff --git a/app/assets/javascripts/discourse/app/services/app-events.js b/app/assets/javascripts/discourse/app/services/app-events.js
index 899be52afd..9e738afecb 100644
--- a/app/assets/javascripts/discourse/app/services/app-events.js
+++ b/app/assets/javascripts/discourse/app/services/app-events.js
@@ -57,7 +57,9 @@ export default Service.extend(Evented, {
this._super(...arguments);
_events[name] = _events[name].filter((e) => e.fn !== fn);
- if (_events[name].length === 0) delete _events[name];
+ if (_events[name].length === 0) {
+ delete _events[name];
+ }
}
}
diff --git a/app/assets/javascripts/discourse/app/services/logs-notice.js b/app/assets/javascripts/discourse/app/services/logs-notice.js
index 66dafa73bf..a3334aadc8 100644
--- a/app/assets/javascripts/discourse/app/services/logs-notice.js
+++ b/app/assets/javascripts/discourse/app/services/logs-notice.js
@@ -16,10 +16,14 @@ const LogsNotice = EmberObject.extend({
@on("init")
_setup() {
- if (!this.isActivated) return;
+ if (!this.isActivated) {
+ return;
+ }
const text = this.keyValueStore.getItem(LOGS_NOTICE_KEY);
- if (text) this.set("text", text);
+ if (text) {
+ this.set("text", text);
+ }
this.messageBus.subscribe("/logs_error_rate_exceeded", (data) => {
const duration = data.duration;
diff --git a/app/assets/javascripts/discourse/app/widgets/component-connector.js b/app/assets/javascripts/discourse/app/widgets/component-connector.js
index 25f0898e47..db52456adc 100644
--- a/app/assets/javascripts/discourse/app/widgets/component-connector.js
+++ b/app/assets/javascripts/discourse/app/widgets/component-connector.js
@@ -31,7 +31,9 @@ export default class ComponentConnector {
}
});
- if (shouldInit) return this.init();
+ if (shouldInit) {
+ return this.init();
+ }
return null;
}
diff --git a/app/assets/javascripts/discourse/app/widgets/hamburger-menu.js b/app/assets/javascripts/discourse/app/widgets/hamburger-menu.js
index f6b7e09d8f..b9fdc94034 100644
--- a/app/assets/javascripts/discourse/app/widgets/hamburger-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/hamburger-menu.js
@@ -342,7 +342,9 @@ export default createWidget("hamburger-menu", {
refreshReviewableCount(state) {
const { currentUser } = this;
- if (state.loading || !currentUser) return;
+ if (state.loading || !currentUser) {
+ return;
+ }
state.loading = true;
diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js
index 7d0f6dba23..11a8a03849 100644
--- a/app/assets/javascripts/discourse/app/widgets/header.js
+++ b/app/assets/javascripts/discourse/app/widgets/header.js
@@ -492,7 +492,9 @@ export default createWidget("header", {
},
toggleBodyScrolling(bool) {
- if (!this.site.mobileView) return;
+ if (!this.site.mobileView) {
+ return;
+ }
if (bool) {
document.body.addEventListener("touchmove", this.preventDefault, {
passive: false,
diff --git a/app/assets/javascripts/discourse/app/widgets/post-menu.js b/app/assets/javascripts/discourse/app/widgets/post-menu.js
index 6a23430cda..17002ce893 100644
--- a/app/assets/javascripts/discourse/app/widgets/post-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/post-menu.js
@@ -42,8 +42,12 @@ export function addButton(name, builder) {
}
export function removeButton(name) {
- if (_extraButtons[name]) delete _extraButtons[name];
- if (_builders[name]) delete _builders[name];
+ if (_extraButtons[name]) {
+ delete _extraButtons[name];
+ }
+ if (_builders[name]) {
+ delete _builders[name];
+ }
}
function registerButton(name, builder) {
diff --git a/app/assets/javascripts/discourse/app/widgets/search-menu.js b/app/assets/javascripts/discourse/app/widgets/search-menu.js
index dd78bb4830..1b3585c72f 100644
--- a/app/assets/javascripts/discourse/app/widgets/search-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/search-menu.js
@@ -115,10 +115,14 @@ export default createWidget("search-menu", {
}
}
- if (query) params.push(query);
+ if (query) {
+ params.push(query);
+ }
}
- if (opts && opts.expanded) params.push("expanded=true");
+ if (opts && opts.expanded) {
+ params.push("expanded=true");
+ }
if (params.length > 0) {
url = `${url}?${params.join("&")}`;
diff --git a/app/assets/javascripts/discourse/app/widgets/topic-timeline.js b/app/assets/javascripts/discourse/app/widgets/topic-timeline.js
index a5992dd06f..2936198357 100644
--- a/app/assets/javascripts/discourse/app/widgets/topic-timeline.js
+++ b/app/assets/javascripts/discourse/app/widgets/topic-timeline.js
@@ -175,7 +175,9 @@ createWidget("timeline-scrollarea", {
.get("posts")
.findBy("id", postStream.get("stream")[current]);
- if (post) date = new Date(post.get("created_at"));
+ if (post) {
+ date = new Date(post.get("created_at"));
+ }
} else if (daysAgo !== null) {
date = new Date();
date.setDate(date.getDate() - daysAgo || 0);
diff --git a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
index 0be4641670..47b7f875d5 100644
--- a/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
+++ b/app/assets/javascripts/discourse/app/widgets/widget-dropdown.js
@@ -251,13 +251,17 @@ export const WidgetDropdownClass = {
`#${this.attrs.id} .widget-dropdown-header`
);
- if (!dropdownHeader) return;
+ if (!dropdownHeader) {
+ return;
+ }
const dropdownBody = document.querySelector(
`#${this.attrs.id} .widget-dropdown-body`
);
- if (!dropdownBody) return;
+ if (!dropdownBody) {
+ return;
+ }
this._popper = createPopper(dropdownHeader, dropdownBody, {
strategy: "fixed",
diff --git a/app/assets/javascripts/docs/yuidoc.json b/app/assets/javascripts/docs/yuidoc.json
index 292146820b..8d52bf9673 100644
--- a/app/assets/javascripts/docs/yuidoc.json
+++ b/app/assets/javascripts/docs/yuidoc.json
@@ -4,6 +4,6 @@
"url": "http://www.discourse.org/",
"options": {
"exclude": "development,production,defer",
- "outdir": "./build"
+ "outdir": "./build"
}
-}
\ No newline at end of file
+}
diff --git a/app/assets/javascripts/pretty-text/addon/emoji.js b/app/assets/javascripts/pretty-text/addon/emoji.js
index b25390468b..4f588a2f4f 100644
--- a/app/assets/javascripts/pretty-text/addon/emoji.js
+++ b/app/assets/javascripts/pretty-text/addon/emoji.js
@@ -72,7 +72,9 @@ Object.keys(aliases).forEach((name) => {
});
function isReplacableInlineEmoji(string, index, inlineEmoji) {
- if (inlineEmoji) return true;
+ if (inlineEmoji) {
+ return true;
+ }
// index depends on regex; when `inlineEmoji` is false, the regex starts
// with a `\B` character, so there's no need to subtract from the index
@@ -155,9 +157,12 @@ export function performEmojiEscape(string, opts) {
export function isCustomEmoji(code, opts) {
code = code.toLowerCase();
- if (extendedEmoji.hasOwnProperty(code)) return true;
- if (opts && opts.customEmoji && opts.customEmoji.hasOwnProperty(code))
+ if (extendedEmoji.hasOwnProperty(code)) {
return true;
+ }
+ if (opts && opts.customEmoji && opts.customEmoji.hasOwnProperty(code)) {
+ return true;
+ }
return false;
}
@@ -227,7 +232,9 @@ export function emojiSearch(term, options) {
// if term matches from beginning
for (let i = 0; i < toSearch.length; i++) {
const item = toSearch[i];
- if (item.indexOf(term) === 0) addResult(item);
+ if (item.indexOf(term) === 0) {
+ addResult(item);
+ }
}
if (searchAliases[term]) {
@@ -236,7 +243,9 @@ export function emojiSearch(term, options) {
for (let i = 0; i < toSearch.length; i++) {
const item = toSearch[i];
- if (item.indexOf(term) > 0) addResult(item);
+ if (item.indexOf(term) > 0) {
+ addResult(item);
+ }
}
if (maxResults === -1) {
diff --git a/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js b/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js
index 94e471f34a..5f0bf23376 100644
--- a/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js
+++ b/app/assets/javascripts/pretty-text/addon/engines/discourse-markdown-it.js
@@ -214,8 +214,13 @@ function renderImageOrPlayableMedia(tokens, idx, options, env, slf) {
token.attrs.push(["height", height]);
}
- if (options.discourse.previewing && match[6] !== "x" && match[4] !== "x")
+ if (
+ options.discourse.previewing &&
+ match[6] !== "x" &&
+ match[4] !== "x"
+ ) {
token.attrs.push(["class", "resizable"]);
+ }
} else if ((data = extractDataAttribute(split[i]))) {
token.attrs.push(data);
} else {
diff --git a/app/assets/javascripts/pretty-text/addon/oneboxer.js b/app/assets/javascripts/pretty-text/addon/oneboxer.js
index 0ef741eab0..00d6867d24 100644
--- a/app/assets/javascripts/pretty-text/addon/oneboxer.js
+++ b/app/assets/javascripts/pretty-text/addon/oneboxer.js
@@ -112,8 +112,12 @@ export function load({
const $elem = $(elem);
// If the onebox has loaded or is loading, return
- if ($elem.data("onebox-loaded")) return;
- if ($elem.hasClass(LOADING_ONEBOX_CSS_CLASS)) return;
+ if ($elem.data("onebox-loaded")) {
+ return;
+ }
+ if ($elem.hasClass(LOADING_ONEBOX_CSS_CLASS)) {
+ return;
+ }
const url = elem.href;
@@ -121,11 +125,15 @@ export function load({
if (!refresh) {
// If we have it in our cache, return it.
const cached = localCache[normalize(url)];
- if (cached) return cached.prop("outerHTML");
+ if (cached) {
+ return cached.prop("outerHTML");
+ }
// If the request failed, don't do anything
const failed = failedCache[normalize(url)];
- if (failed) return;
+ if (failed) {
+ return;
+ }
}
// Add the loading CSS class
diff --git a/app/assets/javascripts/pretty-text/addon/sanitizer.js b/app/assets/javascripts/pretty-text/addon/sanitizer.js
index aaf80055b5..035199fe44 100644
--- a/app/assets/javascripts/pretty-text/addon/sanitizer.js
+++ b/app/assets/javascripts/pretty-text/addon/sanitizer.js
@@ -72,7 +72,9 @@ export function hrefAllowed(href, extraHrefMatchers) {
}
export function sanitize(text, whiteLister) {
- if (!text) return "";
+ if (!text) {
+ return "";
+ }
// Allow things like <3 and <_<
text = text.replace(/<([^A-Za-z\/\!]|$)/g, "<$1");
diff --git a/app/assets/javascripts/pretty-text/addon/white-lister.js b/app/assets/javascripts/pretty-text/addon/white-lister.js
index b042c915c4..59bb3e205b 100644
--- a/app/assets/javascripts/pretty-text/addon/white-lister.js
+++ b/app/assets/javascripts/pretty-text/addon/white-lister.js
@@ -42,7 +42,9 @@ export default class WhiteLister {
const custom = [];
this._rawFeatures.forEach(([name, info]) => {
- if (!this._enabled[name]) return;
+ if (!this._enabled[name]) {
+ return;
+ }
if (info.custom) {
custom.push(info.custom);
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js
index 49d6b73607..3c5c7d1e92 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/mentions.js
@@ -44,7 +44,9 @@ function mentionRegex(unicodeUsernames) {
"u"
);
} catch (e) {
- if (!(e instanceof SyntaxError)) throw e;
+ if (!(e instanceof SyntaxError)) {
+ throw e;
+ }
// Fallback for older browsers and MiniRacer.
// Created with regexpu-core@4.5.4 by executing the following in nodejs:
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.js
index 0fa31d16b7..49dc478383 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/resize-controls.js
@@ -16,7 +16,9 @@ function appendMetaData(index, token) {
sizePart && sizePart.split(",").pop().trim().replace("%", "");
const overwriteScale = !SCALES.find((scale) => scale === selectedScale);
- if (overwriteScale) selectedScale = "100";
+ if (overwriteScale) {
+ selectedScale = "100";
+ }
token.attrs.push(["index-image", index]);
token.attrs.push(["scale", selectedScale]);
@@ -34,7 +36,9 @@ function rule(state) {
currentIndex++;
}
- if (!blockToken.children) continue;
+ if (!blockToken.children) {
+ continue;
+ }
for (let j = 0; j < blockToken.children.length; j++) {
let token = blockToken.children[j];
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.js
index 6ec12895fd..5e2b446e83 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/text-post-process.js
@@ -89,7 +89,9 @@ function textPostProcess(content, state, ruler) {
while ((match = matcher.exec(content))) {
// something is wrong
- if (match.index < pos) break;
+ if (match.index < pos) {
+ break;
+ }
// check boundary
if (match.index > 0) {
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js
index 145a6b6535..0b5d5bf6cb 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/upload-protocol.js
@@ -20,12 +20,16 @@ function rule(state) {
addImage(uploads, blockToken);
}
- if (!blockToken.children) continue;
+ if (!blockToken.children) {
+ continue;
+ }
for (let j = 0; j < blockToken.children.length; j++) {
let token = blockToken.children[j];
- if (token.tag === "img" || token.tag === "a") addImage(uploads, token);
+ if (token.tag === "img" || token.tag === "a") {
+ addImage(uploads, token);
+ }
}
}
@@ -86,7 +90,9 @@ function rule(state) {
export function setup(helper) {
const opts = helper.getOptions();
- if (opts.previewing) helper.whiteList(["img.resizable"]);
+ if (opts.previewing) {
+ helper.whiteList(["img.resizable"]);
+ }
helper.whiteList([
"img[data-orig-src]",
diff --git a/app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.js b/app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.js
index 69e795c8ba..7daa6c0e4b 100644
--- a/app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.js
+++ b/app/assets/javascripts/select-kit/addon/components/category-drop/category-drop-header.js
@@ -28,7 +28,9 @@ export default ComboBoxSelectBoxHeaderComponent.extend({
categoryStyle(category, categoryBackgroundColor, categoryTextColor) {
const categoryStyle = this.siteSettings.category_style;
- if (categoryStyle === "bullet") return;
+ if (categoryStyle === "bullet") {
+ return;
+ }
if (category) {
if (categoryBackgroundColor || categoryTextColor) {
diff --git a/app/assets/javascripts/select-kit/addon/components/category-selector.js b/app/assets/javascripts/select-kit/addon/components/category-selector.js
index b5b0d56786..2c2245aa3f 100644
--- a/app/assets/javascripts/select-kit/addon/components/category-selector.js
+++ b/app/assets/javascripts/select-kit/addon/components/category-selector.js
@@ -21,8 +21,12 @@ export default MultiSelectComponent.extend({
init() {
this._super(...arguments);
- if (!this.categories) this.set("categories", []);
- if (!this.blockedCategories) this.set("blockedCategories", []);
+ if (!this.categories) {
+ this.set("categories", []);
+ }
+ if (!this.blockedCategories) {
+ this.set("blockedCategories", []);
+ }
},
content: computed("categories.[]", "blockedCategories.[]", function () {
diff --git a/app/assets/javascripts/select-kit/addon/components/composer-actions.js b/app/assets/javascripts/select-kit/addon/components/composer-actions.js
index 172bd08ae9..c453c46918 100644
--- a/app/assets/javascripts/select-kit/addon/components/composer-actions.js
+++ b/app/assets/javascripts/select-kit/addon/components/composer-actions.js
@@ -297,7 +297,9 @@ export default DropdownSelectBoxComponent.extend({
bootbox.confirm(
I18n.t("composer.composer_actions.reply_as_new_topic.confirm"),
(result) => {
- if (result) this._replyAsNewTopicSelect(options);
+ if (result) {
+ this._replyAsNewTopicSelect(options);
+ }
}
);
} else {
diff --git a/app/assets/javascripts/select-kit/addon/components/icon-picker.js b/app/assets/javascripts/select-kit/addon/components/icon-picker.js
index 0556413e3e..eb053b0396 100644
--- a/app/assets/javascripts/select-kit/addon/components/icon-picker.js
+++ b/app/assets/javascripts/select-kit/addon/components/icon-picker.js
@@ -55,10 +55,11 @@ export default MultiSelectComponent.extend({
holder = "ajax-icon-holder";
if (typeof icon === "object") {
- if ($(`${spriteEl} .${holder}`).length === 0)
+ if ($(`${spriteEl} .${holder}`).length === 0) {
$(spriteEl).append(
`
`
);
+ }
if (!$(`${spriteEl} symbol#${strippedIconName}`).length) {
$(`${spriteEl} .${holder}`).append(
diff --git a/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js b/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js
index 082d1282ae..8ed8cff649 100644
--- a/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js
+++ b/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js
@@ -136,7 +136,9 @@ export default ComboBox.extend(TagsMixin, {
data.selected_tags = this.value.slice(0, 100);
}
- if (!this.selectKit.options.everyTag) data.filterForInput = true;
+ if (!this.selectKit.options.everyTag) {
+ data.filterForInput = true;
+ }
return this.searchTags("/tags/filter/search", data, this._transformJson);
},
diff --git a/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.js b/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.js
index bad9586745..267e83f273 100644
--- a/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.js
+++ b/app/assets/javascripts/select-kit/addon/components/multi-select/multi-select-filter.js
@@ -10,7 +10,9 @@ export default SelectKitFilterComponent.extend({
@discourseComputed("placeholder", "selectKit.hasSelection")
computedPlaceholder(placeholder, hasSelection) {
- if (hasSelection) return "";
+ if (hasSelection) {
+ return "";
+ }
return isEmpty(placeholder) ? "" : I18n.t(placeholder);
},
});
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.js
index 650fe22a92..8931ad6259 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js
@@ -466,7 +466,9 @@ export default Component.extend(
}
let none = this.selectKit.options.none;
- if (isNone(none) && !this.selectKit.options.allowAny) return null;
+ if (isNone(none) && !this.selectKit.options.allowAny) {
+ return null;
+ }
if (
isNone(none) &&
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-header.js b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-header.js
index 6e70f6574e..83a48f961d 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-header.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-header.js
@@ -8,10 +8,15 @@ export default Component.extend(UtilsMixin, {
eventType: "click",
click(event) {
- if (typeof document === "undefined") return;
- if (this.isDestroyed || !this.selectKit || this.selectKit.isDisabled)
+ if (typeof document === "undefined") {
return;
- if (this.eventType !== "click" || event.button !== 0) return;
+ }
+ if (this.isDestroyed || !this.selectKit || this.selectKit.isDisabled) {
+ return;
+ }
+ if (this.eventType !== "click" || event.button !== 0) {
+ return;
+ }
this.selectKit.toggle(event);
event.preventDefault();
},
diff --git a/app/assets/javascripts/select-kit/addon/components/selected-color.js b/app/assets/javascripts/select-kit/addon/components/selected-color.js
index 065ab7e05b..76232ce625 100644
--- a/app/assets/javascripts/select-kit/addon/components/selected-color.js
+++ b/app/assets/javascripts/select-kit/addon/components/selected-color.js
@@ -12,7 +12,9 @@ export default SelectedNameComponent.extend({
const color = escapeExpression(this.name),
el = document.querySelector(`[data-value="${color}"]`);
- if (el) el.style.borderBottomColor = `#${color}`;
+ if (el) {
+ el.style.borderBottomColor = `#${color}`;
+ }
});
},
});
diff --git a/app/assets/javascripts/select-kit/addon/components/tag-chooser.js b/app/assets/javascripts/select-kit/addon/components/tag-chooser.js
index b6a0c4cea3..0fcc339c11 100644
--- a/app/assets/javascripts/select-kit/addon/components/tag-chooser.js
+++ b/app/assets/javascripts/select-kit/addon/components/tag-chooser.js
@@ -91,9 +91,15 @@ export default MultiSelectComponent.extend(TagsMixin, {
.slice(0, 100);
}
- if (!this.everyTag) data.filterForInput = true;
- if (this.excludeSynonyms) data.excludeSynonyms = true;
- if (this.excludeHasSynonyms) data.excludeHasSynonyms = true;
+ if (!this.everyTag) {
+ data.filterForInput = true;
+ }
+ if (this.excludeSynonyms) {
+ data.excludeSynonyms = true;
+ }
+ if (this.excludeHasSynonyms) {
+ data.excludeHasSynonyms = true;
+ }
return this.searchTags("/tags/filter/search", data, this._transformJson);
},
diff --git a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6 b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6
index 09a180bc9a..0a89564672 100644
--- a/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6
+++ b/plugins/discourse-narrative-bot/assets/javascripts/initializers/new-user-narrative.js.es6
@@ -57,7 +57,8 @@ export default {
initialize(container) {
const siteSettings = container.lookup("site-settings:main");
- if (siteSettings.discourse_narrative_bot_enabled)
+ if (siteSettings.discourse_narrative_bot_enabled) {
withPluginApi("0.8.7", initialize);
+ }
},
};
diff --git a/plugins/lazy-yt/assets/javascripts/lazyYT.js b/plugins/lazy-yt/assets/javascripts/lazyYT.js
index c211db581d..d131a7924a 100644
--- a/plugins/lazy-yt/assets/javascripts/lazyYT.js
+++ b/plugins/lazy-yt/assets/javascripts/lazyYT.js
@@ -53,8 +53,9 @@
// Play button from YouTube (exactly as it is in YouTube)
innerHtml.push('
");
innerHtml.push("