DEV: removes _.map from codebase (#6616)

DEV: removes _.map from codebase (#6616)

From c4ed353fae4280541f8f4c52d9ab43486bd11ba2 Mon Sep 17 00:00:00 2001
From: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Date: Mon, 19 Nov 2018 10:46:46 +0100
Subject: [PATCH] DEV: removes _.map from codebase (#6616)


diff --git a/app/assets/javascripts/admin/models/email-log.js.es6 b/app/assets/javascripts/admin/models/email-log.js.es6
index 4b6db3c..f1ac52a 100644
--- a/app/assets/javascripts/admin/models/email-log.js.es6
+++ b/app/assets/javascripts/admin/models/email-log.js.es6
@@ -27,7 +27,7 @@ EmailLog.reopenClass({
 
     return ajax(`/admin/email/${status}.json?offset=${offset}`, {
       data: filter
-    }).then(logs => _.map(logs, log => EmailLog.create(log)));
+    }).then(logs => logs.map(log => EmailLog.create(log)));
   }
 });
 
diff --git a/app/assets/javascripts/admin/models/incoming-email.js.es6 b/app/assets/javascripts/admin/models/incoming-email.js.es6
index 931258f..fd9d687 100644
--- a/app/assets/javascripts/admin/models/incoming-email.js.es6
+++ b/app/assets/javascripts/admin/models/incoming-email.js.es6
@@ -32,7 +32,7 @@ IncomingEmail.reopenClass({
     return ajax(`/admin/email/${status}.json?offset=${offset}`, {
       data: filter
     }).then(incomings =>
-      _.map(incomings, incoming => IncomingEmail.create(incoming))
+      incomings.map(incoming => IncomingEmail.create(incoming))
     );
   },
 
diff --git a/app/assets/javascripts/discourse/components/emoji-picker.js.es6 b/app/assets/javascripts/discourse/components/emoji-picker.js.es6
index 67f3687..628588e 100644
--- a/app/assets/javascripts/discourse/components/emoji-picker.js.es6
+++ b/app/assets/javascripts/discourse/components/emoji-picker.js.es6
@@ -13,7 +13,7 @@ const keyValueStore = new KeyValueStore("discourse_emojis_");
 const EMOJI_USAGE = "emojiUsage";
 const EMOJI_SELECTED_DIVERSITY = "emojiSelectedDiversity";
 const PER_ROW = 11;
-const customEmojis = _.map(_.keys(extendedEmojiList()), code => {
+const customEmojis = _.keys(extendedEmojiList()).map(code => {
   return { code, src: emojiUrlFor(code) };
 });
 
@@ -148,7 +148,7 @@ export default Ember.Component.extend({
       $recentSection.css("height", "auto").show();
     }
 
-    const recentEmojis = _.map(this.get("recentEmojis"), code => {
+    const recentEmojis = this.get("recentEmojis").map(code => {
       return { code, src: emojiUrlFor(code) };
     });
     const template = findRawTemplate("emoji-picker-recent")({ recentEmojis });
@@ -235,7 +235,7 @@ export default Ember.Component.extend({
       this.$results
         .empty()
         .html(
-          _.map(filteredCodes, code => {
+          filteredCodes.map(code => {
             const hasDiversity = isSkinTonableEmoji(code);
             const diversity = hasDiversity ? "diversity" : "";
             const scaledCode = this._codeWithDiversity(code, hasDiversity);
diff --git a/app/assets/javascripts/discourse/components/global-notice.js.es6 b/app/assets/javascripts/discourse/components/global-notice.js.es6
index 5041da1..0a506cb 100644
--- a/app/assets/javascripts/discourse/components/global-notice.js.es6
+++ b/app/assets/javascripts/discourse/components/global-notice.js.es6
@@ -72,14 +72,16 @@ export default Ember.Component.extend(
 
       if (notices.length > 0) {
         buffer.push(
-          _.map(notices, n => {
-            var html = `<div class='row'><div class='alert alert-info ${
-              n[1]
-            }'>`;
-            if (n[2]) html += n[2];
-            html += `${n[0]}</div></div>`;
-            return html;
-          }).join("")
+          notices
+            .map(n => {
+              var html = `<div class='row'><div class='alert alert-info ${
+                n[1]
+              }'>`;
+              if (n[2]) html += n[2];
+              html += `${n[0]}</div></div>`;
+              return html;
+            })
+            .join("")
         );
       }
     },
diff --git a/app/assets/javascripts/discourse/models/site.js.es6 b/app/assets/javascripts/discourse/models/site.js.es6
index f44e92d..a2de542 100644
--- a/app/assets/javascripts/discourse/models/site.js.es6
+++ b/app/assets/javascripts/discourse/models/site.js.es6
@@ -119,7 +119,7 @@ Site.reopenClass(Singleton, {
       let subcatMap = {};
 
       result.categoriesById = {};
-      result.categories = _.map(result.categories, c => {
+      result.categories = result.categories.map(c => {
         if (c.parent_category_id) {
           subcatMap[c.parent_category_id] =
             subcatMap[c.parent_category_id] || [];
@@ -158,7 +158,7 @@ Site.reopenClass(Singleton, {
 
     if (result.post_action_types) {
       result.postActionByIdLookup = Em.Object.create();
-      result.post_action_types = _.map(result.post_action_types, p => {
+      result.post_action_types = result.post_action_types.map(p => {
         const actionType = PostActionType.create(p);
         result.postActionByIdLookup.set("action" + p.id, actionType);
         return actionType;
@@ -167,7 +167,7 @@ Site.reopenClass(Singleton, {
 
     if (result.topic_flag_types) {
       result.topicFlagByIdLookup = Em.Object.create();
-      result.topic_flag_types = _.map(result.topic_flag_types, p => {
+      result.topic_flag_types = result.topic_flag_types.map(p => {
         const actionType = PostActionType.create(p);
         result.topicFlagByIdLookup.set("action" + p.id, actionType);
         return actionType;
@@ -175,7 +175,7 @@ Site.reopenClass(Singleton, {
     }
 
     if (result.archetypes) {
-      result.archetypes = _.map(result.archetypes, a => {
+      result.archetypes = result.archetypes.map(a => {
         a.site = result;
         return Archetype.create(a);
       });
diff --git a/app/assets/javascripts/discourse/models/user.js.es6 b/app/assets/javascripts/discourse/models/user.js.es6
index acb2ad2..3bb8799 100644
--- a/app/assets/javascripts/discourse/models/user.js.es6
+++ b/app/assets/javascripts/discourse/models/user.js.es6
@@ -469,7 +469,7 @@ const User = RestModel.extend({
     }).then(json => {
       if (!Em.isEmpty(json.user.stats)) {
         json.user.stats = Discourse.User.groupStats(
-          _.map(json.user.stats, s => {
+          json.user.stats.map(s => {
             if (s.count) s.count = parseInt(s.count, 10);
             return UserActionStat.create(s);
           })
diff --git a/app/assets/javascripts/pretty-text/image-short-url.js.es6 b/app/assets/javascripts/pretty-text/image-short-url.js.es6
index 7aa4c93..60403ba 100644
--- a/app/assets/javascripts/pretty-text/image-short-url.js.es6
+++ b/app/assets/javascripts/pretty-text/image-short-url.js.es6
@@ -33,7 +33,7 @@ function _loadCachedShortUrls($images) {
 }
 
 function _loadShortUrls($images, ajax) {
-  const urls = _.map($images, img => $(img).data("orig-src"));
+  const urls = $images.map(img => $(img).data("orig-src"));
   lookupUncachedUploadUrls(urls, ajax).then(() =>
     _loadCachedShortUrls($images)
   );
diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6
index c6e3712..6c2010b 100644
--- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6
+++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6
@@ -71,7 +71,7 @@ export default Ember.Component.extend({
 
   @computed()
   allTimezones() {
-    return _.map(moment.tz.names(), z => z);
+    return moment.tz.names();
   },
 
   @observes(
diff --git a/test/javascripts/models/report-test.js.es6 b/test/javascripts/models/report-test.js.es6
index 888b9fe..f3117d3 100644
--- a/test/javascripts/models/report-test.js.es6
+++ b/test/javascripts/models/report-test.js.es6
@@ -5,7 +5,7 @@ QUnit.module("Report");
 function reportWithData(data) {
   return Report.create({
     type: "topics",
-    data: _.map(data, (val, index) => {
+    dat

GitHub

1 Like