REFACTOR: Remove _.isEmpty in favor of the existing version

This commit is contained in:
Robin Ward 2020-08-31 16:07:57 -04:00
parent 65f6a92129
commit 115b3b6921
6 changed files with 11 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
import { sanitize, emojiUnescape } from "discourse/lib/text"; import { sanitize, emojiUnescape } from "discourse/lib/text";
import { isEmpty } from "@ember/utils";
export default Component.extend({ export default Component.extend({
size: "medium", size: "medium",
@ -25,7 +26,7 @@ export default Component.extend({
summary(size) { summary(size) {
if (size === "large") { if (size === "large") {
const longDescription = this.get("badge.long_description"); const longDescription = this.get("badge.long_description");
if (!_.isEmpty(longDescription)) { if (!isEmpty(longDescription)) {
return emojiUnescape(sanitize(longDescription)); return emojiUnescape(sanitize(longDescription));
} }
} }

View File

@ -31,6 +31,7 @@ import showModal from "discourse/lib/show-modal";
import { Promise } from "rsvp"; import { Promise } from "rsvp";
import { isTesting } from "discourse-common/config/environment"; import { isTesting } from "discourse-common/config/environment";
import { SKIP } from "discourse/lib/autocomplete"; 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 // Our head can be a static string or a function that returns a string
// based on input (like for numbered lists). // based on input (like for numbered lists).
@ -953,7 +954,7 @@ export default Component.extend({
let selected = this._getSelected(); let selected = this._getSelected();
const captures = selected.pre.match(/\B:(\w*)$/); const captures = selected.pre.match(/\B:(\w*)$/);
if (_.isEmpty(captures)) { if (isEmpty(captures)) {
if (selected.pre.match(/\S$/)) { if (selected.pre.match(/\S$/)) {
this._addText(selected, ` :${code}:`); this._addText(selected, ` :${code}:`);
} else { } else {

View File

@ -14,6 +14,7 @@ import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
import { formattedReminderTime, REMINDER_TYPES } from "discourse/lib/bookmark"; import { formattedReminderTime, REMINDER_TYPES } from "discourse/lib/bookmark";
import { AUTO_DELETE_PREFERENCES } from "discourse/models/bookmark"; import { AUTO_DELETE_PREFERENCES } from "discourse/models/bookmark";
import bootbox from "bootbox"; import bootbox from "bootbox";
import { isEmpty } from "@ember/utils";
// global shortcuts that interfere with these modal shortcuts, they are rebound when the // global shortcuts that interfere with these modal shortcuts, they are rebound when the
// modal is closed // modal is closed
@ -294,7 +295,7 @@ export default Controller.extend(ModalFunctionality, {
@discourseComputed("userTimezone") @discourseComputed("userTimezone")
userHasTimezoneSet(userTimezone) { userHasTimezoneSet(userTimezone) {
return !_.isEmpty(userTimezone); return !isEmpty(userTimezone);
}, },
_saveBookmark() { _saveBookmark() {

View File

@ -1,10 +1,11 @@
import { SEARCH_PHRASE_REGEXP } from "discourse/lib/constants"; import { SEARCH_PHRASE_REGEXP } from "discourse/lib/constants";
import highlightHTML from "discourse/lib/highlight-html"; import highlightHTML from "discourse/lib/highlight-html";
import { isEmpty } from "@ember/utils";
export const CLASS_NAME = "search-highlight"; export const CLASS_NAME = "search-highlight";
export default function(elem, term, opts = {}) { export default function(elem, term, opts = {}) {
if (!_.isEmpty(term)) { if (!isEmpty(term)) {
// special case ignore "l" which is used for magic sorting // special case ignore "l" which is used for magic sorting
let words = _.reject( let words = _.reject(
term.match(new RegExp(`${SEARCH_PHRASE_REGEXP}|[^\\s]+`, "g")), term.match(new RegExp(`${SEARCH_PHRASE_REGEXP}|[^\\s]+`, "g")),

View File

@ -23,6 +23,7 @@ import Site from "discourse/models/site";
import User from "discourse/models/user"; import User from "discourse/models/user";
import deprecated from "discourse-common/lib/deprecated"; import deprecated from "discourse-common/lib/deprecated";
import bootbox from "bootbox"; import bootbox from "bootbox";
import { isEmpty } from "@ember/utils";
// The actions the composer can take // The actions the composer can take
export const CREATE_TOPIC = "createTopic", export const CREATE_TOPIC = "createTopic",
@ -996,7 +997,7 @@ const Composer = RestModel.extend({
// Furthermore calculating cooked is very complicated, especially since // Furthermore calculating cooked is very complicated, especially since
// we would need to handle oneboxes and other bits that are not even in the // 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 // engine, staging will just cause a blank post to render
if (!_.isEmpty(createdPost.cooked)) { if (!isEmpty(createdPost.cooked)) {
state = postStream.stagePost(createdPost, user); state = postStream.stagePost(createdPost, user);
if (state === "alreadyStaging") { if (state === "alreadyStaging") {
return; return;

View File

@ -323,7 +323,7 @@ I18n.enableVerboseLocalization = function() {
if (!current) { if (!current) {
current = keys[scope] = ++counter; current = keys[scope] = ++counter;
var message = "Translation #" + current + ": " + scope; var message = "Translation #" + current + ": " + scope;
if (!_.isEmpty(value)) { if (value && Object.keys(value).length > 0) {
message += ", parameters: " + JSON.stringify(value); message += ", parameters: " + JSON.stringify(value);
} }
// eslint-disable-next-line no-console // eslint-disable-next-line no-console