Upgrade lodash to v4 and lint more files (#8495)

* common: import lodash modules separately

* remove test/content from .eslintignore, fix with eslint --fix content/index

* lint test/content

* lint content/index except for lodash methods

* upgrade server/models

* upgrade server/middlewares and server/libs

* port server/controllers/top-level

* port server/controllers/api-v3

* port views and tests

* client old port lodash and _(, missing _.

* upgrade client-old

* port common/script (root level files only)

* port common/script/fns

* port common/libs

* port common/script/ops

* port common/script/content and common/script/libs/shops.js

* misc fixes

* misc fixes

* misc fixes

* more tests fixes

* fix payments test stubbing, down to 2 failing tests

* remove more instances of lodash wrapping

* fix bug where toObject does not clone object

* fix tests

* upgrade migration or add lodash 4 note

* update shrinkwrap

* fix linting

* upgrade eslint-config-habitrpg

* update shrinkwrap

* recompile shrinkwrap
This commit is contained in:
Matteo Pagliazzi
2017-03-01 17:10:48 +01:00
committed by GitHub
parent ef02e59590
commit 98c019a0b6
150 changed files with 4996 additions and 1533 deletions

View File

@@ -63,7 +63,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
//If the user has one filter selected, assume that the user wants to default to that group
var defaultGroup;
//Our filters contain all groups, but we only want groups that have atleast one challenge
var groupsWithChallenges = _.uniq(_.pluck($scope.groupsFilter, '_id'));
var groupsWithChallenges = _.uniq(_.map($scope.groupsFilter, '_id'));
var len = groupsWithChallenges.length;
var filterCount = 0;
@@ -108,11 +108,11 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
reward: []
};
_(clonedTasks).each(function(val, type) {
_(clonedTasks).forEach(function(val, type) {
if (challenge[type + 's']) {
challenge[type + 's'].forEach(_cloneTaskAndPush);
}
}).value();
});
$scope.obj = $scope.newChallenge = {
name: challenge.name,
@@ -446,7 +446,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
};
$scope.filterInitialChallenges = function() {
$scope.groupsFilter = _.uniq(_.compact(_.pluck($scope.challenges, 'group')), function(g) {return g._id});
$scope.groupsFilter = _.uniqBy(_.compact(_.map($scope.challenges, 'group')), function(g) {return g._id});
$scope.search = {
group: _.transform($scope.groupsFilter, function(m,g) { m[g._id] = true;}),

View File

@@ -19,7 +19,7 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared',
$scope._editing = false;
} else {
tagsSnap = angular.copy(user.tags);
tagsSnap = _.object(_.pluck(tagsSnap,'id'), tagsSnap);
tagsSnap = _.zipObject(_.map(tagsSnap, 'id'), tagsSnap);
$scope._editing = true;
}
};

View File

@@ -70,7 +70,7 @@ function($scope, $rootScope, User, $http, Notification, ApiUrl, Social) {
/**
* Debug functions. Note that the server route for gems is only available if process.env.DEBUG=true
*/
if (_.contains(['development','test'],window.env.NODE_ENV)) {
if (_.includes(['development','test'],window.env.NODE_ENV)) {
$scope.setHealthLow = function(){
User.set({

View File

@@ -19,7 +19,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
// If the group is a guild, just check for an intersection with the
// current user's guilds, rather than checking the members of the group.
if(group.type === 'guild') {
return _.detect(User.user.guilds, function(guildId) { return guildId === group._id });
return _.find(User.user.guilds, function(guildId) { return guildId === group._id });
}
// Similarly, if we're dealing with the user's current party, return true.

View File

@@ -89,7 +89,7 @@ habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$r
Challenges.getGroupChallenges(group._id)
.then(function(response) {
var challenges = _.pluck(_.filter(response.data.data, function(c) {
var challenges = _.map(_.filter(response.data.data, function(c) {
return c.group._id == group._id;
}), '_id');

View File

@@ -134,7 +134,7 @@ habitrpg.controller("InventoryCtrl",
if ($scope.selectedEgg && $scope.selectedEgg.key == egg) {
return $scope.selectedEgg = null; // clicked same egg, unselect
}
var eggData = _.findWhere(Content.eggs, {key:egg});
var eggData = _.find(Content.eggs, {key:egg});
if (!$scope.selectedPotion) {
$scope.selectedEgg = eggData;
} else {
@@ -148,7 +148,7 @@ habitrpg.controller("InventoryCtrl",
return $scope.selectedPotion = null; // clicked same egg, unselect
}
// we really didn't think through the way these things are stored and getting passed around...
var potionData = _.findWhere(Content.hatchingPotions, {key:potion});
var potionData = _.find(Content.hatchingPotions, {key:potion});
if (!$scope.selectedEgg) {
$scope.selectedPotion = potionData;
} else {
@@ -175,7 +175,7 @@ habitrpg.controller("InventoryCtrl",
}
$scope.ownedItems = function(inventory){
return _.pick(inventory, function(v,k){return v>0;});
return _.pickBy(inventory, function(v,k){return v>0;});
}
$scope.hatch = function(egg, potion){
@@ -274,7 +274,7 @@ habitrpg.controller("InventoryCtrl",
$scope.getSeasonalShopArray = function(set){
var flatGearArray = _.toArray(Content.gear.flat);
var filteredArray = _.where(flatGearArray, {index: set});
var filteredArray = _.filter(flatGearArray, {index: set});
return filteredArray;
};

View File

@@ -62,7 +62,7 @@ habitrpg.controller('InviteToGroupCtrl', ['$scope', '$rootScope', 'User', 'Group
}
function _getOnlyUuids() {
var uuids = _.pluck($scope.invitees, 'uuid');
var uuids = _.map($scope.invitees, 'uuid');
var filteredUuids = _.filter(uuids, function(id) {
return id != '';
});

View File

@@ -23,7 +23,7 @@ angular.module('habitrpg')
} else if (!(_.isEmpty(user.newMessages))) {
return messageValue;
} else if (!_.isEmpty(user.groupNotifications)) {
var groupNotificationTypes = _.pluck(user.groupNotifications, 'type');
var groupNotificationTypes = _.map(user.groupNotifications, 'type');
if (groupNotificationTypes.indexOf('GROUP_TASK_APPROVAL') !== -1) {
return groupApprovalRequested;
} else if (groupNotificationTypes.indexOf('GROUP_TASK_APPROVED') !== -1) {

View File

@@ -156,7 +156,7 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
//TODO: Move this to challenge service
Challenges.getGroupChallenges(group._id)
.then(function(response) {
var challenges = _.pluck(_.filter(response.data.data, function(c) {
var challenges = _.map(_.filter(response.data.data, function(c) {
return c.group._id == group._id;
}), '_id');

View File

@@ -271,7 +271,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$rootScope.getGearArray = function(set){
var flatGearArray = _.toArray(Content.gear.flat);
var filteredArray = _.where(flatGearArray, {gearSet: set});
var filteredArray = _.filter(flatGearArray, {gearSet: set});
return filteredArray;
}