A platform for community discussion. Free, open, simple.
REFACTOR: Remove `_.isEmpty` in favor of the existing version
Robin Ward115b3b6921ff
diff --git a/app/assets/javascripts/discourse/app/components/badge-card.js b/app/assets/javascripts/discourse/app/components/badge-card.jsindex e0b192895bd..af234f59787 100644--- a/app/assets/javascripts/discourse/app/components/badge-card.js+++ b/app/assets/javascripts/discourse/app/components/badge-card.js@@ -1,6 +1,7 @@import discourseComputed from "discourse-common/utils/decorators";import Component from "@ember/component";import { sanitize, emojiUnescape } from "discourse/lib/text";+import { isEmpty } from "@ember/utils";export default Component.extend({size: "medium",@@ -25,7 +26,7 @@ export default Component.extend({summary(size) {if (size === "large") {const longDescription = this.get("badge.long_description");- if (!_.isEmpty(longDescription)) {+ if (!isEmpty(longDescription)) {return emojiUnescape(sanitize(longDescription));}}diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.jsindex e2cf8746db4..43fd2c1b56c 100644--- a/app/assets/javascripts/discourse/app/components/d-editor.js+++ b/app/assets/javascripts/discourse/app/components/d-editor.js@@ -31,6 +31,7 @@ import showModal from "discourse/lib/show-modal";import { Promise } from "rsvp";import { isTesting } from "discourse-common/config/environment";import { SKIP } from "discourse/lib/autocomplete";+import { isEmpty } from "@ember/utils";// Our head can be a static string or a function that returns a string// based on input (like for numbered lists).@@ -953,7 +954,7 @@ export default Component.extend({let selected = this._getSelected();const captures = selected.pre.match(/\B:(\w*)$/);- if (_.isEmpty(captures)) {+ if (isEmpty(captures)) {if (selected.pre.match(/\S$/)) {this._addText(selected, ` :${code}:`);} else {diff --git a/app/assets/javascripts/discourse/app/controllers/bookmark.js b/app/assets/javascripts/discourse/app/controllers/bookmark.jsindex 494e33dd805..e349a2cef23 100644--- a/app/assets/javascripts/discourse/app/controllers/bookmark.js+++ b/app/assets/javascripts/discourse/app/controllers/bookmark.js@@ -14,6 +14,7 @@ import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";import { formattedReminderTime, REMINDER_TYPES } from "discourse/lib/bookmark";import { AUTO_DELETE_PREFERENCES } from "discourse/models/bookmark";import bootbox from "bootbox";+import { isEmpty } from "@ember/utils";// global shortcuts that interfere with these modal shortcuts, they are rebound when the// modal is closed@@ -294,7 +295,7 @@ export default Controller.extend(ModalFunctionality, {@discourseComputed("userTimezone")userHasTimezoneSet(userTimezone) {- return !_.isEmpty(userTimezone);+ return !isEmpty(userTimezone);},_saveBookmark() {diff --git a/app/assets/javascripts/discourse/app/lib/highlight-search.js b/app/assets/javascripts/discourse/app/lib/highlight-search.jsindex 6f233426565..2eb3f7862dc 100644--- a/app/assets/javascripts/discourse/app/lib/highlight-search.js+++ b/app/assets/javascripts/discourse/app/lib/highlight-search.js@@ -1,10 +1,11 @@import { SEARCH_PHRASE_REGEXP } from "discourse/lib/constants";import highlightHTML from "discourse/lib/highlight-html";+import { isEmpty } from "@ember/utils";export const CLASS_NAME = "search-highlight";export default function(elem, term, opts = {}) {- if (!_.isEmpty(term)) {+ if (!isEmpty(term)) {// special case ignore "l" which is used for magic sortinglet words = _.reject(term.match(new RegExp(`${SEARCH_PHRASE_REGEXP}|[^\\s]+`, "g")),diff --git a/app/assets/javascripts/discourse/app/models/composer.js b/app/assets/javascripts/discourse/app/models/composer.jsindex ebade501c98..41fca8f26c8 100644--- a/app/assets/javascripts/discourse/app/models/composer.js+++ b/app/assets/javascripts/discourse/app/models/composer.js@@ -23,6 +23,7 @@ import Site from "discourse/models/site";import User from "discourse/models/user";import deprecated from "discourse-common/lib/deprecated";import bootbox from "bootbox";+import { isEmpty } from "@ember/utils";// The actions the composer can takeexport const CREATE_TOPIC = "createTopic",@@ -996,7 +997,7 @@ const Composer = RestModel.extend({// Furthermore calculating cooked is very complicated, especially since// we would need to handle oneboxes and other bits that are not even in the// engine, staging will just cause a blank post to render- if (!_.isEmpty(createdPost.cooked)) {+ if (!isEmpty(createdPost.cooked)) {state = postStream.stagePost(createdPost, user);if (state === "alreadyStaging") {return;diff --git a/app/assets/javascripts/locales/i18n.js b/app/assets/javascripts/locales/i18n.jsindex 480287700ab..0542bf1f03c 100644--- a/app/assets/javascripts/locales/i18n.js+++ b/app/assets/javascripts/locales/i18n.js@@ -323,7 +323,7 @@ I18n.enableVerboseLocalization = function() {if (!current) {current = keys[scope] = ++counter;var message = "Translation #" + current + ": " + scope;- if (!_.isEmpty(value)) {+ if (value && Object.keys(value).length > 0) {message += ", parameters: " + JSON.stringify(value);}// eslint-disable-next-line no-console