From e0e9811ab60a6fd286f6f0a16267aa218beecfc3 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Wed, 9 Oct 2019 20:08:36 +0200 Subject: [PATCH] lint common --- package-lock.json | 6 +- package.json | 4 +- webpack/build.js | 47 - webpack/config/dev.env.js | 6 - webpack/config/index.js | 81 -- webpack/config/prod.env.js | 45 - webpack/config/test.env.js | 6 - webpack/dev-client.js | 10 - webpack/dev-server.js | 72 -- webpack/utils.js | 66 -- webpack/webpack.base.conf.js | 154 --- webpack/webpack.dev.conf.js | 32 - webpack/webpack.prod.conf.js | 101 -- webpack/webpack.test.conf.js | 24 - website/client/.eslintrc.js | 23 +- website/client/babel.config.js | 6 +- website/client/postcss.config.js | 6 +- website/client/src/app.vue | 66 +- website/client/src/components/404.vue | 11 +- .../achievements/achievementFooter.vue | 5 +- .../components/achievements/chooseClass.vue | 25 +- .../components/achievements/contributor.vue | 2 +- .../src/components/achievements/death.vue | 4 +- .../components/achievements/dropsEnabled.vue | 2 +- .../achievements/genericAchievement.vue | 34 +- .../components/achievements/justAddWater.vue | 42 +- .../src/components/achievements/levelUp.vue | 10 +- .../achievements/lostMasterclasser.vue | 42 +- .../src/components/achievements/lowHealth.vue | 4 +- .../achievements/mindOverMatter.vue | 42 +- .../src/components/achievements/newStuff.vue | 60 +- .../achievements/questCompleted.vue | 6 +- .../achievements/questInvitation.vue | 4 +- .../src/components/achievements/rebirth.vue | 32 +- .../achievements/rebirthEnabled.vue | 2 +- .../src/components/achievements/streak.vue | 6 +- .../components/achievements/ultimateGear.vue | 2 +- .../components/achievements/wonChallenge.vue | 4 +- website/client/src/components/appFooter.vue | 20 +- .../client/src/components/auth/authForm.vue | 22 +- website/client/src/components/auth/logout.vue | 20 +- .../components/auth/registerLoginReset.vue | 30 +- website/client/src/components/avatar.vue | 23 +- .../components/avatarModal/body-settings.vue | 112 +-- .../avatarModal/customize-options.vue | 42 +- .../components/avatarModal/extra-settings.vue | 417 ++++---- .../components/avatarModal/hair-settings.vue | 514 +++++----- .../components/avatarModal/skin-settings.vue | 154 ++- .../src/components/avatarModal/sub-menu.vue | 6 +- .../components/categories/categoryTags.vue | 34 +- .../components/challenges/challengeDetail.vue | 34 +- .../components/challenges/challengeItem.vue | 154 +-- .../challengeMemberProgressModal.vue | 32 +- .../components/challenges/challengeModal.vue | 92 +- .../challenges/closeChallengeModal.vue | 2 +- .../components/challenges/findChallenges.vue | 9 +- .../components/challenges/groupChallenges.vue | 90 +- .../challenges/leaveChallengeModal.vue | 10 +- .../components/challenges/myChallenges.vue | 14 +- .../src/components/chat/autoComplete.vue | 32 +- .../client/src/components/chat/chatCard.vue | 42 +- .../src/components/chat/chatMessages.vue | 67 +- .../src/components/chat/copyAsTodoModal.vue | 5 +- .../src/components/chat/reportFlagModal.vue | 10 +- .../client/src/components/creatorIntro.vue | 54 +- website/client/src/components/emptyView.vue | 2 +- .../src/components/group-plans/billing.vue | 6 +- .../group-plans/createGroupModalPages.vue | 8 +- .../group-plans/groupPlanOverviewModal.vue | 2 +- .../src/components/group-plans/index.vue | 6 +- .../group-plans/taskInformation.vue | 42 +- website/client/src/components/groupLink.vue | 30 +- website/client/src/components/groups/chat.vue | 356 +++---- .../components/groups/communityGuidelines.vue | 4 +- .../components/groups/createPartyModal.vue | 90 +- .../src/components/groups/discovery.vue | 24 +- .../client/src/components/groups/group.vue | 50 +- .../src/components/groups/groupFormModal.vue | 28 +- .../src/components/groups/groupPlan.vue | 8 +- .../src/components/groups/inviteModal.vue | 194 ++-- .../src/components/groups/membersModal.vue | 20 +- .../client/src/components/groups/myGuilds.vue | 18 +- .../groups/participantListModal.vue | 6 +- .../src/components/groups/publicGuildItem.vue | 16 +- .../components/groups/questDetailsModal.vue | 26 +- .../components/groups/questSidebarSection.vue | 26 +- .../src/components/groups/startQuestModal.vue | 8 +- .../client/src/components/groups/tavern.vue | 6 +- website/client/src/components/hall/heroes.vue | 20 +- .../client/src/components/hall/patrons.vue | 2 +- .../client/src/components/header/index.vue | 2 +- website/client/src/components/header/menu.vue | 4 +- .../src/components/header/messageCount.vue | 2 +- .../components/header/notifications/base.vue | 12 +- .../header/notifications/cardReceived.vue | 6 +- .../notifications/challengeInvitation.vue | 2 +- .../notifications/groupTaskApproval.vue | 26 +- .../notifications/groupTaskApproved.vue | 8 +- .../notifications/groupTaskAssigned.vue | 22 +- .../header/notifications/groupTaskClaimed.vue | 6 +- .../notifications/groupTaskNeedsWork.vue | 6 +- .../header/notifications/guildInvitation.vue | 13 +- .../header/notifications/justAddWater.vue | 30 +- .../notifications/lostMasterclasser.vue | 30 +- .../header/notifications/mindOverMatter.vue | 30 +- .../header/notifications/newChatMessage.vue | 10 +- .../header/notifications/newInboxMessage.vue | 4 +- .../header/notifications/newMysteryItems.vue | 8 +- .../header/notifications/newStuff.vue | 4 +- .../header/notifications/partyInvitation.vue | 10 +- .../header/notifications/questInvitation.vue | 4 +- .../notifications/unallocatedStatsPoints.vue | 8 +- .../header/notifications/verifyUsername.vue | 42 +- .../header/notifications/worldBoss.vue | 4 +- .../header/notificationsDropdown.vue | 62 +- .../src/components/header/userDropdown.vue | 8 +- .../inventory/equipment/attributesGrid.vue | 54 +- .../inventory/equipment/attributesPopover.vue | 60 +- .../inventory/equipment/equipGearModal.vue | 175 ++-- .../components/inventory/equipment/index.vue | 32 +- .../client/src/components/inventory/index.vue | 2 +- .../inventory/items/cards-modal.vue | 8 +- .../src/components/inventory/items/index.vue | 66 +- .../components/inventory/stable/foodItem.vue | 2 +- .../inventory/stable/hatchedPetDialog.vue | 60 +- .../inventory/stable/hatchingModal.vue | 2 +- .../src/components/inventory/stable/index.vue | 919 +++++++++--------- .../components/inventory/stable/mountItem.vue | 70 +- .../inventory/stable/mountRaisedModal.vue | 64 +- .../components/inventory/stable/petItem.vue | 162 +-- .../client/src/components/memberDetails.vue | 19 +- .../client/src/components/modifyInventory.vue | 10 +- .../client/src/components/notifications.vue | 61 +- website/client/src/components/parentPage.vue | 2 +- .../src/components/payments/amazonButton.vue | 31 +- .../src/components/payments/amazonModal.vue | 30 +- .../src/components/payments/buyGemsModal.vue | 124 +-- .../payments/cancelModalConfirm.vue | 4 +- .../src/components/payments/canceledModal.vue | 6 +- .../src/components/payments/sendGemsModal.vue | 27 +- .../src/components/payments/successModal.vue | 36 +- .../src/components/selectMembersModal.vue | 22 +- .../client/src/components/settings/api.vue | 10 +- .../src/components/settings/deleteModal.vue | 2 +- .../src/components/settings/notifications.vue | 8 +- .../src/components/settings/promoCode.vue | 4 +- .../src/components/settings/resetModal.vue | 4 +- .../src/components/settings/restoreModal.vue | 4 +- .../client/src/components/settings/site.vue | 45 +- .../src/components/settings/subscription.vue | 48 +- .../src/components/settings/usernameForm.vue | 222 ++--- .../components/settings/verifyUsername.vue | 28 +- .../src/components/shared/inventoryDrawer.vue | 212 ++-- .../src/components/shops/balanceInfo.vue | 102 +- .../client/src/components/shops/buyModal.vue | 436 ++++----- .../components/shops/featuredItemsHeader.vue | 52 +- website/client/src/components/shops/index.vue | 14 +- .../components/shops/market/categoryItem.vue | 4 +- .../components/shops/market/categoryRow.vue | 130 ++- .../shops/market/equipmentSection.vue | 211 ++-- .../src/components/shops/market/filter.vue | 31 +- .../src/components/shops/market/index.vue | 388 ++++---- .../components/shops/market/keysToKennel.vue | 10 +- .../src/components/shops/market/sellModal.vue | 126 +-- .../components/shops/quests/buyQuestModal.vue | 266 +++-- .../src/components/shops/quests/index.vue | 275 +++--- .../shops/quests/questDialogContent.vue | 46 +- .../shops/quests/questDialogDrops.vue | 95 +- .../src/components/shops/quests/questInfo.vue | 99 +- .../src/components/shops/seasonal/index.vue | 444 ++++----- .../client/src/components/shops/shopItem.vue | 176 ++-- .../components/shops/timeTravelers/index.vue | 324 +++--- .../client/src/components/sidebarSection.vue | 60 +- .../src/components/snackbars/notification.vue | 52 +- .../components/static/clearBrowserData.vue | 34 +- website/client/src/components/static/faq.vue | 94 +- .../client/src/components/static/features.vue | 20 +- .../src/components/static/groupPlans.vue | 98 +- website/client/src/components/static/home.vue | 318 +++--- .../client/src/components/static/merch.vue | 38 +- .../client/src/components/static/newStuff.vue | 2 +- .../client/src/components/static/pressKit.vue | 186 ++-- .../src/components/tasks/approvalFooter.vue | 41 +- .../src/components/tasks/approvalHeader.vue | 22 +- .../src/components/tasks/approvalModal.vue | 4 +- .../src/components/tasks/brokenTaskModal.vue | 8 +- .../client/src/components/tasks/column.vue | 82 +- .../client/src/components/tasks/spells.vue | 8 +- .../client/src/components/tasks/tagsPopup.vue | 2 +- website/client/src/components/tasks/task.vue | 48 +- .../client/src/components/tasks/taskModal.vue | 63 +- website/client/src/components/tasks/user.vue | 24 +- website/client/src/components/ui/checkbox.vue | 32 +- .../client/src/components/ui/countBadge.vue | 18 +- .../src/components/ui/customMenuDropdown.vue | 2 +- website/client/src/components/ui/drawer.vue | 16 +- .../src/components/ui/drawerHeaderTabs.vue | 34 +- .../client/src/components/ui/drawerSlider.vue | 151 ++- .../src/components/ui/filterDropdown.vue | 42 +- website/client/src/components/ui/itemRows.vue | 123 ++- .../src/components/ui/layoutSection.vue | 10 +- .../client/src/components/ui/pageLayout.vue | 16 +- .../client/src/components/ui/starBadge.vue | 26 +- website/client/src/components/ui/statsbar.vue | 83 +- .../client/src/components/ui/toggleSwitch.vue | 17 +- website/client/src/components/userLink.vue | 145 ++- .../src/components/userMenu/achievements.vue | 2 +- .../client/src/components/userMenu/inbox.vue | 109 +-- .../src/components/userMenu/profile.vue | 34 +- .../src/components/userMenu/profileModal.vue | 64 +- .../src/components/userMenu/profilePage.vue | 14 +- .../src/components/userMenu/profileStats.vue | 371 ++++--- .../client/src/components/userMenu/stats.vue | 30 +- .../world-boss/worldBossRageModal.vue | 38 +- .../src/components/yesterdailyModal.vue | 4 +- .../client/src/directives/directive.common.js | 2 +- website/client/src/directives/markdown.js | 4 +- .../src/directives/mouseposition.directive.js | 2 +- .../client/src/filters/floorWholeNumber.js | 2 +- website/client/src/filters/registerGlobals.js | 2 +- website/client/src/filters/round.js | 2 +- website/client/src/filters/roundBigNumber.js | 9 +- website/client/src/libs/analytics.js | 12 +- website/client/src/libs/asyncResource.js | 18 +- website/client/src/libs/auth.js | 2 +- website/client/src/libs/createAnimal.js | 19 +- website/client/src/libs/encodeParams.js | 4 +- website/client/src/libs/i18n.js | 8 +- website/client/src/libs/notifications.js | 4 +- .../src/libs/store/helpers/filterTasks.js | 10 +- .../src/libs/store/helpers/internals.js | 4 +- .../src/libs/store/helpers/orderTasks.js | 2 +- .../client/src/libs/store/helpers/public.js | 14 +- website/client/src/libs/store/index.js | 6 +- website/client/src/main.js | 2 +- .../client/src/mixins/avatarEditUtilities.js | 24 +- website/client/src/mixins/buy.js | 3 +- website/client/src/mixins/groupsUtilities.js | 10 +- website/client/src/mixins/guide.js | 36 +- website/client/src/mixins/inventoryUtils.js | 4 +- website/client/src/mixins/notifications.js | 12 +- website/client/src/mixins/openedItemRows.js | 4 +- website/client/src/mixins/payments.js | 36 +- website/client/src/mixins/petMixin.js | 4 +- website/client/src/mixins/pinUtils.js | 4 +- website/client/src/mixins/spells.js | 33 +- website/client/src/mixins/stats.js | 38 +- website/client/src/mixins/styleHelper.js | 4 +- website/client/src/mixins/sync.js | 4 +- website/client/src/mixins/userState.js | 2 +- website/client/src/router/handleRedirect.js | 6 +- website/client/src/router/index.js | 86 +- website/client/src/store/actions/auth.js | 30 +- .../client/src/store/actions/challenges.js | 28 +- website/client/src/store/actions/chat.js | 20 +- website/client/src/store/actions/common.js | 6 +- website/client/src/store/actions/guilds.js | 62 +- website/client/src/store/actions/hall.js | 22 +- website/client/src/store/actions/members.js | 38 +- .../client/src/store/actions/notifications.js | 16 +- website/client/src/store/actions/quests.js | 2 +- website/client/src/store/actions/shops.js | 53 +- website/client/src/store/actions/snackbars.js | 6 +- website/client/src/store/actions/tags.js | 30 +- website/client/src/store/actions/tasks.js | 52 +- website/client/src/store/actions/user.js | 35 +- website/client/src/store/getters/members.js | 6 +- website/client/src/store/getters/tasks.js | 59 +- website/client/src/store/getters/user.js | 4 +- website/client/src/store/index.js | 8 +- website/client/tests/unit/.eslintrc.js | 6 +- .../tests/unit/components/avatar.spec.js | 12 +- .../categories/categoryTags.spec.js | 8 +- .../challenges/challengeDetail.spec.js | 16 +- .../components/groups/membersModal.spec.js | 1 + .../unit/components/notifications.spec.js | 2 +- .../unit/components/sidebarSection.spec.js | 4 +- .../unit/components/tasks/column.spec.js | 34 +- .../tests/unit/components/ui/drawer.spec.js | 8 +- .../client/tests/unit/filters/floor.spec.js | 2 +- .../client/tests/unit/filters/round.spec.js | 2 +- .../tests/unit/filters/roundBigNumber.spec.js | 2 +- .../tests/unit/libs/asyncResource.spec.js | 14 +- .../client/tests/unit/libs/deepFreeze.spec.js | 6 +- .../tests/unit/libs/highlightUsers.spec.js | 2 +- website/client/tests/unit/libs/i18n.spec.js | 4 +- website/client/tests/unit/libs/store.spec.js | 16 +- .../libs/store/helpers/filterTasks.spec.js | 9 +- .../libs/store/helpers/orderTasks.spec.js | 11 +- .../tests/unit/mixins/groupsUtilities.spec.js | 7 +- .../tests/unit/store/actions/shops.spec.js | 8 +- .../tests/unit/store/actions/tasks.spec.js | 18 +- .../tests/unit/store/actions/user.spec.js | 20 +- .../store/getters/members/hasClass.spec.js | 2 +- .../store/getters/tasks/canDelete.spec.js | 4 +- .../store/getters/tasks/getTagsFor.spec.js | 8 +- .../getters/tasks/getTaskClasses.spec.js | 47 +- .../unit/store/getters/tasks/getTasks.spec.js | 11 +- .../unit/store/getters/user/user.spec.js | 6 +- website/client/vue.config.js | 90 +- .../common/script/content/appearance/size.js | 2 +- .../common/script/content/gear/gear-helper.js | 2 +- .../common/script/content/gear/sets/healer.js | 1 - website/common/script/content/gear/weapon.js | 5 +- website/common/script/content/index.js | 2 +- .../common/script/content/loginIncentives.js | 22 +- website/common/script/content/quests.js | 2 +- website/common/script/content/spells.js | 8 +- website/common/script/cron.js | 2 +- website/common/script/fns/crit.js | 4 +- website/common/script/fns/randomDrop.js | 4 +- website/common/script/index.js | 3 +- website/common/script/libs/inAppRewards.js | 3 +- website/common/script/libs/preenTodos.js | 2 +- website/common/script/libs/shops.js | 114 ++- website/common/script/libs/statsComputed.js | 2 +- .../script/ops/buy/abstractBuyOperation.js | 32 +- website/common/script/ops/buy/buyArmoire.js | 6 +- website/common/script/ops/buy/buyGem.js | 14 +- .../common/script/ops/buy/buyHealthPotion.js | 6 +- .../common/script/ops/buy/buyMarketGear.js | 8 +- website/common/script/ops/buy/buyMount.js | 6 +- website/common/script/ops/buy/buyQuestGem.js | 10 +- website/common/script/ops/buy/buyQuestGold.js | 15 +- website/common/script/ops/buy/buySpell.js | 8 +- website/common/script/ops/revive.js | 3 +- website/common/script/ops/scoreTask.js | 6 +- website/server/.eslintrc | 5 - website/server/.eslintrc.js | 5 + website/server/index.js | 11 +- 330 files changed, 6885 insertions(+), 7668 deletions(-) delete mode 100644 webpack/build.js delete mode 100644 webpack/config/dev.env.js delete mode 100644 webpack/config/index.js delete mode 100644 webpack/config/prod.env.js delete mode 100644 webpack/config/test.env.js delete mode 100644 webpack/dev-client.js delete mode 100644 webpack/dev-server.js delete mode 100644 webpack/utils.js delete mode 100644 webpack/webpack.base.conf.js delete mode 100644 webpack/webpack.dev.conf.js delete mode 100644 webpack/webpack.prod.conf.js delete mode 100644 webpack/webpack.test.conf.js delete mode 100644 website/server/.eslintrc create mode 100644 website/server/.eslintrc.js diff --git a/package-lock.json b/package-lock.json index 5cf2d56b68..71b54c232c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4476,9 +4476,9 @@ } }, "eslint-config-habitrpg": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/eslint-config-habitrpg/-/eslint-config-habitrpg-6.0.7.tgz", - "integrity": "sha512-hda2IKsfwE/94CjLtPI3Cgsq0capQCFKCiqPPNM7foeO/E6cZpXCSvMHdGt5TXy66DQxF5h+kz4xcheHdcaRcA==", + "version": "6.0.8", + "resolved": "https://registry.npmjs.org/eslint-config-habitrpg/-/eslint-config-habitrpg-6.0.8.tgz", + "integrity": "sha512-jQ62H3+Gkie4CK8uFfV37SX+yNs6yu+SHP27hIYIlnZ21HCaQnabEQfhrYzbpQUn9fNd2y1gUNqGOIG8ph84vg==", "dev": true, "requires": { "eslint": "^6.5.1", diff --git a/package.json b/package.json index e2993caf3e..b0b3ec4e46 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "npm": "^6" }, "scripts": { - "lint": "eslint --ext .js --fix ./website/server", + "lint": "eslint --ext .js --fix ./website/common", "test": "npm run lint && gulp test && gulp apidoc", "test:build": "gulp test:prepare:build", "test:api-v3": "gulp test:api-v3", @@ -103,7 +103,7 @@ "chai-as-promised": "^7.1.1", "chalk": "^2.4.1", "eslint": "^6.5.1", - "eslint-config-habitrpg": "^6.0.7", + "eslint-config-habitrpg": "^6.0.8", "eslint-plugin-mocha": "^5.0.0", "expect.js": "^0.3.1", "istanbul": "^1.1.0-alpha.1", diff --git a/webpack/build.js b/webpack/build.js deleted file mode 100644 index 793784e55b..0000000000 --- a/webpack/build.js +++ /dev/null @@ -1,47 +0,0 @@ -/* global env:true, rm:true, mkdir:true, cp:true */ - -// https://github.com/shelljs/shelljs -require('shelljs/global'); - -const path = require('path'); -const config = require('./config'); -const ora = require('ora'); -const webpack = require('webpack'); -const webpackConfig = require('./webpack.prod.conf'); - -module.exports = function webpackProductionBuild (callback) { - env.NODE_ENV = 'production'; - - console.log( // eslint-disable-line no-console - ' Tip:\n' + - ' Built files are meant to be served over an HTTP server.\n' + - ' Opening index.html over file:// won\'t work.\n' - ); - - const spinner = ora('building for production...'); - spinner.start(); - - const assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory); - rm('-rf', assetsPath); - mkdir('-p', assetsPath); - cp('-R', config.build.staticAssetsDirectory, assetsPath); - - webpack(webpackConfig, (err, stats) => { - spinner.stop(); - - const output = `${stats.toString({ - colors: true, - modules: false, - children: false, - chunks: false, - chunkModules: false, - })}\n`; - - if (callback) { - return err ? callback(err) : callback(null, output); - } else { - if (err) throw err; - process.stdout.write(output); - } - }); -}; diff --git a/webpack/config/dev.env.js b/webpack/config/dev.env.js deleted file mode 100644 index 6c18ee1767..0000000000 --- a/webpack/config/dev.env.js +++ /dev/null @@ -1,6 +0,0 @@ -const merge = require('webpack-merge'); -const prodEnv = require('./prod.env'); - -module.exports = merge(prodEnv, { - NODE_ENV: '"development"', -}); diff --git a/webpack/config/index.js b/webpack/config/index.js deleted file mode 100644 index ca098d0a95..0000000000 --- a/webpack/config/index.js +++ /dev/null @@ -1,81 +0,0 @@ -// see http://vuejs-templates.github.io/webpack for documentation. -const path = require('path'); -const staticAssetsDirectory = './website/static/.'; // The folder where static files (not processed) live -const prodEnv = require('./prod.env'); -const devEnv = require('./dev.env'); -const nconf = require('nconf'); -const setupNconf = require('../../website/server/libs/setupNconf'); - -let configFile = path.join(path.resolve(__dirname, '../../config.json')); - -setupNconf(configFile); - -const DEV_BASE_URL = nconf.get('BASE_URL'); - -module.exports = { - build: { - env: prodEnv, - index: path.resolve(__dirname, '../../dist-client/index.html'), - assetsRoot: path.resolve(__dirname, '../../dist-client'), - assetsSubDirectory: 'static', - assetsPublicPath: '/', - staticAssetsDirectory, - productionSourceMap: true, - // Gzip off by default as many popular static hosts such as - // Surge or Netlify already gzip all static assets for you. - // Before setting to `true`, make sure to: - // npm install --save-dev compression-webpack-plugin - productionGzip: false, - productionGzipExtensions: ['js', 'css'], - // Run the build command with an extra argument to - // View the bundle analyzer report after build finishes: - // `npm run client:build --report` - // Set to `true` or `false` to always turn it on or off - bundleAnalyzerReport: process.env.npm_config_report, // eslint-disable-line no-process-env - }, - dev: { - env: devEnv, - port: 8080, - autoOpenBrowser: true, - assetsSubDirectory: 'static', - assetsPublicPath: '/', - staticAssetsDirectory, - proxyTable: { - // proxy all requests to the server at IP:PORT as specified in the top-level config - '/api/v3': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - '/api/v4': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - '/stripe': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - '/amazon': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - '/paypal': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - '/logout-server': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - '/export': { - target: DEV_BASE_URL, - changeOrigin: true, - }, - }, - // CSS Sourcemaps off by default because relative paths are "buggy" - // with this option, according to the CSS-Loader README - // (https://github.com/webpack/css-loader#sourcemaps) - // In our experience, they generally work as expected, - // just be aware of this issue when enabling this option. - cssSourceMap: false, - }, -}; diff --git a/webpack/config/prod.env.js b/webpack/config/prod.env.js deleted file mode 100644 index 7b89084678..0000000000 --- a/webpack/config/prod.env.js +++ /dev/null @@ -1,45 +0,0 @@ -const nconf = require('nconf'); -const { join, resolve } = require('path'); -const setupNconf = require('../../website/server/libs/setupNconf'); - -const PATH_TO_CONFIG = join(resolve(__dirname, '../../config.json')); -let configFile = PATH_TO_CONFIG; - -setupNconf(configFile); - -// @TODO: Check if we can import from client. Items like admin emails can be imported -// and that should be prefered - -// To avoid stringifying more data then we need, -// items from `env` used on the client will have to be specified in this array -// @TODO: Do we need? const CLIENT_VARS = ['language', 'isStaticPage', 'availableLanguages', 'translations', -// 'FACEBOOK_KEY', 'GOOGLE_CLIENT_ID', 'NODE_ENV', 'BASE_URL', 'GA_ID', -// 'AMAZON_PAYMENTS', 'STRIPE_PUB_KEY', 'AMPLITUDE_KEY', -// 'worldDmg', 'mods', 'IS_MOBILE']; - -const AMAZON_SELLER_ID = nconf.get('AMAZON_PAYMENTS_SELLER_ID'); -const AMAZON_CLIENT_ID = nconf.get('AMAZON_PAYMENTS_CLIENT_ID'); -const AMAZON_MODE = nconf.get('AMAZON_PAYMENTS_MODE'); - -let env = { - NODE_ENV: '"production"', - // clientVars: CLIENT_VARS, - AMAZON_PAYMENTS: { - SELLER_ID: `"${AMAZON_SELLER_ID}"`, - CLIENT_ID: `"${AMAZON_CLIENT_ID}"`, - MODE: `"${AMAZON_MODE}"`, - }, - EMAILS: { - COMMUNITY_MANAGER_EMAIL: `"${nconf.get('EMAILS_COMMUNITY_MANAGER_EMAIL')}"`, - TECH_ASSISTANCE_EMAIL: `"${nconf.get('EMAILS_TECH_ASSISTANCE_EMAIL')}"`, - PRESS_ENQUIRY_EMAIL: `"${nconf.get('EMAILS_PRESS_ENQUIRY_EMAIL')}"`, - }, -}; - -'NODE_ENV BASE_URL GA_ID STRIPE_PUB_KEY FACEBOOK_KEY GOOGLE_CLIENT_ID AMPLITUDE_KEY LOGGLY_CLIENT_TOKEN' - .split(' ') - .forEach(key => { - env[key] = `"${nconf.get(key)}"`; - }); - -module.exports = env; diff --git a/webpack/config/test.env.js b/webpack/config/test.env.js deleted file mode 100644 index 42e6329b71..0000000000 --- a/webpack/config/test.env.js +++ /dev/null @@ -1,6 +0,0 @@ -const merge = require('webpack-merge'); -const devEnv = require('./dev.env'); - -module.exports = merge(devEnv, { - NODE_ENV: '"test"', -}); diff --git a/webpack/dev-client.js b/webpack/dev-client.js deleted file mode 100644 index e81faee24c..0000000000 --- a/webpack/dev-client.js +++ /dev/null @@ -1,10 +0,0 @@ -/* global window:true */ - -require('eventsource-polyfill'); -const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true&overlay=false'); - -hotClient.subscribe(event => { - if (event.action === 'reload') { - window.location.reload(); - } -}); diff --git a/webpack/dev-server.js b/webpack/dev-server.js deleted file mode 100644 index aee1529044..0000000000 --- a/webpack/dev-server.js +++ /dev/null @@ -1,72 +0,0 @@ -/* eslint-disable no-process-env, no-console */ - -const path = require('path'); -const express = require('express'); -const webpack = require('webpack'); -const config = require('./config'); - -if (!process.env.NODE_ENV) { - process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV); -} - -const proxyMiddleware = require('http-proxy-middleware'); -const webpackConfig = process.env.NODE_ENV === 'test' ? - require('./webpack.prod.conf') : - require('./webpack.dev.conf'); - -// default port where dev server listens for incoming traffic -const port = process.env.PORT || config.dev.port; -// Define HTTP proxies to your custom API backend -// https://github.com/chimurai/http-proxy-middleware -const proxyTable = config.dev.proxyTable; - -const app = express(); -const compiler = webpack(webpackConfig); - -const devMiddleware = require('webpack-dev-middleware')(compiler, { - publicPath: webpackConfig.output.publicPath, - stats: { - colors: true, - chunks: false, - }, -}); - -const hotMiddleware = require('webpack-hot-middleware')(compiler); -// force page reload when html-webpack-plugin template changes -compiler.plugin('compilation', (compilation) => { - compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => { - hotMiddleware.publish({ action: 'reload' }); - cb(); - }); -}); - -// proxy api requests -Object.keys(proxyTable).forEach((context) => { - let options = proxyTable[context]; - if (typeof options === 'string') { - options = { target: options }; - } - app.use(proxyMiddleware(options.filter || context, options)); -}); - -// handle fallback for HTML5 history API -app.use(require('connect-history-api-fallback')()); - -// serve webpack bundle output -app.use(devMiddleware); - -// enable hot-reload and state-preserving -// compilation error display -app.use(hotMiddleware); - -// serve pure static assets -const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory); -app.use(staticPath, express.static(config.dev.staticAssetsDirectory)); - -module.exports = app.listen(port, (err) => { - if (err) { - console.log(err); - return; - } - console.log(`Listening at http://localhost:${port}\n`); -}); diff --git a/webpack/utils.js b/webpack/utils.js deleted file mode 100644 index 5bf7fabe28..0000000000 --- a/webpack/utils.js +++ /dev/null @@ -1,66 +0,0 @@ -/* eslint-disable no-process-env, no-console */ - -const path = require('path'); -const config = require('./config'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); - -exports.assetsPath = (_path) => { - const assetsSubDirectory = process.env.NODE_ENV === 'production' ? - config.build.assetsSubDirectory : - config.dev.assetsSubDirectory; - return path.posix.join(assetsSubDirectory, _path); -}; - -exports.cssLoaders = function cssLoaders (options) { - options = options || {}; - // generate loader string to be used with extract text plugin - function generateLoaders (loaders) { - let sourceLoader = loaders.map((loader) => { - let extraParamChar; - if (/\?/.test(loader)) { - loader = loader.replace(/\?/, '-loader?'); - extraParamChar = '&'; - } else { - loader = `${loader}-loader`; - extraParamChar = '?'; - } - return loader + (options.sourceMap ? `${extraParamChar}sourceMap` : ''); - }).join('!'); - - // Extract CSS when that option is specified - // (which is the case during production build) - if (options.extract) { - return ExtractTextPlugin.extract({ - use: sourceLoader, - fallback: 'vue-style-loader', - }); - } else { - return ['vue-style-loader', sourceLoader].join('!'); - } - } - - // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html - return { - css: generateLoaders(['css']), - postcss: generateLoaders(['css']), - less: generateLoaders(['css', 'less']), - sass: generateLoaders(['css', 'sass?indentedSyntax']), - scss: generateLoaders(['css', 'sass']), - stylus: generateLoaders(['css', 'stylus']), - styl: generateLoaders(['css', 'stylus']), - }; -}; - -// Generate loaders for standalone style files (outside of .vue) -exports.styleLoaders = (options) => { - const output = []; - const loaders = exports.cssLoaders(options); - for (let extension in loaders) { - const loader = loaders[extension]; - output.push({ - test: new RegExp(`\\.${extension}$`), - loader, - }); - } - return output; -}; diff --git a/webpack/webpack.base.conf.js b/webpack/webpack.base.conf.js deleted file mode 100644 index fcc86bc21b..0000000000 --- a/webpack/webpack.base.conf.js +++ /dev/null @@ -1,154 +0,0 @@ -/* eslint-disable no-process-env, no-console */ - -const path = require('path'); -const config = require('./config'); -const utils = require('./utils'); -const webpack = require('webpack'); -const projectRoot = path.resolve(__dirname, '../'); -const autoprefixer = require('autoprefixer'); -const postcssEasyImport = require('postcss-easy-import'); -const IS_PROD = process.env.NODE_ENV === 'production'; - -const baseConfig = { - entry: { - app: ['babel-polyfill', './website/client/main.js'], - }, - output: { - path: config.build.assetsRoot, - publicPath: IS_PROD ? config.build.assetsPublicPath : config.dev.assetsPublicPath, - filename: '[name].js', - devtoolModuleFilenameTemplate (info) { - // Fix source maps, code from - // https://github.com/Darkside73/bbsmile.com.ua/commit/3596d3c42ef91b69d8380359c3e8908edc08acdb - let filename = info.resourcePath; - if (info.resource.match(/\.vue$/) && !info.allLoaders.match(/type=script/)) { - filename = 'generated'; - } - - return filename; - }, - }, - resolve: { - extensions: ['*', '.js', '.vue', '.json'], - modules: [ - path.join(projectRoot, 'website'), - path.join(projectRoot, 'test/client/unit'), - path.join(projectRoot, 'node_modules'), - ], - alias: { - website: path.resolve(projectRoot, 'website'), - common: path.resolve(projectRoot, 'website/common'), - client: path.resolve(projectRoot, 'website/client'), - assets: path.resolve(projectRoot, 'website/client/assets'), - components: path.resolve(projectRoot, 'website/client/components'), - }, - }, - plugins: [ - new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/(NOT_EXISTING)$/), - ], - module: { - rules: [ - { - test: /\.vue$/, - loader: 'vue-loader', - options: { - loaders: utils.cssLoaders({ - sourceMap: IS_PROD ? - config.build.productionSourceMap : - config.dev.cssSourceMap, - extract: IS_PROD, - }), - postcss: [ - autoprefixer({ - overrideBrowserslist: ['last 2 versions'], - }), - postcssEasyImport(), - ], - }, - }, - { - test: /\.js$/, - loader: 'babel-loader', - include: [ - path.join(projectRoot, 'test'), - path.join(projectRoot, 'website'), - path.join(projectRoot, 'node_modules', 'bootstrap-vue'), - ], - options: { - cacheDirectory: true, - }, - }, - { - test: /\.(png|jpe?g|gif)(\?.*)?$/, - loader: 'url-loader', - query: { - limit: 10000, - name: utils.assetsPath('images/[name].[hash:7].[ext]'), - }, - }, - { - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, - loader: 'url-loader', - query: { - limit: 10000, - name: utils.assetsPath('fonts/[name].[hash:7].[ext]'), - }, - }, - { - test: /\.svg$/, - use: [ - { loader: 'svg-inline-loader' }, - { - loader: 'svgo-loader', - options: { - plugins: [ - {removeViewBox: false}, - {convertPathData: {noSpaceAfterFlags: false}}, - ], - }, - }, - ], - exclude: [path.resolve(projectRoot, 'website/client/assets/svg/for-css')], - }, - { - test: /\.svg$/, - use: [ - { - loader: 'svg-url-loader', - options: { - limit: 10000, - name: utils.assetsPath('svg/[name].[hash:7].[ext]'), - }, - }, - { - loader: 'svgo-loader', - options: { - plugins: [ - {removeViewBox: false}, - {convertPathData: {noSpaceAfterFlags: false}}, - ], - }, - }, - ], - include: [path.resolve(projectRoot, 'website/client/assets/svg/for-css')], - }, - ], - }, -}; - -if (!IS_PROD) { - const eslintFriendlyFormatter = require('eslint-friendly-formatter'); // eslint-disable-line global-require - - baseConfig.module.rules.unshift({ - test: /\.(js|vue)$/, - loader: 'eslint-loader', - enforce: 'pre', - include: projectRoot, - options: { - formatter: eslintFriendlyFormatter, - emitWarning: true, - }, - exclude: /node_modules/, - }); -} -module.exports = baseConfig; \ No newline at end of file diff --git a/webpack/webpack.dev.conf.js b/webpack/webpack.dev.conf.js deleted file mode 100644 index 75d6741d08..0000000000 --- a/webpack/webpack.dev.conf.js +++ /dev/null @@ -1,32 +0,0 @@ -const config = require('./config'); -const webpack = require('webpack'); -const merge = require('webpack-merge'); -const utils = require('./utils'); -const baseWebpackConfig = require('./webpack.base.conf'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); - -// add hot-reload related code to entry chunks -Object.keys(baseWebpackConfig.entry).forEach((name) => { - baseWebpackConfig.entry[name] = baseWebpackConfig.entry[name].concat('./webpack/dev-client'); -}); - -module.exports = merge(baseWebpackConfig, { - module: { - rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }), - }, - // cheap-module-eval-source-map is faster for development - devtool: '#cheap-module-eval-source-map', - plugins: [ - new webpack.DefinePlugin({ - 'process.env': config.dev.env, - }), - // https://github.com/glenjamin/webpack-hot-middleware#installation--usage - new webpack.HotModuleReplacementPlugin(), - // https://github.com/ampedandwired/html-webpack-plugin - new HtmlWebpackPlugin({ - filename: 'index.html', - template: './website/client/index.html', - inject: true, - }), - ], -}); diff --git a/webpack/webpack.prod.conf.js b/webpack/webpack.prod.conf.js deleted file mode 100644 index 5ee916508e..0000000000 --- a/webpack/webpack.prod.conf.js +++ /dev/null @@ -1,101 +0,0 @@ -/* eslint-disable no-process-env, no-console */ - -const path = require('path'); -const config = require('./config'); -const utils = require('./utils'); -const webpack = require('webpack'); -const merge = require('webpack-merge'); -const baseWebpackConfig = require('./webpack.base.conf'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const HtmlWebpackPlugin = require('html-webpack-plugin'); -const env = process.env.NODE_ENV === 'test' ? - require('./config/test.env') : - config.build.env; - -const webpackConfig = merge(baseWebpackConfig, { - module: { - rules: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true }), - }, - devtool: config.build.productionSourceMap ? '#source-map' : false, - output: { - path: config.build.assetsRoot, - filename: utils.assetsPath('js/[name].[chunkhash].js'), - chunkFilename: utils.assetsPath('js/[id].[chunkhash].js'), - }, - plugins: [ - // http://vuejs.github.io/vue-loader/workflow/production.html - new webpack.DefinePlugin({ - 'process.env': env, - }), - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false, - }, - sourceMap: true, - }), - // extract css into its own file - new ExtractTextPlugin({ - filename: utils.assetsPath('css/[name].[contenthash].css'), - }), - // generate dist index.html with correct asset hash for caching. - // you can customize output by editing /index.html - // see https://github.com/ampedandwired/html-webpack-plugin - new HtmlWebpackPlugin({ - filename: process.env.NODE_ENV === 'test' ? - 'index.html' : - config.build.index, - template: './website/client/index.html', - inject: true, - minify: { - removeComments: true, - collapseWhitespace: true, - removeAttributeQuotes: true, - // more options: - // https://github.com/kangax/html-minifier#options-quick-reference - }, - // necessary to consistently work with multiple chunks via CommonsChunkPlugin - chunksSortMode: 'dependency', - }), - // split vendor js into its own file - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - minChunks (scriptModule) { - // any required modules inside node_modules are extracted to vendor - return ( - scriptModule.resource && - /\.js$/.test(scriptModule.resource) && - scriptModule.resource.indexOf( - path.join(__dirname, '../node_modules') - ) === 0 - ); - }, - }), - // extract webpack runtime and module manifest to its own file in order to - // prevent vendor hash from being updated whenever app bundle is updated - new webpack.optimize.CommonsChunkPlugin({ - name: 'manifest', - chunks: ['vendor'], - }), - ], -}); - -if (config.build.productionGzip) { - const CompressionWebpackPlugin = require('compression-webpack-plugin'); // eslint-disable-line global-require - - webpackConfig.plugins.push( - new CompressionWebpackPlugin({ - asset: '[path].gz[query]', - algorithm: 'gzip', - test: new RegExp(`\\.(${config.build.productionGzipExtensions.join('|')})$`), - threshold: 10240, - minRatio: 0.8, - }) - ); -} - -if (config.build.bundleAnalyzerReport) { - const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // eslint-disable-line global-require - webpackConfig.plugins.push(new BundleAnalyzerPlugin()); -} - -module.exports = webpackConfig; diff --git a/webpack/webpack.test.conf.js b/webpack/webpack.test.conf.js deleted file mode 100644 index 16327ea609..0000000000 --- a/webpack/webpack.test.conf.js +++ /dev/null @@ -1,24 +0,0 @@ -// This is the webpack config used for unit tests. -const merge = require('webpack-merge'); -const baseConfig = require('./webpack.base.conf'); -const utils = require('./utils'); -const webpack = require('webpack'); -const testEnv = require('./config/test.env'); - -const webpackConfig = merge(baseConfig, { - // use inline sourcemap for karma-sourcemap-loader - module: { - rules: utils.styleLoaders(), - }, - devtool: '#inline-source-map', - plugins: [ - new webpack.DefinePlugin({ - 'process.env': testEnv, - }), - ], -}); - -// no need for app entry during tests -delete webpackConfig.entry; - -module.exports = webpackConfig; diff --git a/website/client/.eslintrc.js b/website/client/.eslintrc.js index e37caab6e4..de3a53ac1a 100644 --- a/website/client/.eslintrc.js +++ b/website/client/.eslintrc.js @@ -1,27 +1,26 @@ module.exports = { root: true, env: { - node: true + node: true, }, - 'extends': [ - 'plugin:vue/essential', - 'eslint:recommended' + extends: [ + 'habitrpg/lib/vue', ], rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', }, parserOptions: { - parser: 'babel-eslint' + parser: 'babel-eslint', }, overrides: [ { files: [ - '**/__tests__/*.{j,t}s?(x)' + '**/__tests__/*.{j,t}s?(x)', ], env: { - mocha: true - } - } - ] -} + mocha: true, + }, + }, + ], +}; diff --git a/website/client/babel.config.js b/website/client/babel.config.js index e9558405fd..757ff9b16a 100644 --- a/website/client/babel.config.js +++ b/website/client/babel.config.js @@ -1,5 +1,5 @@ module.exports = { presets: [ - '@vue/cli-plugin-babel/preset' - ] -} + '@vue/cli-plugin-babel/preset', + ], +}; diff --git a/website/client/postcss.config.js b/website/client/postcss.config.js index 961986e2b1..a47ef4f952 100644 --- a/website/client/postcss.config.js +++ b/website/client/postcss.config.js @@ -1,5 +1,5 @@ module.exports = { plugins: { - autoprefixer: {} - } -} + autoprefixer: {}, + }, +}; diff --git a/website/client/src/app.vue b/website/client/src/app.vue index 64d3ec8fd7..4cc73fee6a 100644 --- a/website/client/src/app.vue +++ b/website/client/src/app.vue @@ -201,8 +201,7 @@ import bannedAccountModal from '@/components/bannedAccountModal'; const COMMUNITY_MANAGER_EMAIL = process.env.EMAILS_COMMUNITY_MANAGER_EMAIL; // eslint-disable-line export default { - mixins: [notifications, spellsMixin], - name: 'app', + name: 'App', components: { AppMenu, AppHeader, @@ -217,6 +216,7 @@ export default { subCancelModalConfirm, subCanceledModal, }, + mixins: [notifications, spellsMixin], data () { return { icons: Object.freeze({ @@ -235,9 +235,9 @@ export default { }, computed: { ...mapState(['isUserLoggedIn', 'browserTimezoneOffset', 'isUserLoaded']), - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), isStaticPage () { - return this.$route.meta.requiresLogin === false ? true : false; + return this.$route.meta.requiresLogin === false; }, castingSpell () { return this.$store.state.spellOptions.castingSpell; @@ -256,14 +256,14 @@ export default { }, }, created () { - this.$root.$on('playSound', (sound) => { - let theme = this.user.preferences.sound; + this.$root.$on('playSound', sound => { + const theme = this.user.preferences.sound; if (!theme || theme === 'off') { return; } - let file = `/static/audio/${theme}/${sound}`; + const file = `/static/audio/${theme}/${sound}`; if (this.audioSuffix === null) { this.audioSource = document.createElement('source'); @@ -284,12 +284,12 @@ export default { }); // @TODO: I'm not sure these should be at the app level. Can we move these back into shop/inventory or maybe they need a lateral move? - this.$root.$on('buyModal::showItem', (item) => { + this.$root.$on('buyModal::showItem', item => { this.selectedItemToBuy = item; this.$root.$emit('bv::show::modal', 'buy-modal'); }); - this.$root.$on('selectMembersModal::showItem', (item) => { + this.$root.$on('selectMembersModal::showItem', item => { this.selectedSpellToBuy = item; this.$root.$emit('bv::show::modal', 'select-member-modal'); }); @@ -301,18 +301,18 @@ export default { }); // Set up Error interceptors - axios.interceptors.response.use((response) => { + axios.interceptors.response.use(response => { if (this.user && response.data && response.data.notifications) { this.$set(this.user, 'notifications', response.data.notifications); } return response; - }, (error) => { + }, error => { if (error.response.status >= 400) { this.checkForBannedUser(error); // Don't show errors from getting user details. These users have delete their account, // but their chat message still exists. - let configExists = Boolean(error.response) && Boolean(error.response.config); + const configExists = Boolean(error.response) && Boolean(error.response.config); if (configExists && error.response.config.method === 'get' && error.response.config.url.indexOf('/api/v4/members/') !== -1) { // @TODO: We resolve the promise because we need our caching to cache this user as tried // Chat paging should help this, but maybe we can also find another solution.. @@ -333,11 +333,11 @@ export default { let snackbarTimeout = false; if (error.response.status === 502) snackbarTimeout = true; - let errorsToShow = []; + const errorsToShow = []; // show only the first error for each param - let paramErrorsFound = {}; + const paramErrorsFound = {}; if (errorData.errors) { - for (let e of errorData.errors) { + for (const e of errorData.errors) { if (!paramErrorsFound[e.param]) { errorsToShow.push(e.message); paramErrorsFound[e.param] = true; @@ -362,11 +362,11 @@ export default { return Promise.reject(error); }); - axios.interceptors.response.use((response) => { + axios.interceptors.response.use(response => { // Verify that the user was not updated from another browser/app/client // If it was, sync - const url = response.config.url; - const method = response.config.method; + const { url } = response.config; + const { method } = response.config; const isApiCall = url.indexOf('api/v4') !== -1; const userV = response.data && response.data.userV; @@ -380,14 +380,14 @@ export default { const isUserSync = url.indexOf('/api/v4/user') === 0 && method === 'get'; const isTasksSync = url.indexOf('/api/v4/tasks/user') === 0 && method === 'get'; // exclude chat seen requests because with real time chat they would be too many - const isChatSeen = url.indexOf('/chat/seen') !== -1 && method === 'post'; + const isChatSeen = url.indexOf('/chat/seen') !== -1 && method === 'post'; // exclude POST /api/v4/cron because the user is synced automatically after cron runs // Something has changed on the user object that was not tracked here, sync the user if (userV - oldUserV > 1 && !isCron && !isChatSeen && !isUserSync && !isTasksSync) { Promise.all([ - this.$store.dispatch('user:fetch', {forceLoad: true}), - this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}), + this.$store.dispatch('user:fetch', { forceLoad: true }), + this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true }), ]); } } @@ -407,7 +407,7 @@ export default { }); // Setup listener for title - this.$store.watch(state => state.title, (title) => { + this.$store.watch(state => state.title, title => { document.title = title; }); this.$nextTick(() => { @@ -446,7 +446,7 @@ export default { // Load external scripts after the app has been rendered setupPayments(); }); - }).catch((err) => { + }).catch(err => { console.error('Impossible to fetch user. Clean up localStorage and refresh.', err); // eslint-disable-line no-console }); } else { @@ -491,17 +491,17 @@ export default { // Manage modals this.$root.$on('bv::show::modal', (modalId, data = {}) => { if (data.fromRoot) return; - const modalStack = this.$store.state.modalStack; + const { modalStack } = this.$store.state; this.trackGemPurchase(modalId, data); // Add new modal to the stack const prev = modalStack[modalStack.length - 1]; const prevId = prev ? prev.modalId : undefined; - modalStack.push({modalId, prev: prevId}); + modalStack.push({ modalId, prev: prevId }); }); - this.$root.$on('bv::modal::hidden', (bvEvent) => { + this.$root.$on('bv::modal::hidden', bvEvent => { let modalId = bvEvent.target && bvEvent.target.id; // sometimes the target isn't passed to the hidden event, fallback is the vueTarget @@ -513,7 +513,7 @@ export default { return; } - const modalStack = this.$store.state.modalStack; + const { modalStack } = this.$store.state; const modalOnTop = modalStack[modalStack.length - 1]; @@ -529,7 +529,7 @@ export default { // Get previous modal const modalBefore = modalOnTop ? modalOnTop.prev : undefined; - if (modalBefore) this.$root.$emit('bv::show::modal', modalBefore, {fromRoot: true}); + if (modalBefore) this.$root.$emit('bv::show::modal', modalBefore, { fromRoot: true }); }); }, validStack (modalStack) { @@ -537,7 +537,7 @@ export default { const modalCount = {}; const prevAndCurrent = 2; - for (let index in modalStack) { + for (const index in modalStack) { const current = modalStack[index]; if (!modalCount[current.modalId]) modalCount[current.modalId] = 0; @@ -574,11 +574,9 @@ export default { this.selectedItemToBuy = item; }, genericPurchase (item) { - if (!item) - return false; + if (!item) return false; - if (['card', 'debuffPotion'].includes(item.purchaseType)) - return false; + if (['card', 'debuffPotion'].includes(item.purchaseType)) return false; return true; }, @@ -609,7 +607,7 @@ export default { this.selectedSpellToBuy = null; if (this.user.party._id) { - this.$store.dispatch('party:getMembers', {forceLoad: true}); + this.$store.dispatch('party:getMembers', { forceLoad: true }); } this.$root.$emit('bv::hide::modal', 'select-member-modal'); diff --git a/website/client/src/components/404.vue b/website/client/src/components/404.vue index d94b3b3191..983d5c274b 100644 --- a/website/client/src/components/404.vue +++ b/website/client/src/components/404.vue @@ -3,8 +3,8 @@ .col-12.text-center // @TODO i18n. How to setup the strings with the router-link inside? img.not-found-img(src='~@/assets/images/404.png') - h1.not-found Sometimes even the bravest adventurer gets lost. - h2.not-found Looks like this link is broken or the page may have moved, sorry! + h1.not-found Sometimes even the bravest adventurer gets lost. + h2.not-found Looks like this link is broken or the page may have moved, sorry! h2.not-found Head back to the Homepage or Contact Us about the issue. @@ -16,10 +16,9 @@ export default { ...mapState(['isUserLoggedIn']), contactUsLink () { if (this.isUserLoggedIn) { - return {name: 'guild', params: {groupId: 'a29da26b-37de-4a71-b0c6-48e72a900dac'} }; - } else { - return {name: 'contact'}; + return { name: 'guild', params: { groupId: 'a29da26b-37de-4a71-b0c6-48e72a900dac' } }; } + return { name: 'contact' }; }, }, }; @@ -52,4 +51,4 @@ h2.not-found { margin-bottom: 0px; margin-top: 0px; } - \ No newline at end of file + diff --git a/website/client/src/components/achievements/achievementFooter.vue b/website/client/src/components/achievements/achievementFooter.vue index d751f840a8..da75a68147 100644 --- a/website/client/src/components/achievements/achievementFooter.vue +++ b/website/client/src/components/achievements/achievementFooter.vue @@ -56,13 +56,14 @@ diff --git a/website/client/src/components/achievements/justAddWater.vue b/website/client/src/components/achievements/justAddWater.vue index 7f027af528..b881c2e369 100644 --- a/website/client/src/components/achievements/justAddWater.vue +++ b/website/client/src/components/achievements/justAddWater.vue @@ -19,28 +19,28 @@ diff --git a/website/client/src/components/achievements/levelUp.vue b/website/client/src/components/achievements/levelUp.vue index f439939d85..90956723d4 100644 --- a/website/client/src/components/achievements/levelUp.vue +++ b/website/client/src/components/achievements/levelUp.vue @@ -116,20 +116,20 @@ diff --git a/website/client/src/components/achievements/lowHealth.vue b/website/client/src/components/achievements/lowHealth.vue index b42efc7909..76d552ceb2 100644 --- a/website/client/src/components/achievements/lowHealth.vue +++ b/website/client/src/components/achievements/lowHealth.vue @@ -59,7 +59,7 @@ import Avatar from '../avatar'; import { mapState } from '@/libs/store'; import percent from '@/../../common/script/libs/percent'; -import {MAX_HEALTH as maxHealth} from '@/../../common/script/constants'; +import { MAX_HEALTH as maxHealth } from '@/../../common/script/constants'; export default { components: { @@ -71,7 +71,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), barStyle () { return { width: `${percent(this.user.stats.hp, maxHealth)}%`, diff --git a/website/client/src/components/achievements/mindOverMatter.vue b/website/client/src/components/achievements/mindOverMatter.vue index 919fbec53c..d25f1129cf 100644 --- a/website/client/src/components/achievements/mindOverMatter.vue +++ b/website/client/src/components/achievements/mindOverMatter.vue @@ -19,28 +19,28 @@ diff --git a/website/client/src/components/achievements/newStuff.vue b/website/client/src/components/achievements/newStuff.vue index 6734457ecf..fa106a234b 100644 --- a/website/client/src/components/achievements/newStuff.vue +++ b/website/client/src/components/achievements/newStuff.vue @@ -24,37 +24,37 @@ diff --git a/website/client/src/components/achievements/questCompleted.vue b/website/client/src/components/achievements/questCompleted.vue index 1d5a40ab5c..6fb7144664 100644 --- a/website/client/src/components/achievements/questCompleted.vue +++ b/website/client/src/components/achievements/questCompleted.vue @@ -28,7 +28,7 @@ import questDialogDrops from '@/components/shops/quests/questDialogDrops'; import { mapState } from '@/libs/store'; import percent from '@/../../common/script/libs/percent'; -import {MAX_HEALTH as maxHealth} from '@/../../common/script/constants'; +import { MAX_HEALTH as maxHealth } from '@/../../common/script/constants'; export default { components: { @@ -41,7 +41,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), questData () { return this.quests.quests[this.user.party.quest.completed]; }, @@ -62,7 +62,7 @@ export default { this.close(); }, hide () { - this.$store.dispatch('user:set', {'party.quest.completed': ''}); + this.$store.dispatch('user:set', { 'party.quest.completed': '' }); }, }, }; diff --git a/website/client/src/components/achievements/questInvitation.vue b/website/client/src/components/achievements/questInvitation.vue index 9c633442d9..e6cfff0daf 100644 --- a/website/client/src/components/achievements/questInvitation.vue +++ b/website/client/src/components/achievements/questInvitation.vue @@ -48,7 +48,7 @@ import * as quests from '@/../../common/script/content/quests'; import { mapState } from '@/libs/store'; import percent from '@/../../common/script/libs/percent'; -import {MAX_HEALTH as maxHealth} from '@/../../common/script/constants'; +import { MAX_HEALTH as maxHealth } from '@/../../common/script/constants'; export default { data () { @@ -58,7 +58,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), barStyle () { return { width: `${percent(this.user.stats.hp, maxHealth)}%`, diff --git a/website/client/src/components/achievements/rebirth.vue b/website/client/src/components/achievements/rebirth.vue index edf78448fb..68612857dc 100644 --- a/website/client/src/components/achievements/rebirth.vue +++ b/website/client/src/components/achievements/rebirth.vue @@ -24,23 +24,23 @@ diff --git a/website/client/src/components/achievements/rebirthEnabled.vue b/website/client/src/components/achievements/rebirthEnabled.vue index 6f575a8936..4e69bda00e 100644 --- a/website/client/src/components/achievements/rebirthEnabled.vue +++ b/website/client/src/components/achievements/rebirthEnabled.vue @@ -21,7 +21,7 @@ import { mapState } from '@/libs/store'; export default { computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { close () { diff --git a/website/client/src/components/achievements/streak.vue b/website/client/src/components/achievements/streak.vue index 95cb2269fa..198cf3ebea 100644 --- a/website/client/src/components/achievements/streak.vue +++ b/website/client/src/components/achievements/streak.vue @@ -38,15 +38,15 @@ export default { achievementAvatar, }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { close () { this.$root.$emit('bv::hide::modal', 'streak'); }, suppressModals () { - let surpress = this.user.preferences.suppressModals.streak ? true : false; - this.$store.dispatch('user:set', {'preferences.suppressModals.streak': surpress}); + const surpress = !!this.user.preferences.suppressModals.streak; + this.$store.dispatch('user:set', { 'preferences.suppressModals.streak': surpress }); }, }, }; diff --git a/website/client/src/components/achievements/ultimateGear.vue b/website/client/src/components/achievements/ultimateGear.vue index fd1c46abb1..1d0e03576e 100644 --- a/website/client/src/components/achievements/ultimateGear.vue +++ b/website/client/src/components/achievements/ultimateGear.vue @@ -56,7 +56,7 @@ export default { achievementAvatar, }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { close () { diff --git a/website/client/src/components/achievements/wonChallenge.vue b/website/client/src/components/achievements/wonChallenge.vue index af8f7fd877..3390579edf 100644 --- a/website/client/src/components/achievements/wonChallenge.vue +++ b/website/client/src/components/achievements/wonChallenge.vue @@ -49,10 +49,10 @@ export default { markdown: markdownDirective, }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, data () { - let tweet = this.$t('wonChallengeShare'); + const tweet = this.$t('wonChallengeShare'); return { tweet, }; diff --git a/website/client/src/components/appFooter.vue b/website/client/src/components/appFooter.vue index 363d9cef69..fe5dbd0209 100644 --- a/website/client/src/components/appFooter.vue +++ b/website/client/src/components/appFooter.vue @@ -295,7 +295,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), ...mapState(['isUserLoaded']), getDataDisplayToolUrl () { const base = 'https://oldgods.net/habitrpg/habitrpg_user_data_display.html'; @@ -318,7 +318,7 @@ export default { async addMissedDay (numberOfDays) { if (!confirm(`Are you sure you want to reset the day by ${numberOfDays} day(s)?`)) return; - let date = moment(this.user.lastCron).subtract(numberOfDays, 'days').toDate(); + const date = moment(this.user.lastCron).subtract(numberOfDays, 'days').toDate(); await axios.post('/api/v4/debug/set-cron', { lastCron: date, @@ -349,18 +349,18 @@ export default { addLevelsAndGold () { this.$store.dispatch('user:set', { 'stats.exp': this.user.stats.exp + 10000, - 'stats.gp': this.user.stats.gp + 10000, - 'stats.mp': this.user.stats.mp + 10000, + 'stats.gp': this.user.stats.gp + 10000, + 'stats.mp': this.user.stats.mp + 10000, }); }, addExp () { // @TODO: Name these variables better let exp = 0; - let five = 10 * this.user.stats.lvl; - let four = Math.pow(this.user.stats.lvl, 2) * 0.25; - let three = four + five + 139.75; - let two = three / 10; - let one = Math.round(two) * 10; + const five = 10 * this.user.stats.lvl; + const four = Math.pow(this.user.stats.lvl, 2) * 0.25; + const three = four + five + 139.75; + const two = three / 10; + const one = Math.round(two) * 10; exp = this.user.stats.exp + one; this.$store.dispatch('user:set', { @@ -394,7 +394,7 @@ export default { eventAction: 'click', eventLabel: 'Gems > Donate', }); - this.$root.$emit('bv::show::modal', 'buy-gems', {alreadyTracked: true}); + this.$root.$emit('bv::show::modal', 'buy-gems', { alreadyTracked: true }); }, }, }; diff --git a/website/client/src/components/auth/authForm.vue b/website/client/src/components/auth/authForm.vue index 5184753a8f..fd9e9d8871 100644 --- a/website/client/src/components/auth/authForm.vue +++ b/website/client/src/components/auth/authForm.vue @@ -80,9 +80,9 @@ diff --git a/website/client/src/components/auth/registerLoginReset.vue b/website/client/src/components/auth/registerLoginReset.vue index b7bdfbfb80..2c241f157d 100644 --- a/website/client/src/components/auth/registerLoginReset.vue +++ b/website/client/src/components/auth/registerLoginReset.vue @@ -304,7 +304,7 @@ import googleIcon from '@/assets/svg/google.svg'; export default { data () { - let data = { + const data = { username: '', email: '', password: '', @@ -364,29 +364,22 @@ export default { return !this.passwordConfirmValid; }, }, - mounted () { - hello.init({ - facebook: process.env.FACEBOOK_KEY, // eslint-disable-line - // windows: WINDOWS_CLIENT_ID, - google: process.env.GOOGLE_CLIENT_ID, // eslint-disable-line - }); - }, watch: { $route: { handler () { if (this.resetPasswordSetNewOne) { - const query = this.$route.query; - const code = query.code; - const hasError = query.hasError === 'true' ? true : false; + const { query } = this.$route; + const { code } = query; + const hasError = query.hasError === 'true'; if (hasError) { alert(query.message); - this.$router.push({name: 'login'}); + this.$router.push({ name: 'login' }); return; } if (!code) { alert(this.$t('invalidPasswordResetCode')); - this.$router.push({name: 'login'}); + this.$router.push({ name: 'login' }); return; } @@ -400,6 +393,13 @@ export default { this.validateUsername(this.username); }, }, + mounted () { + hello.init({ + facebook: process.env.FACEBOOK_KEY, // eslint-disable-line + // windows: WINDOWS_CLIENT_ID, + google: process.env.GOOGLE_CLIENT_ID, // eslint-disable-line + }); + }, methods: { // eslint-disable-next-line func-names validateUsername: debounce(function (username) { @@ -488,7 +488,7 @@ export default { } catch (e) {} // eslint-disable-line const redirectUrl = `${window.location.protocol}//${window.location.host}`; - let auth = await hello(network).login({ + const auth = await hello(network).login({ scope: 'email', // explicitly pass the redirect url or it might redirect to /home redirect_uri: redirectUrl, // eslint-disable-line camelcase @@ -568,7 +568,7 @@ export default { this.passwordConfirm = ''; this.resetPasswordSetNewOneData.code = ''; this.resetPasswordSetNewOneData.hasError = false; - this.$router.push({name: 'login'}); + this.$router.push({ name: 'login' }); }, }, }; diff --git a/website/client/src/components/avatar.vue b/website/client/src/components/avatar.vue index 0699576841..104591935b 100644 --- a/website/client/src/components/avatar.vue +++ b/website/client/src/components/avatar.vue @@ -146,9 +146,9 @@ export default { return val; }, backgroundClass () { - let background = this.member.preferences.background; + const { background } = this.member.preferences; - let allowToShowBackground = !this.avatarOnly || this.withBackground; + const allowToShowBackground = !this.avatarOnly || this.withBackground; if (this.overrideAvatarGear && this.overrideAvatarGear.background) { return `background_${this.overrideAvatarGear.background}`; @@ -169,7 +169,7 @@ export default { }; }, skinClass () { - let baseClass = `skin_${this.member.preferences.skin}`; + const baseClass = `skin_${this.member.preferences.skin}`; return `${baseClass}${this.member.preferences.sleep ? '_sleep' : ''}`; }, @@ -196,19 +196,19 @@ export default { }, hideGear (gearType) { if (gearType === 'weapon') { - let equippedWeapon = this.member.items.gear[this.costumeClass][gearType]; + const equippedWeapon = this.member.items.gear[this.costumeClass][gearType]; if (!equippedWeapon) { return false; } - let equippedIsTwoHanded = this.flatGear[equippedWeapon].twoHanded; - let hasOverrideShield = this.overrideAvatarGear && this.overrideAvatarGear.shield; + const equippedIsTwoHanded = this.flatGear[equippedWeapon].twoHanded; + const hasOverrideShield = this.overrideAvatarGear && this.overrideAvatarGear.shield; return equippedIsTwoHanded && hasOverrideShield; - } else if (gearType === 'shield') { - let overrideWeapon = this.overrideAvatarGear && this.overrideAvatarGear.weapon; - let overrideIsTwoHanded = overrideWeapon && this.flatGear[overrideWeapon].twoHanded; + } if (gearType === 'shield') { + const overrideWeapon = this.overrideAvatarGear && this.overrideAvatarGear.weapon; + const overrideIsTwoHanded = overrideWeapon && this.flatGear[overrideWeapon].twoHanded; return overrideIsTwoHanded; } @@ -218,10 +218,9 @@ export default { this.$root.$emit('castEnd', this.member, 'user', e); }, showAvatar () { - if (!this.showVisualBuffs) - return true; + if (!this.showVisualBuffs) return true; - let buffs = this.member.stats.buffs; + const { buffs } = this.member.stats; return !buffs.snowball && !buffs.spookySparkles && !buffs.shinySeed && !buffs.seafoam; }, diff --git a/website/client/src/components/avatarModal/body-settings.vue b/website/client/src/components/avatarModal/body-settings.vue index 8071ddcf32..fcd4a35a2e 100644 --- a/website/client/src/components/avatarModal/body-settings.vue +++ b/website/client/src/components/avatarModal/body-settings.vue @@ -21,70 +21,70 @@ diff --git a/website/client/src/components/challenges/challengeMemberProgressModal.vue b/website/client/src/components/challenges/challengeMemberProgressModal.vue index afc90b4682..7c76144b56 100644 --- a/website/client/src/components/challenges/challengeMemberProgressModal.vue +++ b/website/client/src/components/challenges/challengeMemberProgressModal.vue @@ -23,10 +23,10 @@ import axios from 'axios'; import Column from '../tasks/column'; export default { - props: ['challengeId'], components: { TaskColumn: Column, }, + props: ['challengeId'], data () { return { columns: ['habit', 'daily', 'todo', 'reward'], @@ -41,18 +41,6 @@ export default { isAdmin: false, }; }, - mounted () { - this.$root.$on('habitica:challenge:member-progress', (data) => { - if (!data.progressMemberId) return; - this.memberId = data.progressMemberId; - this.isLeader = data.isLeader; - this.isAdmin = data.isAdmin; - this.$root.$emit('bv::show::modal', 'challenge-member-modal'); - }); - }, - beforeDestroy () { - this.$root.$off('habitica:challenge:member-progress'); - }, watch: { async memberId (id) { if (!id) return; @@ -63,13 +51,25 @@ export default { reward: [], }; - let response = await axios.get(`/api/v4/challenges/${this.challengeId}/members/${this.memberId}`); - let tasks = response.data.data.tasks; - tasks.forEach((task) => { + const response = await axios.get(`/api/v4/challenges/${this.challengeId}/members/${this.memberId}`); + const { tasks } = response.data.data; + tasks.forEach(task => { this.tasksByType[task.type].push(task); }); }, }, + mounted () { + this.$root.$on('habitica:challenge:member-progress', data => { + if (!data.progressMemberId) return; + this.memberId = data.progressMemberId; + this.isLeader = data.isLeader; + this.isAdmin = data.isAdmin; + this.$root.$emit('bv::show::modal', 'challenge-member-modal'); + }); + }, + beforeDestroy () { + this.$root.$off('habitica:challenge:member-progress'); + }, methods: { async closeChallenge () { this.challenge = await this.$store.dispatch('challenges:selectChallengeWinner', { diff --git a/website/client/src/components/challenges/challengeModal.vue b/website/client/src/components/challenges/challengeModal.vue index 67641106e1..c6f1bcc437 100644 --- a/website/client/src/components/challenges/challengeModal.vue +++ b/website/client/src/components/challenges/challengeModal.vue @@ -138,12 +138,12 @@ import { TAVERN_ID, MIN_SHORTNAME_SIZE_FOR_CHALLENGES, MAX_SUMMARY_SIZE_FOR_CHAL import { mapState } from '@/libs/store'; export default { - props: ['groupId'], directives: { markdown: markdownDirective, }, + props: ['groupId'], data () { - let categoryOptions = [ + const categoryOptions = [ { label: 'habitica_official', key: 'habitica_official', @@ -201,11 +201,11 @@ export default { key: 'time_management', }, ]; - let hashedCategories = {}; - categoryOptions.forEach((category) => { + const hashedCategories = {}; + categoryOptions.forEach(category => { hashedCategories[category.key] = category.label; }); - let categoriesHashByKey = hashedCategories; + const categoriesHashByKey = hashedCategories; return { workingChallenge: { @@ -233,24 +233,6 @@ export default { groups: [], }; }, - mounted () { - this.$root.$on('habitica:clone-challenge', (data) => { - if (!data.challenge) return; - this.cloning = true; - this.cloningChallengeId = data.challenge._id; - this.$store.state.challengeOptions.workingChallenge = Object.assign({}, this.$store.state.challengeOptions.workingChallenge, data.challenge); - this.$root.$emit('bv::show::modal', 'challenge-modal'); - }); - this.$root.$on('habitica:update-challenge', (data) => { - if (!data.challenge) return; - this.cloning = false; - this.$store.state.challengeOptions.workingChallenge = Object.assign({}, this.$store.state.challengeOptions.workingChallenge, data.challenge); - this.$root.$emit('bv::show::modal', 'challenge-modal'); - }); - }, - beforeDestroy () { - this.$root.$off('habitica:clone-challenge'); - }, watch: { user () { if (!this.challenge) this.workingChallenge.leader = this.user._id; @@ -262,8 +244,26 @@ export default { this.setUpWorkingChallenge(); }, }, + mounted () { + this.$root.$on('habitica:clone-challenge', data => { + if (!data.challenge) return; + this.cloning = true; + this.cloningChallengeId = data.challenge._id; + this.$store.state.challengeOptions.workingChallenge = { ...this.$store.state.challengeOptions.workingChallenge, ...data.challenge }; + this.$root.$emit('bv::show::modal', 'challenge-modal'); + }); + this.$root.$on('habitica:update-challenge', data => { + if (!data.challenge) return; + this.cloning = false; + this.$store.state.challengeOptions.workingChallenge = { ...this.$store.state.challengeOptions.workingChallenge, ...data.challenge }; + this.$root.$emit('bv::show::modal', 'challenge-modal'); + }); + }, + beforeDestroy () { + this.$root.$off('habitica:clone-challenge'); + }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), creating () { return !this.workingChallenge.id; }, @@ -274,19 +274,18 @@ export default { return this.$t('editingChallenge'); }, charactersRemaining () { - let currentLength = this.workingChallenge.summary ? this.workingChallenge.summary.length : 0; + const currentLength = this.workingChallenge.summary ? this.workingChallenge.summary.length : 0; return MAX_SUMMARY_SIZE_FOR_CHALLENGES - currentLength; }, maxPrize () { let userBalance = this.user.balance || 0; - userBalance = userBalance * 4; + userBalance *= 4; let groupBalance = 0; let group; this.groups.forEach(item => { if (item._id === this.workingChallenge.group) { group = item; - return; } }); @@ -301,14 +300,13 @@ export default { return 0; }, insufficientGemsForTavernChallenge () { - let balance = this.user.balance || 0; - let isForTavern = this.workingChallenge.group === TAVERN_ID; + const balance = this.user.balance || 0; + const isForTavern = this.workingChallenge.group === TAVERN_ID; if (isForTavern) { return balance <= 0; - } else { - return false; } + return false; }, challenge () { return this.$store.state.challengeOptions.workingChallenge; @@ -342,7 +340,7 @@ export default { if (!this.challenge) return; - this.workingChallenge = Object.assign({}, this.workingChallenge, this.challenge); + this.workingChallenge = { ...this.workingChallenge, ...this.challenge }; // @TODO: Should we use a separate field? I think the API expects `group` but it is confusing this.workingChallenge.group = this.workingChallenge.group._id; this.workingChallenge.categories = []; @@ -381,7 +379,7 @@ export default { async createChallenge () { this.loading = true; // @TODO: improve error handling, add it to updateChallenge, make errors translatable. Suggestion: `<% fieldName %> is required` where possible, where `fieldName` is inserted as the translatable string that's used for the field header. - let errors = []; + const errors = []; if (!this.workingChallenge.name) errors.push(this.$t('nameRequired')); if (this.workingChallenge.shortName.length < MIN_SHORTNAME_SIZE_FOR_CHALLENGES) errors.push(this.$t('tagTooShort')); @@ -398,17 +396,17 @@ export default { } this.workingChallenge.timestamp = new Date().getTime(); - let categoryKeys = this.workingChallenge.categories; - let serverCategories = []; + const categoryKeys = this.workingChallenge.categories; + const serverCategories = []; categoryKeys.forEach(key => { - let catName = this.categoriesHashByKey[key]; + const catName = this.categoriesHashByKey[key]; serverCategories.push({ slug: key, name: catName, }); }); - let challengeDetails = clone(this.workingChallenge); + const challengeDetails = clone(this.workingChallenge); challengeDetails.categories = serverCategories; let challenge; @@ -419,13 +417,11 @@ export default { }); this.cloningChallengeId = ''; } else { - challenge = await this.$store.dispatch('challenges:createChallenge', {challenge: challengeDetails}); + challenge = await this.$store.dispatch('challenges:createChallenge', { challenge: challengeDetails }); } // Update Group Prize - let challengeGroup = this.groups.find(group => { - return group._id === this.workingChallenge.group; - }); + const challengeGroup = this.groups.find(group => group._id === this.workingChallenge.group); // @TODO: Share with server const prizeCost = this.workingChallenge.prize / 4; @@ -435,7 +431,7 @@ export default { // Group pays for all of prize } else if (challengeGroup && userIsLeader && challengeGroup.balance > 0) { // User pays remainder of prize cost after group - let remainder = prizeCost - challengeGroup.balance; + const remainder = prizeCost - challengeGroup.balance; this.user.balance -= remainder; } else { // User pays for all of prize @@ -449,24 +445,24 @@ export default { this.$router.push(`/challenges/${challenge._id}`); }, updateChallenge () { - let categoryKeys = this.workingChallenge.categories; - let serverCategories = []; + const categoryKeys = this.workingChallenge.categories; + const serverCategories = []; categoryKeys.forEach(key => { - let newKey = key.trim(); - let catName = this.categoriesHashByKey[newKey]; + const newKey = key.trim(); + const catName = this.categoriesHashByKey[newKey]; serverCategories.push({ slug: newKey, name: catName, }); }); - let challengeDetails = clone(this.workingChallenge); + const challengeDetails = clone(this.workingChallenge); challengeDetails.categories = serverCategories; this.$emit('updatedChallenge', { challenge: challengeDetails, }); - this.$store.dispatch('challenges:updateChallenge', {challenge: challengeDetails}); + this.$store.dispatch('challenges:updateChallenge', { challenge: challengeDetails }); this.resetWorkingChallenge(); this.$root.$emit('bv::hide::modal', 'challenge-modal'); }, diff --git a/website/client/src/components/challenges/closeChallengeModal.vue b/website/client/src/components/challenges/closeChallengeModal.vue index 248034dce9..76d97a1379 100644 --- a/website/client/src/components/challenges/closeChallengeModal.vue +++ b/website/client/src/components/challenges/closeChallengeModal.vue @@ -74,10 +74,10 @@ div import memberSearchDropdown from '@/components/members/memberSearchDropdown'; export default { - props: ['challengeId', 'members', 'prize'], components: { memberSearchDropdown, }, + props: ['challengeId', 'members', 'prize'], data () { return { winner: {}, diff --git a/website/client/src/components/challenges/findChallenges.vue b/website/client/src/components/challenges/findChallenges.vue index 623c04e786..893dad43c5 100644 --- a/website/client/src/components/challenges/findChallenges.vue +++ b/website/client/src/components/challenges/findChallenges.vue @@ -66,6 +66,8 @@ diff --git a/website/client/src/components/challenges/leaveChallengeModal.vue b/website/client/src/components/challenges/leaveChallengeModal.vue index 805076d5e9..f2309c6984 100644 --- a/website/client/src/components/challenges/leaveChallengeModal.vue +++ b/website/client/src/components/challenges/leaveChallengeModal.vue @@ -19,22 +19,20 @@ import { mapState } from '@/libs/store'; import notifications from '@/mixins/notifications'; export default { - props: ['challengeId'], mixins: [notifications], + props: ['challengeId'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { async leaveChallenge (keep) { - let index = findIndex(this.user.challenges, (id) => { - return id === this.challengeId; - }); + const index = findIndex(this.user.challenges, id => id === this.challengeId); this.user.challenges.splice(index, 1); await this.$store.dispatch('challenges:leaveChallenge', { challengeId: this.challengeId, keep, }); - await this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}); + await this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true }); this.close(); }, close () { diff --git a/website/client/src/components/challenges/myChallenges.vue b/website/client/src/components/challenges/myChallenges.vue index fdd5e4b54b..ad974d3e65 100644 --- a/website/client/src/components/challenges/myChallenges.vue +++ b/website/client/src/components/challenges/myChallenges.vue @@ -80,6 +80,8 @@ diff --git a/website/client/src/components/chat/chatCard.vue b/website/client/src/components/chat/chatCard.vue index 7c3f317692..edc52ae889 100644 --- a/website/client/src/components/chat/chatCard.vue +++ b/website/client/src/components/chat/chatCard.vue @@ -140,7 +140,16 @@ import { highlightUsers } from '../../libs/highlightUsers'; import { CHAT_FLAG_LIMIT_FOR_HIDING, CHAT_FLAG_FROM_SHADOW_MUTE } from '@/../../common/script/constants'; export default { - components: {userLink}, + components: { userLink }, + filters: { + timeAgo (value) { + return moment(value).fromNow(); + }, + date (value) { + // @TODO: Vue doesn't support this so we cant user preference + return moment(value).toDate().toString(); + }, + }, props: { msg: {}, inbox: { @@ -161,20 +170,11 @@ export default { reported: false, }; }, - filters: { - timeAgo (value) { - return moment(value).fromNow(); - }, - date (value) { - // @TODO: Vue doesn't support this so we cant user preference - return moment(value).toDate().toString(); - }, - }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), isUserMentioned () { const message = this.msg; - const user = this.user; + const { user } = this; if (message.hasOwnProperty('highlight')) return message.highlight; @@ -190,7 +190,7 @@ export default { const pattern = `@(${escapedUsername}|${escapedDisplayName})(\\b)`; const precedingChar = messageText.substring(mentioned - 1, mentioned); if (mentioned === 0 || precedingChar.trim() === '' || precedingChar === '@') { - let regex = new RegExp(pattern, 'i'); + const regex = new RegExp(pattern, 'i'); message.highlight = regex.test(messageText); } @@ -201,8 +201,8 @@ export default { if (!message.likes) return 0; let likeCount = 0; - for (let key in message.likes) { - let like = message.likes[key]; + for (const key in message.likes) { + const like = message.likes[key]; if (like) likeCount += 1; } return likeCount; @@ -217,9 +217,14 @@ export default { return 'Message hidden (shadow-muted)'; }, }, + mounted () { + this.CHAT_FLAG_LIMIT_FOR_HIDING = CHAT_FLAG_LIMIT_FOR_HIDING; + this.CHAT_FLAG_FROM_SHADOW_MUTE = CHAT_FLAG_FROM_SHADOW_MUTE; + this.$emit('chat-card-mounted', this.msg.id); + }, methods: { async like () { - let message = cloneDeep(this.msg); + const message = cloneDeep(this.msg); await this.$store.dispatch('chat:like', { groupId: this.groupId, @@ -279,10 +284,5 @@ export default { return habiticaMarkdown.render(String(text)); }, }, - mounted () { - this.CHAT_FLAG_LIMIT_FOR_HIDING = CHAT_FLAG_LIMIT_FOR_HIDING; - this.CHAT_FLAG_FROM_SHADOW_MUTE = CHAT_FLAG_FROM_SHADOW_MUTE; - this.$emit('chat-card-mounted', this.msg.id); - }, }; diff --git a/website/client/src/components/chat/chatMessages.vue b/website/client/src/components/chat/chatMessages.vue index 5a9e942224..e15a930949 100644 --- a/website/client/src/components/chat/chatMessages.vue +++ b/website/client/src/components/chat/chatMessages.vue @@ -140,15 +140,20 @@ \ No newline at end of file + }, +}; + diff --git a/website/client/src/components/groups/chat.vue b/website/client/src/components/groups/chat.vue index f2e696a0a3..a515b11abc 100644 --- a/website/client/src/components/groups/chat.vue +++ b/website/client/src/components/groups/chat.vue @@ -48,190 +48,190 @@ diff --git a/website/client/src/components/groups/discovery.vue b/website/client/src/components/groups/discovery.vue index e44bfbb5b6..0d33238b7b 100644 --- a/website/client/src/components/groups/discovery.vue +++ b/website/client/src/components/groups/discovery.vue @@ -64,7 +64,7 @@ import groupUtilities from '@/mixins/groupsUtilities'; import positiveIcon from '@/assets/svg/positive.svg'; function _mapCategories (guilds) { - guilds.forEach((guild) => { + guilds.forEach(guild => { if (!guild.categories) return; guild.categorySlugs = guild.categories.map(cat => { if (!cat) return; @@ -74,8 +74,8 @@ function _mapCategories (guilds) { } export default { - mixins: [groupUtilities], components: { PublicGuildItem, MugenScroll, Sidebar }, + mixins: [groupUtilities], data () { return { icons: Object.freeze({ @@ -113,14 +113,12 @@ export default { }, computed: { filteredGuilds () { - let search = this.search; - let filters = this.filters; - let user = this.$store.state.user.data; - let filterGuild = this.filterGuild; + const { search } = this; + const { filters } = this; + const user = this.$store.state.user.data; + const { filterGuild } = this; // @TODO: Move this to the server - return this.guilds.filter((guild) => { - return filterGuild(guild, filters, search, user); - }); + return this.guilds.filter(guild => filterGuild(guild, filters, search, user)); }, }, methods: { @@ -133,7 +131,7 @@ export default { this.queryFilters.search = eventData.searchTerm; - let guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters); + const guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters); _mapCategories(guilds); this.guilds = guilds; }, @@ -157,7 +155,7 @@ export default { this.queryFilters.categories = eventData.categories.join(','); // Role filters - let filteringRole = eventData.roles && eventData.roles.length > 0; + const filteringRole = eventData.roles && eventData.roles.length > 0; if (filteringRole && eventData.roles.indexOf('member') !== -1) { this.queryFilters.member = true; } @@ -182,7 +180,7 @@ export default { this.queryFilters.maxMemberCount = 99; } - let guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters); + const guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters); _mapCategories(guilds); this.guilds = guilds; }, @@ -194,7 +192,7 @@ export default { this.loading = true; this.queryFilters.page = this.lastPageLoaded; - let guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters); + const guilds = await this.$store.dispatch('guilds:getPublicGuilds', this.queryFilters); if (guilds.length === 0) this.hasLoadedAllGuilds = true; _mapCategories(guilds); diff --git a/website/client/src/components/groups/group.vue b/website/client/src/components/groups/group.vue index 332dc532a6..d9db6f8823 100644 --- a/website/client/src/components/groups/group.vue +++ b/website/client/src/components/groups/group.vue @@ -289,8 +289,6 @@ import silverGuildBadgeIcon from '@/assets/svg/silver-guild-badge-small.svg'; import bronzeGuildBadgeIcon from '@/assets/svg/bronze-guild-badge-small.svg'; export default { - mixins: [groupUtilities, styleHelper], - props: ['groupId'], components: { membersModal, startQuestModal, @@ -307,6 +305,8 @@ export default { directives: { markdown: markdownDirective, }, + mixins: [groupUtilities, styleHelper], + props: ['groupId'], data () { return { searchId: '', @@ -333,7 +333,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), partyStore () { return this.$store.state.party; }, @@ -353,16 +353,6 @@ export default { return this.group.memberCount > this.$store.state.constants.LARGE_GROUP_COUNT_MESSAGE_CUTOFF; }, }, - mounted () { - if (this.isParty) this.searchId = 'party'; - if (!this.searchId) this.searchId = this.groupId; - this.load(); - }, - beforeRouteUpdate (to, from, next) { - this.$set(this, 'searchId', to.params.groupId); - - next(); - }, watch: { // call again the method if the route changes (when this route is already active) $route: 'fetchGuild', @@ -375,9 +365,19 @@ export default { } }, }, + mounted () { + if (this.isParty) this.searchId = 'party'; + if (!this.searchId) this.searchId = this.groupId; + this.load(); + }, + beforeRouteUpdate (to, from, next) { + this.$set(this, 'searchId', to.params.groupId); + + next(); + }, methods: { acceptCommunityGuidelines () { - this.$store.dispatch('user:set', {'flags.communityGuidelinesAccepted': true}); + this.$store.dispatch('user:set', { 'flags.communityGuidelinesAccepted': true }); }, async load () { if (this.isParty) { @@ -393,7 +393,7 @@ export default { includeAllPublicFields: true, }); this.$root.$on('updatedGroup', group => { - let updatedGroup = extend(this.group, group); + const updatedGroup = extend(this.group, group); this.$set(this.group, updatedGroup); }); }, @@ -442,7 +442,7 @@ export default { this.group = this.$store.state.party.data; this.checkForAchievements(); } else { - const group = await this.$store.dispatch('guilds:getGroup', {groupId: this.searchId}); + const group = await this.$store.dispatch('guilds:getGroup', { groupId: this.searchId }); this.$set(this, 'group', group); } @@ -450,7 +450,7 @@ export default { if (this.hasUnreadMessages(groupId)) { // Delay by 1sec to make sure it returns after other requests that don't have the notification marked as read setTimeout(() => { - this.$store.dispatch('chat:markChatSeen', {groupId}); + this.$store.dispatch('chat:markChatSeen', { groupId }); this.$delete(this.user.newMessages, groupId); }, 1000); } @@ -458,9 +458,7 @@ export default { hasUnreadMessages (groupId) { if (this.user.newMessages[groupId]) return true; - return this.user.notifications.some(n => { - return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === groupId; - }); + return this.user.notifications.some(n => n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === groupId); }, checkForAchievements () { // Checks if user's party has reached 2 players for the first time. @@ -481,7 +479,7 @@ export default { if (this.group.cancelledPlan && !confirm(this.$t('aboutToJoinCancelledGroupPlan'))) { return; } - await this.$store.dispatch('guilds:join', {groupId: this.group._id, type: 'guild'}); + await this.$store.dispatch('guilds:join', { groupId: this.group._id, type: 'guild' }); }, clickLeave () { Analytics.track({ @@ -493,13 +491,13 @@ export default { // @TODO: Get challenges and ask to keep or remove if (!confirm('Are you sure you want to leave?')) return; - let keep = true; + const keep = true; this.leave(keep); }, async leave (keepTasks) { - let keepChallenges = 'remain-in-challenges'; + const keepChallenges = 'remain-in-challenges'; - let data = { + const data = { groupId: this.group._id, keep: keepTasks, keepChallenges, @@ -507,14 +505,14 @@ export default { if (this.isParty) { data.type = 'party'; - Analytics.updateUser({partySize: null, partyID: null}); + Analytics.updateUser({ partySize: null, partyID: null }); this.$store.state.partyMembers = []; } await this.$store.dispatch('guilds:leave', data); if (this.isParty) { - this.$router.push({name: 'tasks'}); + this.$router.push({ name: 'tasks' }); } }, upgradeGroup () { diff --git a/website/client/src/components/groups/groupFormModal.vue b/website/client/src/components/groups/groupFormModal.vue index 0ed797ed66..41db557c8c 100644 --- a/website/client/src/components/groups/groupFormModal.vue +++ b/website/client/src/components/groups/groupFormModal.vue @@ -185,7 +185,7 @@ export default { markdown: markdownDirective, }, data () { - let data = { + const data = { workingGroup: { id: '', name: '', @@ -267,8 +267,8 @@ export default { membersToInvite: [], }; - let hashedCategories = {}; - data.categoryOptions.forEach((category) => { + const hashedCategories = {}; + data.categoryOptions.forEach(category => { hashedCategories[category.key] = category.label; }); data.categoriesHashByKey = hashedCategories; @@ -281,12 +281,12 @@ export default { return data; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), editingGroup () { return this.$store.state.editingGroup; }, charactersRemaining () { - let currentLength = this.workingGroup.summary ? this.workingGroup.summary.length : 0; + const currentLength = this.workingGroup.summary ? this.workingGroup.summary.length : 0; return MAX_SUMMARY_SIZE_FOR_GUILDS - currentLength; }, title () { @@ -304,7 +304,7 @@ export default { }, watch: { editingGroup () { - let editingGroup = this.editingGroup; + const { editingGroup } = this; if (!editingGroup._id) { this.resetWorkingGroup(); @@ -339,7 +339,7 @@ export default { methods: { async getMembers () { if (!this.workingGroup.id) return; - let members = await this.$store.dispatch('members:getGroupMembers', { + const members = await this.$store.dispatch('members:getGroupMembers', { groupId: this.workingGroup.id, includeAllPublicFields: true, }); @@ -367,7 +367,7 @@ export default { // @TODO return $rootScope.openModal('buyGems', {track:"Gems > Gems > Create Group"}); } - let errors = []; + const errors = []; if (!this.workingGroup.name) errors.push(this.$t('nameRequired')); if (!this.workingGroup.summary) errors.push(this.$t('summaryRequired')); @@ -391,10 +391,10 @@ export default { challenges: this.workingGroup.onlyLeaderCreatesChallenges, }; - let categoryKeys = this.workingGroup.categories; - let serverCategories = []; + const categoryKeys = this.workingGroup.categories; + const serverCategories = []; categoryKeys.forEach(key => { - let catName = this.categoriesHashByKey[key]; + const catName = this.categoriesHashByKey[key]; serverCategories.push({ slug: key, name: catName, @@ -402,16 +402,16 @@ export default { }); this.workingGroup.categories = serverCategories; - let groupData = Object.assign({}, this.workingGroup); + const groupData = { ...this.workingGroup }; let newgroup; if (groupData.id) { - await this.$store.dispatch('guilds:update', {group: groupData}); + await this.$store.dispatch('guilds:update', { group: groupData }); this.$root.$emit('updatedGroup', this.workingGroup); // @TODO: this doesn't work because of the async resource // if (updatedGroup.type === 'party') this.$store.state.party = {data: updatedGroup}; } else { - newgroup = await this.$store.dispatch('guilds:create', {group: groupData}); + newgroup = await this.$store.dispatch('guilds:create', { group: groupData }); this.$store.state.user.data.balance -= 1; } diff --git a/website/client/src/components/groups/groupPlan.vue b/website/client/src/components/groups/groupPlan.vue index c1b0447971..95f5978188 100644 --- a/website/client/src/components/groups/groupPlan.vue +++ b/website/client/src/components/groups/groupPlan.vue @@ -49,7 +49,7 @@ div .box.payment-providers h3 Choose your payment method .payments-column - button.purchase.btn.btn-primary.payment-button.payment-item(@click='pay(PAYMENTS.STRIPE)') + button.purchase.btn.btn-primary.payment-button.payment-item(@click='pay(PAYMENTS.STRIPE)') .svg-icon.credit-card-icon(v-html="icons.creditCardIcon") | {{ $t('card') }} amazon-button.payment-item(:amazon-data="pay(PAYMENTS.AMAZON)") @@ -99,7 +99,7 @@ div .text-center h3 Choose your payment method .payments-column.mx-auto - button.purchase.btn.btn-primary.payment-button.payment-item(@click='pay(PAYMENTS.STRIPE)') + button.purchase.btn.btn-primary.payment-button.payment-item(@click='pay(PAYMENTS.STRIPE)') .svg-icon.credit-card-icon(v-html="icons.creditCardIcon") | {{ $t('card') }} amazon-button.payment-item(:amazon-data="pay(PAYMENTS.AMAZON)") @@ -297,10 +297,10 @@ import creditCardIcon from '@/assets/svg/credit-card-icon.svg'; import amazonButton from '@/components/payments/amazonButton'; export default { - mixins: [paymentsMixin], components: { amazonButton, }, + mixins: [paymentsMixin], data () { return { amazonPayments: {}, @@ -341,7 +341,7 @@ export default { return this.$store.state.upgradingGroup; }, // @TODO: can we move this to payment mixin? - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { launchModal () { diff --git a/website/client/src/components/groups/inviteModal.vue b/website/client/src/components/groups/inviteModal.vue index 30e43079ec..ac9926309e 100644 --- a/website/client/src/components/groups/inviteModal.vue +++ b/website/client/src/components/groups/inviteModal.vue @@ -90,111 +90,103 @@ diff --git a/website/client/src/components/groups/membersModal.vue b/website/client/src/components/groups/membersModal.vue index 73e10b0640..377395b0a3 100644 --- a/website/client/src/components/groups/membersModal.vue +++ b/website/client/src/components/groups/membersModal.vue @@ -214,11 +214,11 @@ import starIcon from '@/assets/members/star.svg'; import dots from '@/assets/svg/dots.svg'; export default { - props: ['hideBadge'], components: { MemberDetails, removeMemberModal, }, + props: ['hideBadge'], data () { return { sortOption: {}, @@ -278,7 +278,7 @@ export default { }; }, mounted () { - this.$root.$on('habitica:show-member-modal', (data) => { + this.$root.$on('habitica:show-member-modal', data => { // @TODO: Remove store this.$store.state.memberModalOptions.challengeId = data.challengeId; this.$store.state.memberModalOptions.groupId = data.groupId; @@ -294,7 +294,7 @@ export default { this.$root.$off('habitica:show-member-modal'); }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), isLeader () { if (!this.group || !this.group.leader) return false; return this.user._id === this.group.leader || this.user._id === this.group.leader._id; @@ -370,10 +370,10 @@ export default { }); }, async getMembers () { - let groupId = this.groupId; + const { groupId } = this; if (groupId && groupId !== 'challenge') { - let invites = await this.$store.dispatch('members:getGroupInvites', { + const invites = await this.$store.dispatch('members:getGroupInvites', { groupId, includeAllPublicFields: true, }); @@ -383,7 +383,7 @@ export default { this.members = this.$store.state.memberModalOptions.viewingMembers; }, async clickMember (uid, forceShow) { - let user = this.$store.state.user.data; + const user = this.$store.state.user.data; if (user._id === uid && !forceShow) { if (this.$route.name === 'tasks') { @@ -409,7 +409,7 @@ export default { memberRemoved () { this.members.splice(this.memberToRemove.index, 1); this.group.memberCount -= 1; - this.memberToRemove = {}; + this.memberToRemove = {}; }, async quickReply (uid) { this.memberToReply = uid; @@ -459,7 +459,7 @@ export default { const lastMember = this.members[this.members.length - 1]; if (!lastMember) return; - let newMembers = await this.$store.state.memberModalOptions.fetchMoreMembers({ + const newMembers = await this.$store.state.memberModalOptions.fetchMoreMembers({ challengeId: this.challengeId, groupId: this.groupId, lastMemberId: lastMember._id, @@ -483,10 +483,10 @@ export default { this.viewMembers(); }, async promoteToLeader (member) { - let groupData = Object.assign({}, this.group); + const groupData = { ...this.group }; groupData.leader = member._id; - await this.$store.dispatch('guilds:update', {group: groupData}); + await this.$store.dispatch('guilds:update', { group: groupData }); alert(this.$t('leaderChanged')); diff --git a/website/client/src/components/groups/myGuilds.vue b/website/client/src/components/groups/myGuilds.vue index dbe5eda3c0..83c3d6e983 100644 --- a/website/client/src/components/groups/myGuilds.vue +++ b/website/client/src/components/groups/myGuilds.vue @@ -61,10 +61,10 @@ \ No newline at end of file + diff --git a/website/client/src/components/groups/publicGuildItem.vue b/website/client/src/components/groups/publicGuildItem.vue index c732f63ecf..f6f3a2d53d 100644 --- a/website/client/src/components/groups/publicGuildItem.vue +++ b/website/client/src/components/groups/publicGuildItem.vue @@ -144,16 +144,16 @@ import bronzeGuildBadgeIcon from '@/assets/svg/bronze-guild-badge-large.svg'; import { MAX_SUMMARY_SIZE_FOR_GUILDS } from '@/../../common/script/constants'; export default { - mixins: [groupUtilities], directives: { markdown, }, - props: ['guild', 'displayLeave', 'displayGemBank'], components: { categoryTags, }, + mixins: [groupUtilities], + props: ['guild', 'displayLeave', 'displayGemBank'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), isOwner () { return this.guild.leader && this.guild.leader === this.user._id; }, @@ -174,9 +174,9 @@ export default { }, methods: { showSuggested (guildId) { - let habiticaHelpingGuildId = '5481ccf3-5d2d-48a9-a871-70a7380cee5a'; - let sixtyDaysAgoFromNow = moment().subtract(60, 'days'); - let isUserNew = moment(this.user.auth.timestamps.created).isAfter(sixtyDaysAgoFromNow); + const habiticaHelpingGuildId = '5481ccf3-5d2d-48a9-a871-70a7380cee5a'; + const sixtyDaysAgoFromNow = moment().subtract(60, 'days'); + const isUserNew = moment(this.user.auth.timestamps.created).isAfter(sixtyDaysAgoFromNow); return guildId === habiticaHelpingGuildId && isUserNew; }, async join () { @@ -184,11 +184,11 @@ export default { if (this.guild.cancelledPlan && !confirm(window.env.t('aboutToJoinCancelledGroupPlan'))) { return; } - await this.$store.dispatch('guilds:join', {groupId: this.guild._id, type: 'guild'}); + await this.$store.dispatch('guilds:join', { groupId: this.guild._id, type: 'guild' }); }, async leave () { // @TODO: ask about challenges when we add challenges - await this.$store.dispatch('guilds:leave', {groupId: this.guild._id, type: 'myGuilds'}); + await this.$store.dispatch('guilds:leave', { groupId: this.guild._id, type: 'myGuilds' }); }, }, }; diff --git a/website/client/src/components/groups/questDetailsModal.vue b/website/client/src/components/groups/questDetailsModal.vue index bc85d5a9d5..e442548f1e 100644 --- a/website/client/src/components/groups/questDetailsModal.vue +++ b/website/client/src/components/groups/questDetailsModal.vue @@ -149,11 +149,11 @@ import questDialogDrops from '../shops/quests/questDialogDrops'; import questDialogContent from '../shops/quests/questDialogContent'; export default { - props: ['group'], components: { questDialogDrops, questDialogContent, }, + props: ['group'], data () { return { loading: false, @@ -181,38 +181,36 @@ export default { return quests.quests[this.group.quest.key]; }, members () { - let partyMembers = this.partyMembers || []; - return partyMembers.map(member => { - return { - name: member.profile.name, - accepted: this.group.quest.members[member._id], - }; - }); + const partyMembers = this.partyMembers || []; + return partyMembers.map(member => ({ + name: member.profile.name, + accepted: this.group.quest.members[member._id], + })); }, canEditQuest () { if (!this.group.quest) return false; - let isQuestLeader = this.group.quest.leader === this.user._id; - let isPartyLeader = this.group.leader._id === this.user._id; + const isQuestLeader = this.group.quest.leader === this.user._id; + const isPartyLeader = this.group.leader._id === this.user._id; return isQuestLeader || isPartyLeader; }, }, methods: { async questConfirm () { let count = 0; - for (let uuid in this.group.quest.members) { + for (const uuid in this.group.quest.members) { if (this.group.quest.members[uuid]) count += 1; } - if (!confirm(this.$t('questConfirm', { questmembers: count, totalmembers: this.group.memberCount}))) return; + if (!confirm(this.$t('questConfirm', { questmembers: count, totalmembers: this.group.memberCount }))) return; this.questForceStart(); }, async questForceStart () { - let quest = await this.$store.dispatch('quests:sendAction', {groupId: this.group._id, action: 'quests/force-start'}); + const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/force-start' }); this.group.quest = quest; this.close(); }, async questCancel () { if (!confirm(this.$t('sureCancel'))) return; - let quest = await this.$store.dispatch('quests:sendAction', {groupId: this.group._id, action: 'quests/cancel'}); + const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/cancel' }); this.group.quest = quest; this.close(); }, diff --git a/website/client/src/components/groups/questSidebarSection.vue b/website/client/src/components/groups/questSidebarSection.vue index 11351e2267..fe6868cebf 100644 --- a/website/client/src/components/groups/questSidebarSection.vue +++ b/website/client/src/components/groups/questSidebarSection.vue @@ -198,10 +198,10 @@ import sidebarSection from '../sidebarSection'; import questIcon from '@/assets/svg/quest.svg'; export default { - props: ['group'], components: { sidebarSection, }, + props: ['group'], data () { return { icons: Object.freeze({ @@ -210,7 +210,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), userIsOnQuest () { if (!this.group.quest || !this.group.quest.members) return false; return Boolean(this.group.quest.members[this.user._id]); @@ -230,20 +230,20 @@ export default { }, canEditQuest () { if (!this.group.quest) return false; - let isQuestLeader = this.group.quest.leader === this.user._id; - let isPartyLeader = this.group.leader._id === this.user._id; + const isQuestLeader = this.group.quest.leader === this.user._id; + const isPartyLeader = this.group.leader._id === this.user._id; return isQuestLeader || isPartyLeader; }, isMemberOfPendingQuest () { - let userid = this.user._id; - let group = this.group; + const userid = this.user._id; + const { group } = this; if (!group.quest || !group.quest.members) return false; if (group.quest.active) return false; // quest is started, not pending return userid in group.quest.members && group.quest.members[userid] !== false; }, isMemberOfRunningQuest () { - let userid = this.user._id; - let group = this.group; + const userid = this.user._id; + const { group } = this; if (!group.quest || !group.quest.members) return false; if (!group.quest.active) return false; // quest is pending, not started return group.quest.members[userid]; @@ -253,7 +253,7 @@ export default { if (!this.group || !this.group.quest) return count; - for (let uuid in this.group.quest.members) { + for (const uuid in this.group.quest.members) { if (this.group.quest.members[uuid]) count += 1; } @@ -273,20 +273,20 @@ export default { async questAbort () { if (!confirm(this.$t('sureAbort'))) return; if (!confirm(this.$t('doubleSureAbort'))) return; - let quest = await this.$store.dispatch('quests:sendAction', {groupId: this.group._id, action: 'quests/abort'}); + const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/abort' }); this.group.quest = quest; }, async questLeave () { if (!confirm(this.$t('sureLeave'))) return; - let quest = await this.$store.dispatch('quests:sendAction', {groupId: this.group._id, action: 'quests/leave'}); + const quest = await this.$store.dispatch('quests:sendAction', { groupId: this.group._id, action: 'quests/leave' }); this.group.quest = quest; }, async questAccept (partyId) { - let quest = await this.$store.dispatch('quests:sendAction', {groupId: partyId, action: 'quests/accept'}); + const quest = await this.$store.dispatch('quests:sendAction', { groupId: partyId, action: 'quests/accept' }); this.user.party.quest = quest; }, async questReject (partyId) { - let quest = await this.$store.dispatch('quests:sendAction', {groupId: partyId, action: 'quests/reject'}); + const quest = await this.$store.dispatch('quests:sendAction', { groupId: partyId, action: 'quests/reject' }); this.user.party.quest = quest; }, }, diff --git a/website/client/src/components/groups/startQuestModal.vue b/website/client/src/components/groups/startQuestModal.vue index a119708d3a..c310dd4e86 100644 --- a/website/client/src/components/groups/startQuestModal.vue +++ b/website/client/src/components/groups/startQuestModal.vue @@ -123,12 +123,12 @@ import questDialogContent from '../shops/quests/questDialogContent'; import QuestInfo from '../shops/quests/questInfo'; export default { - props: ['group'], components: { questDialogDrops, questDialogContent, QuestInfo, }, + props: ['group'], data () { return { loading: false, @@ -162,7 +162,7 @@ export default { this.$root.$off('selectQuest', this.selectQuest); }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), questData () { return quests.quests[this.selectedQuest]; }, @@ -179,11 +179,11 @@ export default { partySize: this.group.memberCount, }); - let groupId = this.group._id || this.user.party._id; + const groupId = this.group._id || this.user.party._id; const key = this.selectedQuest; try { - const response = await this.$store.dispatch('guilds:inviteToQuest', {groupId, key}); + const response = await this.$store.dispatch('guilds:inviteToQuest', { groupId, key }); const quest = response.data.data; if (this.$store.state.party.data) this.$store.state.party.data.quest = quest; diff --git a/website/client/src/components/groups/tavern.vue b/website/client/src/components/groups/tavern.vue index 107033079e..b2c2aae514 100644 --- a/website/client/src/components/groups/tavern.vue +++ b/website/client/src/components/groups/tavern.vue @@ -501,14 +501,14 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), questData () { if (!this.group.quest) return {}; return quests.quests[this.group.quest.key]; }, }, async mounted () { - this.group = await this.$store.dispatch('guilds:getGroup', {groupId: TAVERN_ID}); + this.group = await this.$store.dispatch('guilds:getGroup', { groupId: TAVERN_ID }); }, methods: { modForm () { @@ -543,7 +543,7 @@ export default { } }, async fetchRecentMessages () { - this.group = await this.$store.dispatch('guilds:getGroup', {groupId: TAVERN_ID}); + this.group = await this.$store.dispatch('guilds:getGroup', { groupId: TAVERN_ID }); }, }, }; diff --git a/website/client/src/components/hall/heroes.vue b/website/client/src/components/hall/heroes.vue index b6a1d7faef..6b24194483 100644 --- a/website/client/src/components/hall/heroes.vue +++ b/website/client/src/components/hall/heroes.vue @@ -119,10 +119,13 @@ import notifications from '@/mixins/notifications'; import userLink from '../userLink'; export default { - mixins: [notifications, styleHelper], components: { userLink, }, + directives: { + markdown: markdownDirective, + }, + mixins: [notifications, styleHelper], data () { return { heroes: [], @@ -141,14 +144,11 @@ export default { expandAuth: false, }; }, - directives: { - markdown: markdownDirective, - }, async mounted () { this.heroes = await this.$store.dispatch('hall:getHeroes'); }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { getAllItemPaths () { @@ -172,7 +172,7 @@ export default { getFormattedItemReference (pathPrefix, itemKeys, values) { let finishedString = '\n'.concat('path: ', pathPrefix, ', ', 'value: {', values, '}\n'); - each(itemKeys, (key) => { + each(itemKeys, key => { finishedString = finishedString.concat('\t', pathPrefix, '.', key, '\n'); }); @@ -180,8 +180,8 @@ export default { }, async loadHero (uuid, heroIndex) { this.currentHeroIndex = heroIndex; - let hero = await this.$store.dispatch('hall:getHero', { uuid }); - this.hero = Object.assign({}, hero); + const hero = await this.$store.dispatch('hall:getHero', { uuid }); + this.hero = { ...hero }; if (!this.hero.flags) { this.hero.flags = { chatRevoked: false, @@ -192,8 +192,8 @@ export default { this.expandAuth = false; }, async saveHero () { - this.hero.contributor.admin = this.hero.contributor.level > 7 ? true : false; - let heroUpdated = await this.$store.dispatch('hall:updateHero', { heroDetails: this.hero }); + this.hero.contributor.admin = this.hero.contributor.level > 7; + const heroUpdated = await this.$store.dispatch('hall:updateHero', { heroDetails: this.hero }); this.text('User updated'); this.hero = {}; this.heroID = -1; diff --git a/website/client/src/components/hall/patrons.vue b/website/client/src/components/hall/patrons.vue index 2a6a954802..ec090b9077 100644 --- a/website/client/src/components/hall/patrons.vue +++ b/website/client/src/components/hall/patrons.vue @@ -32,7 +32,7 @@ export default { this.patrons = await this.$store.dispatch('hall:getPatrons', { page: 0 }); }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { // @TODO: Import member modal - clickMember() diff --git a/website/client/src/components/header/index.vue b/website/client/src/components/header/index.vue index 9c709773c4..3104b679ff 100644 --- a/website/client/src/components/header/index.vue +++ b/website/client/src/components/header/index.vue @@ -178,7 +178,7 @@ export default { } }, mounted () { - this.$root.$on('inviteModal::inviteToGroup', (group) => { + this.$root.$on('inviteModal::inviteToGroup', group => { this.inviteModalGroup = group; this.inviteModalGroupType = group.type === 'guild' ? 'Guild' : 'Party'; this.$root.$emit('bv::show::modal', 'invite-modal'); diff --git a/website/client/src/components/header/menu.vue b/website/client/src/components/header/menu.vue index fc3c18f04a..d8f3064028 100644 --- a/website/client/src/components/header/menu.vue +++ b/website/client/src/components/header/menu.vue @@ -488,7 +488,7 @@ export default { eventLabel: 'Gems > Toolbar', }); - this.$root.$emit('bv::show::modal', 'buy-gems', {alreadyTracked: true}); + this.$root.$emit('bv::show::modal', 'buy-gems', { alreadyTracked: true }); }, dropdownDesktop (hover) { if (this.isDesktop() && hover.target.classList.contains('droppable')) { @@ -499,7 +499,7 @@ export default { this.dropdown(click.currentTarget.parentElement); }, dropdown (element) { - let droppedElement = document.getElementsByClassName('down')[0]; + const droppedElement = document.getElementsByClassName('down')[0]; if (droppedElement && droppedElement !== element) { droppedElement.classList.remove('down'); if (droppedElement.lastChild) { diff --git a/website/client/src/components/header/messageCount.vue b/website/client/src/components/header/messageCount.vue index 93c307eecb..b8673b0524 100644 --- a/website/client/src/components/header/messageCount.vue +++ b/website/client/src/components/header/messageCount.vue @@ -30,4 +30,4 @@ span.message-count( .message-count.top-count-gray { background-color: $gray-200; } - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/base.vue b/website/client/src/components/header/notifications/base.vue index 30305f0953..7a5bbec0cd 100644 --- a/website/client/src/components/header/notifications/base.vue +++ b/website/client/src/components/header/notifications/base.vue @@ -11,7 +11,7 @@ slot(name="content") .notification-remove(@click.stop="canRemove ? remove() : null",) .svg-icon( - v-if="canRemove", + v-if="canRemove", v-html="icons.close", ) @@ -130,7 +130,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), isNotBailey () { return this.notification.type !== 'NEW_STUFF'; }, @@ -141,7 +141,7 @@ export default { }), clicked () { if (this.readAfterClick === true) { - this.readNotification({notificationId: this.notification.id}); + this.readNotification({ notificationId: this.notification.id }); } this.$emit('click'); @@ -149,14 +149,14 @@ export default { remove () { if (this.notification.type === 'NEW_CHAT_MESSAGE') { const groupId = this.notification.data.group.id; - this.$store.dispatch('chat:markChatSeen', {groupId}); + this.$store.dispatch('chat:markChatSeen', { groupId }); if (this.user.newMessages[groupId]) { this.$delete(this.user.newMessages, groupId); } } else { - this.readNotification({notificationId: this.notification.id}); + this.readNotification({ notificationId: this.notification.id }); } }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/cardReceived.vue b/website/client/src/components/header/notifications/cardReceived.vue index 0762f6e09a..f7c2351cdf 100644 --- a/website/client/src/components/header/notifications/cardReceived.vue +++ b/website/client/src/components/header/notifications/cardReceived.vue @@ -14,10 +14,10 @@ base-notification( import BaseNotification from './base'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], computed: { cardString () { return this.$t(`${this.notification.data.card}Card`); @@ -28,8 +28,8 @@ export default { }, methods: { action () { - this.$router.push({name: 'items'}); + this.$router.push({ name: 'items' }); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/challengeInvitation.vue b/website/client/src/components/header/notifications/challengeInvitation.vue index 97083da552..852a0425c5 100644 --- a/website/client/src/components/header/notifications/challengeInvitation.vue +++ b/website/client/src/components/header/notifications/challengeInvitation.vue @@ -1,3 +1,3 @@ \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/groupTaskApproval.vue b/website/client/src/components/header/notifications/groupTaskApproval.vue index cbc5295c98..2b378c410b 100644 --- a/website/client/src/components/header/notifications/groupTaskApproval.vue +++ b/website/client/src/components/header/notifications/groupTaskApproval.vue @@ -18,13 +18,13 @@ import { mapState } from '@/libs/store'; import sync from '@/mixins/sync'; export default { - mixins: [sync], - props: ['notification', 'canRemove'], components: { BaseNotification, }, + mixins: [sync], + props: ['notification', 'canRemove'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), // Check that the notification has all the necessary data (old ones are missing some fields) notificationHasData () { return Boolean(this.notification.data.groupTaskId && this.notification.data.userId); @@ -33,14 +33,17 @@ export default { methods: { action () { const groupId = this.notification.data.group.id; - this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId }}); + this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId } }); }, async approve () { // Redirect users to the group tasks page if the notification doesn't have data if (!this.notificationHasData) { - this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { - groupId: this.notification.data.groupId, - }}); + this.$router.push({ + name: 'groupPlanDetailTaskInformation', + params: { + groupId: this.notification.data.groupId, + }, + }); return; } @@ -55,9 +58,12 @@ export default { async needsWork () { // Redirect users to the group tasks page if the notification doesn't have data if (!this.notificationHasData) { - this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { - groupId: this.notification.data.groupId, - }}); + this.$router.push({ + name: 'groupPlanDetailTaskInformation', + params: { + groupId: this.notification.data.groupId, + }, + }); return; } diff --git a/website/client/src/components/header/notifications/groupTaskApproved.vue b/website/client/src/components/header/notifications/groupTaskApproved.vue index 35982f3ef9..bbd6000e36 100644 --- a/website/client/src/components/header/notifications/groupTaskApproved.vue +++ b/website/client/src/components/header/notifications/groupTaskApproved.vue @@ -13,15 +13,15 @@ base-notification( import BaseNotification from './base'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], methods: { action () { - const groupId = this.notification.data.groupId; - this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId }}); + const { groupId } = this.notification.data; + this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId } }); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/groupTaskAssigned.vue b/website/client/src/components/header/notifications/groupTaskAssigned.vue index 5916ba27a6..7d1fc32bad 100644 --- a/website/client/src/components/header/notifications/groupTaskAssigned.vue +++ b/website/client/src/components/header/notifications/groupTaskAssigned.vue @@ -10,17 +10,17 @@ diff --git a/website/client/src/components/header/notifications/groupTaskClaimed.vue b/website/client/src/components/header/notifications/groupTaskClaimed.vue index 508177dbb2..e3768668d6 100644 --- a/website/client/src/components/header/notifications/groupTaskClaimed.vue +++ b/website/client/src/components/header/notifications/groupTaskClaimed.vue @@ -13,14 +13,14 @@ base-notification( import BaseNotification from './base'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], methods: { action () { - const groupId = this.notification.data.groupId; - this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId }}); + const { groupId } = this.notification.data; + this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId } }); }, }, }; diff --git a/website/client/src/components/header/notifications/groupTaskNeedsWork.vue b/website/client/src/components/header/notifications/groupTaskNeedsWork.vue index 068e479f72..45175bead8 100644 --- a/website/client/src/components/header/notifications/groupTaskNeedsWork.vue +++ b/website/client/src/components/header/notifications/groupTaskNeedsWork.vue @@ -13,15 +13,15 @@ base-notification( import BaseNotification from './base'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], methods: { action () { const groupId = this.notification.data.group.id; - this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId }}); + this.$router.push({ name: 'groupPlanDetailTaskInformation', params: { groupId } }); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/guildInvitation.vue b/website/client/src/components/header/notifications/guildInvitation.vue index c140e7de86..1ac067d926 100644 --- a/website/client/src/components/header/notifications/guildInvitation.vue +++ b/website/client/src/components/header/notifications/guildInvitation.vue @@ -17,12 +17,12 @@ import BaseNotification from './base'; import { mapState } from '@/libs/store'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), isPublicGuild () { if (this.notification.data.publicGuild === true) return true; return false; @@ -31,10 +31,9 @@ export default { const guild = this.notification.data.name; if (this.isPublicGuild) { - return this.$t('invitedToPublicGuild', {guild}); - } else { - return this.$t('invitedToPrivateGuild', {guild}); + return this.$t('invitedToPublicGuild', { guild }); } + return this.$t('invitedToPrivateGuild', { guild }); }, }, methods: { @@ -52,11 +51,11 @@ export default { return; } - await this.$store.dispatch('guilds:join', {groupId: group.id, type: 'guild'}); + await this.$store.dispatch('guilds:join', { groupId: group.id, type: 'guild' }); this.$router.push({ name: 'guild', params: { groupId: group.id } }); }, reject () { - this.$store.dispatch('guilds:rejectInvite', {groupId: this.notification.data.id, type: 'guild'}); + this.$store.dispatch('guilds:rejectInvite', { groupId: this.notification.data.id, type: 'guild' }); }, }, diff --git a/website/client/src/components/header/notifications/justAddWater.vue b/website/client/src/components/header/notifications/justAddWater.vue index 9889b28cc4..81a2b0e3d5 100644 --- a/website/client/src/components/header/notifications/justAddWater.vue +++ b/website/client/src/components/header/notifications/justAddWater.vue @@ -9,22 +9,22 @@ diff --git a/website/client/src/components/header/notifications/lostMasterclasser.vue b/website/client/src/components/header/notifications/lostMasterclasser.vue index c72aa02d3e..9c76589cfb 100644 --- a/website/client/src/components/header/notifications/lostMasterclasser.vue +++ b/website/client/src/components/header/notifications/lostMasterclasser.vue @@ -9,22 +9,22 @@ diff --git a/website/client/src/components/header/notifications/mindOverMatter.vue b/website/client/src/components/header/notifications/mindOverMatter.vue index 9044a25a91..a294475b36 100644 --- a/website/client/src/components/header/notifications/mindOverMatter.vue +++ b/website/client/src/components/header/notifications/mindOverMatter.vue @@ -9,22 +9,22 @@ diff --git a/website/client/src/components/header/notifications/newChatMessage.vue b/website/client/src/components/header/notifications/newChatMessage.vue index 3d55485d33..558033fa01 100644 --- a/website/client/src/components/header/notifications/newChatMessage.vue +++ b/website/client/src/components/header/notifications/newChatMessage.vue @@ -15,12 +15,12 @@ import BaseNotification from './base'; import { mapState } from '@/libs/store'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), groupId () { return this.notification.data.group.id; }, @@ -29,7 +29,7 @@ export default { }, string () { const stringKey = this.isParty ? 'newMsgParty' : 'newMsgGuild'; - return this.$t(stringKey, {name: this.notification.data.group.name}); + return this.$t(stringKey, { name: this.notification.data.group.name }); }, }, methods: { @@ -39,8 +39,8 @@ export default { return; } - this.$router.push({ name: 'guild', params: { groupId: this.groupId }}); + this.$router.push({ name: 'guild', params: { groupId: this.groupId } }); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/newInboxMessage.vue b/website/client/src/components/header/notifications/newInboxMessage.vue index 05f76b2f15..3ee3ec4f3b 100644 --- a/website/client/src/components/header/notifications/newInboxMessage.vue +++ b/website/client/src/components/header/notifications/newInboxMessage.vue @@ -15,14 +15,14 @@ base-notification( import BaseNotification from './base'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], methods: { action () { this.$root.$emit('bv::show::modal', 'inbox-modal'); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/newMysteryItems.vue b/website/client/src/components/header/notifications/newMysteryItems.vue index 763b848b11..1202daaca6 100644 --- a/website/client/src/components/header/notifications/newMysteryItems.vue +++ b/website/client/src/components/header/notifications/newMysteryItems.vue @@ -11,14 +11,14 @@ base-notification( \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/newStuff.vue b/website/client/src/components/header/notifications/newStuff.vue index a479748413..bc919fb5d0 100644 --- a/website/client/src/components/header/notifications/newStuff.vue +++ b/website/client/src/components/header/notifications/newStuff.vue @@ -16,14 +16,14 @@ base-notification( import BaseNotification from './base'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], methods: { action () { this.$root.$emit('bv::show::modal', 'new-stuff'); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/partyInvitation.vue b/website/client/src/components/header/notifications/partyInvitation.vue index 1d3e93490f..8cbaf45e78 100644 --- a/website/client/src/components/header/notifications/partyInvitation.vue +++ b/website/client/src/components/header/notifications/partyInvitation.vue @@ -16,12 +16,12 @@ import BaseNotification from './base'; import { mapState } from '@/libs/store'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, }, + props: ['notification', 'canRemove'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, methods: { async accept () { @@ -31,12 +31,12 @@ export default { return; } - await this.$store.dispatch('guilds:join', {groupId: group.id, type: 'party'}); + await this.$store.dispatch('guilds:join', { groupId: group.id, type: 'party' }); this.$router.push('/party'); }, reject () { - this.$store.dispatch('guilds:rejectInvite', {groupId: this.notification.data.id, type: 'party'}); + this.$store.dispatch('guilds:rejectInvite', { groupId: this.notification.data.id, type: 'party' }); }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/header/notifications/questInvitation.vue b/website/client/src/components/header/notifications/questInvitation.vue index 16f036e591..bc67a538e7 100644 --- a/website/client/src/components/header/notifications/questInvitation.vue +++ b/website/client/src/components/header/notifications/questInvitation.vue @@ -26,13 +26,13 @@ import * as quests from '@/../../common/script/content/quests'; import questInfo from '@/components/shops/quests/questInfo'; export default { - props: ['notification', 'canRemove'], components: { BaseNotification, questInfo, }, + props: ['notification', 'canRemove'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), questData () { return quests.quests[this.notification.data.quest]; }, diff --git a/website/client/src/components/header/notifications/unallocatedStatsPoints.vue b/website/client/src/components/header/notifications/unallocatedStatsPoints.vue index 455f1d4e81..203c4727d4 100644 --- a/website/client/src/components/header/notifications/unallocatedStatsPoints.vue +++ b/website/client/src/components/header/notifications/unallocatedStatsPoints.vue @@ -22,6 +22,9 @@ import BaseNotification from './base'; import sparklesIcon from '@/assets/svg/sparkles.svg'; export default { + components: { + BaseNotification, + }, props: ['notification', 'canRemove'], data () { return { @@ -30,12 +33,9 @@ export default { }), }; }, - components: { - BaseNotification, - }, methods: { action () { - this.$router.push({name: 'stats'}); + this.$router.push({ name: 'stats' }); }, }, }; diff --git a/website/client/src/components/header/notifications/verifyUsername.vue b/website/client/src/components/header/notifications/verifyUsername.vue index e127250ada..aec3a35e80 100644 --- a/website/client/src/components/header/notifications/verifyUsername.vue +++ b/website/client/src/components/header/notifications/verifyUsername.vue @@ -46,29 +46,29 @@ diff --git a/website/client/src/components/header/notifications/worldBoss.vue b/website/client/src/components/header/notifications/worldBoss.vue index eb33bcc0ec..11f96612e4 100644 --- a/website/client/src/components/header/notifications/worldBoss.vue +++ b/website/client/src/components/header/notifications/worldBoss.vue @@ -163,7 +163,7 @@ export default { this.worldBoss = result.worldBoss; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), bossHp () { if (this.worldBoss && this.worldBoss.progress) { return this.worldBoss.progress.hp; @@ -173,7 +173,7 @@ export default { }, methods: { action () { - this.$router.push({name: 'tavern'}); + this.$router.push({ name: 'tavern' }); }, }, }; diff --git a/website/client/src/components/header/notificationsDropdown.vue b/website/client/src/components/header/notificationsDropdown.vue index bc338aa559..74d410fe78 100644 --- a/website/client/src/components/header/notificationsDropdown.vue +++ b/website/client/src/components/header/notificationsDropdown.vue @@ -105,12 +105,24 @@ export default { MenuDropdown, MessageCount, // One component for each type - NEW_STUFF, GROUP_TASK_NEEDS_WORK, - GUILD_INVITATION, PARTY_INVITATION, CHALLENGE_INVITATION, - QUEST_INVITATION, GROUP_TASK_APPROVAL, GROUP_TASK_APPROVED, GROUP_TASK_ASSIGNED, GROUP_TASK_CLAIMED, - UNALLOCATED_STATS_POINTS, NEW_MYSTERY_ITEMS, CARD_RECEIVED, - NEW_INBOX_MESSAGE, NEW_CHAT_MESSAGE, - ACHIEVEMENT_JUST_ADD_WATER, ACHIEVEMENT_LOST_MASTERCLASSER, ACHIEVEMENT_MIND_OVER_MATTER, + NEW_STUFF, + GROUP_TASK_NEEDS_WORK, + GUILD_INVITATION, + PARTY_INVITATION, + CHALLENGE_INVITATION, + QUEST_INVITATION, + GROUP_TASK_APPROVAL, + GROUP_TASK_APPROVED, + GROUP_TASK_ASSIGNED, + GROUP_TASK_CLAIMED, + UNALLOCATED_STATS_POINTS, + NEW_MYSTERY_ITEMS, + CARD_RECEIVED, + NEW_INBOX_MESSAGE, + NEW_CHAT_MESSAGE, + ACHIEVEMENT_JUST_ADD_WATER, + ACHIEVEMENT_LOST_MASTERCLASSER, + ACHIEVEMENT_MIND_OVER_MATTER, WorldBoss: WORLD_BOSS, VERIFY_USERNAME, }, @@ -141,7 +153,7 @@ export default { }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), notificationsOrder () { // Returns a map of NOTIFICATION_TYPE -> POSITION const orderMap = {}; @@ -157,24 +169,20 @@ export default { const notifications = []; // Parties invitations - notifications.push(...this.user.invitations.parties.map(partyInvitation => { - return { - type: 'PARTY_INVITATION', - data: partyInvitation, - // Create a custom id for notifications outside user.notifications (must be unique) - id: `custom-party-invitation-${partyInvitation.id}`, - }; - })); + notifications.push(...this.user.invitations.parties.map(partyInvitation => ({ + type: 'PARTY_INVITATION', + data: partyInvitation, + // Create a custom id for notifications outside user.notifications (must be unique) + id: `custom-party-invitation-${partyInvitation.id}`, + }))); // Guilds invitations - notifications.push(...this.user.invitations.guilds.map(guildInvitation => { - return { - type: 'GUILD_INVITATION', - data: guildInvitation, - // Create a custom id for notifications outside user.notifications (must be unique) - id: `custom-guild-invitation-${guildInvitation.id}`, - }; - })); + notifications.push(...this.user.invitations.guilds.map(guildInvitation => ({ + type: 'GUILD_INVITATION', + data: guildInvitation, + // Create a custom id for notifications outside user.notifications (must be unique) + id: `custom-guild-invitation-${guildInvitation.id}`, + }))); // Quest invitation if (this.user.party.quest.RSVPNeeded === true) { @@ -228,9 +236,7 @@ export default { return this.notifications.length; }, hasUnseenNotifications () { - return this.notifications.some((notification) => { - return notification.seen === false ? true : false; - }); + return this.notifications.some(notification => (notification.seen === false)); }, hasClass () { return this.$store.getters['members:hasClass'](this.user); @@ -257,7 +263,7 @@ export default { } }).filter(id => Boolean(id)); - if (idsToSee.length > 0) this.seeNotifications({notificationIds: idsToSee}); + if (idsToSee.length > 0) this.seeNotifications({ notificationIds: idsToSee }); }, dismissAll () { const idsToRead = this.notifications.map(notification => { @@ -270,7 +276,7 @@ export default { }).filter(id => Boolean(id)); this.openStatus = 0; - if (idsToRead.length > 0) this.readNotifications({notificationIds: idsToRead}); + if (idsToRead.length > 0) this.readNotifications({ notificationIds: idsToRead }); }, isActionable (notification) { return this.actionableNotifications.indexOf(notification.type) !== -1; diff --git a/website/client/src/components/header/userDropdown.vue b/website/client/src/components/header/userDropdown.vue index 8e453cb8d5..372c3dbcb7 100644 --- a/website/client/src/components/header/userDropdown.vue +++ b/website/client/src/components/header/userDropdown.vue @@ -66,11 +66,11 @@ menu-dropdown.item-user(:right="true") diff --git a/website/client/src/components/inventory/equipment/attributesPopover.vue b/website/client/src/components/inventory/equipment/attributesPopover.vue index 2466800d42..0cefb75cbb 100644 --- a/website/client/src/components/inventory/equipment/attributesPopover.vue +++ b/website/client/src/components/inventory/equipment/attributesPopover.vue @@ -18,39 +18,37 @@ div diff --git a/website/client/src/components/inventory/equipment/equipGearModal.vue b/website/client/src/components/inventory/equipment/equipGearModal.vue index 6746cb27b4..d3c679399a 100644 --- a/website/client/src/components/inventory/equipment/equipGearModal.vue +++ b/website/client/src/components/inventory/equipment/equipGearModal.vue @@ -117,103 +117,100 @@ diff --git a/website/client/src/components/inventory/equipment/index.vue b/website/client/src/components/inventory/equipment/index.vue index 27cf0cf25e..8a132d48b0 100644 --- a/website/client/src/components/inventory/equipment/index.vue +++ b/website/client/src/components/inventory/equipment/index.vue @@ -139,14 +139,14 @@ \ No newline at end of file + diff --git a/website/client/src/components/inventory/items/cards-modal.vue b/website/client/src/components/inventory/items/cards-modal.vue index 44c2f22431..ec5ad2d32f 100644 --- a/website/client/src/components/inventory/items/cards-modal.vue +++ b/website/client/src/components/inventory/items/cards-modal.vue @@ -22,10 +22,10 @@ import { mapState } from '@/libs/store'; import markdown from '@/directives/markdown'; export default { - props: ['cardOptions'], directives: { markdown, }, + props: ['cardOptions'], computed: { ...mapState({ user: 'user.data', @@ -41,13 +41,13 @@ export default { return numberOfVariations; }, cardMessage () { - let random = Math.random() * this.numberOfVariations; - let selection = Math.floor(random); + const random = Math.random() * this.numberOfVariations; + const selection = Math.floor(random); return this.$t(`${this.cardType}${selection}`); }, fromName () { let fromName = ''; - let card = this.user.items.special[`${this.cardType}Received`]; + const card = this.user.items.special[`${this.cardType}Received`]; if (card && card[0]) fromName = card[0]; return fromName; }, diff --git a/website/client/src/components/inventory/items/index.vue b/website/client/src/components/inventory/items/index.vue index 566dd277bf..4a8ef581f8 100644 --- a/website/client/src/components/inventory/items/index.vue +++ b/website/client/src/components/inventory/items/index.vue @@ -221,20 +221,17 @@ const groups = [ ['food', 'Pet_Food_'], ['special', 'inventory_special_', allowedSpecialItems], ['quests', 'inventory_quest_scroll_'], -].map(([group, classPrefix, allowedItems]) => { - return { - key: group, - quantity: 0, - selected: false, - classPrefix, - allowedItems, - }; -}); +].map(([group, classPrefix, allowedItems]) => ({ + key: group, + quantity: 0, + selected: false, + classPrefix, + allowedItems, +})); let lastMouseMoveEvent = {}; export default { - mixins: [notifications], name: 'Items', components: { Item, @@ -249,6 +246,7 @@ export default { drag: DragDropDirective, mousePosition: MouseMoveDirective, }, + mixins: [notifications], data () { return { searchText: null, @@ -283,11 +281,11 @@ export default { this.groups.forEach(group => { const groupKey = group.key; group.quantity = 0; // resetf the count - let itemsArray = itemsByType[groupKey] = []; + const itemsArray = itemsByType[groupKey] = []; const contentItems = this.content[groupKey]; each(this.user.items[groupKey], (itemQuantity, itemKey) => { - let isAllowed = !group.allowedItems || group.allowedItems.indexOf(itemKey) !== -1; + const isAllowed = !group.allowedItems || group.allowedItems.indexOf(itemKey) !== -1; if (itemQuantity > 0 && isAllowed) { const item = contentItems[itemKey]; @@ -310,13 +308,12 @@ export default { itemsArray.sort((a, b) => { if (this.sortBy === 'quantity') { return b.quantity - a.quantity; - } else { // AZ - return a.text.localeCompare(b.text); - } + } // AZ + return a.text.localeCompare(b.text); }); }); - let specialArray = itemsByType.special; + const specialArray = itemsByType.special; specialArray.push({ key: 'mysteryItem', @@ -325,14 +322,14 @@ export default { quantity: this.user.purchased.plan.mysteryItems.length, }); - for (let type in this.content.cardTypes) { - let card = this.user.items.special[`${type}Received`] || []; + for (const type in this.content.cardTypes) { + const card = this.user.items.special[`${type}Received`] || []; if (this.user.items.special[type] > 0 || card.length > 0) { specialArray.push({ type: 'card', key: type, class: `inventory_special_${type}`, - text: this.$t('toAndFromCard', { toName: this.user.profile.name, fromName: card[0]}), + text: this.$t('toAndFromCard', { toName: this.user.profile.name, fromName: card[0] }), quantity: this.user.items.special[type], }); } @@ -347,15 +344,15 @@ export default { }, methods: { userHasPet (potionKey, eggKey) { - let animalKey = `${eggKey}-${potionKey}`; + const animalKey = `${eggKey}-${potionKey}`; - let result = this.user.items.pets[animalKey] > 0; + const result = this.user.items.pets[animalKey] > 0; return result; }, hatchPet (potion, egg) { - this.$store.dispatch('common:hatch', {egg: egg.key, hatchingPotion: potion.key}); - this.text(this.$t('hatchedPet', {egg: egg.text, potion: potion.text})); + this.$store.dispatch('common:hatch', { egg: egg.key, hatchingPotion: potion.key }); + this.text(this.$t('hatchedPet', { egg: egg.text, potion: potion.text })); if (this.user.preferences.suppressModals.hatchPet) return; const newPet = createAnimal(egg, potion, 'pet', this.content, this.user.items); this.$root.$emit('hatchedPet::open', newPet); @@ -367,23 +364,21 @@ export default { // Dragging needs to be added for egg items this.currentDraggingPotion = potion; - let itemRef = this.$refs.draggingPotionInfo; + const itemRef = this.$refs.draggingPotionInfo; - let dragEvent = $event.event; + const dragEvent = $event.event; dragEvent.dataTransfer.setDragImage(itemRef, -20, -20); }, isHatchable (potion, egg) { - if (potion === null || egg === null) - return false; + if (potion === null || egg === null) return false; const petKey = `${egg.key}-${potion.key}`; const petInfo = this.content.petInfo[petKey]; // Check pet exists and is hatchable - if (!petInfo || !petInfo.potion) - return false; + if (!petInfo || !petInfo.potion) return false; return !this.userHasPet(potion.key, egg.key); }, @@ -459,16 +454,15 @@ export default { if (groupKey === 'special') { if (item.key === 'timeTravelers') { - this.$router.push({name: 'time'}); + this.$router.push({ name: 'time' }); } else if (item.key === 'mysteryItem') { - if (item.quantity === 0) - return; + if (item.quantity === 0) return; - let result = await this.$store.dispatch('user:openMysteryItem'); + const result = await this.$store.dispatch('user:openMysteryItem'); - let openedItem = result.data.data; - let text = this.content.gear.flat[openedItem.key].text(); - this.drop(this.$t('messageDropMysteryItem', {dropText: text}), openedItem); + const openedItem = result.data.data; + const text = this.content.gear.flat[openedItem.key].text(); + this.drop(this.$t('messageDropMysteryItem', { dropText: text }), openedItem); } else { this.$root.$emit('selectMembersModal::showItem', item); } diff --git a/website/client/src/components/inventory/stable/foodItem.vue b/website/client/src/components/inventory/stable/foodItem.vue index 6b730fb08b..fc3d80e639 100644 --- a/website/client/src/components/inventory/stable/foodItem.vue +++ b/website/client/src/components/inventory/stable/foodItem.vue @@ -22,11 +22,11 @@ div diff --git a/website/client/src/components/inventory/stable/hatchingModal.vue b/website/client/src/components/inventory/stable/hatchingModal.vue index 3c98b0061e..213b959136 100644 --- a/website/client/src/components/inventory/stable/hatchingModal.vue +++ b/website/client/src/components/inventory/stable/hatchingModal.vue @@ -64,8 +64,8 @@ import svgClose from '@/assets/svg/close.svg'; import petMixin from '@/mixins/petMixin'; export default { - props: ['hatchablePet'], mixins: [petMixin], + props: ['hatchablePet'], data () { return { icons: Object.freeze({ diff --git a/website/client/src/components/inventory/stable/index.vue b/website/client/src/components/inventory/stable/index.vue index 2c0e0535fb..1fea83fc89 100644 --- a/website/client/src/components/inventory/stable/index.vue +++ b/website/client/src/components/inventory/stable/index.vue @@ -312,500 +312,489 @@ diff --git a/website/client/src/components/inventory/stable/mountItem.vue b/website/client/src/components/inventory/stable/mountItem.vue index 0c283d0743..a7f7d15dad 100644 --- a/website/client/src/components/inventory/stable/mountItem.vue +++ b/website/client/src/components/inventory/stable/mountItem.vue @@ -16,44 +16,44 @@ div diff --git a/website/client/src/components/inventory/stable/mountRaisedModal.vue b/website/client/src/components/inventory/stable/mountRaisedModal.vue index 80272c0614..daa873e373 100644 --- a/website/client/src/components/inventory/stable/mountRaisedModal.vue +++ b/website/client/src/components/inventory/stable/mountRaisedModal.vue @@ -57,41 +57,41 @@ b-modal#mount-raised-modal(:hide-header="true") diff --git a/website/client/src/components/inventory/stable/petItem.vue b/website/client/src/components/inventory/stable/petItem.vue index 72f0b48764..55fabceae5 100644 --- a/website/client/src/components/inventory/stable/petItem.vue +++ b/website/client/src/components/inventory/stable/petItem.vue @@ -71,91 +71,93 @@ diff --git a/website/client/src/components/memberDetails.vue b/website/client/src/components/memberDetails.vue index 860e272f54..44392e2757 100644 --- a/website/client/src/components/memberDetails.vue +++ b/website/client/src/components/memberDetails.vue @@ -161,6 +161,14 @@ export default { ClassBadge, StatsBar, }, + filters: { + statFloor (value) { + if (value < 1 && value > 0) { + return Math.ceil(value * 10) / 10; + } + return Math.floor(value); + }, + }, props: { member: { type: Object, @@ -193,19 +201,10 @@ export default { }), }; }, - filters: { - statFloor (value) { - if (value < 1 && value > 0) { - return Math.ceil(value * 10) / 10; - } else { - return Math.floor(value); - } - }, - }, methods: { percent, showMemberModal (member) { - this.$router.push({name: 'userProfile', params: {userId: member._id}}); + this.$router.push({ name: 'userProfile', params: { userId: member._id } }); }, }, computed: { diff --git a/website/client/src/components/modifyInventory.vue b/website/client/src/components/modifyInventory.vue index df612de158..866a75cb36 100644 --- a/website/client/src/components/modifyInventory.vue +++ b/website/client/src/components/modifyInventory.vue @@ -262,11 +262,11 @@ import Content from '@/../../common/script/content'; export default { computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, data () { - let showInv = {}; - let inv = { + const showInv = {}; + const inv = { gear: {}, special: {}, pets: {}, @@ -285,9 +285,9 @@ export default { }, methods: { setAllItems (type, value) { - let set = this.inv[type]; + const set = this.inv[type]; - for (let item in set) { + for (const item in set) { if (set.hasOwnProperty(item)) { set[item] = value; } diff --git a/website/client/src/components/notifications.vue b/website/client/src/components/notifications.vue index 4b6033619e..1f55641fd6 100644 --- a/website/client/src/components/notifications.vue +++ b/website/client/src/components/notifications.vue @@ -132,53 +132,52 @@ import verifyUsername from './settings/verifyUsername'; const NOTIFICATIONS = { CHALLENGE_JOINED_ACHIEVEMENT: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('joinedChallenge')}`, + label: $t => `${$t('achievement')}: ${$t('joinedChallenge')}`, modalId: 'joined-challenge', }, ULTIMATE_GEAR_ACHIEVEMENT: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('gearAchievementNotification')}`, + label: $t => `${$t('achievement')}: ${$t('gearAchievementNotification')}`, modalId: 'ultimate-gear', }, GUILD_JOINED_ACHIEVEMENT: { - label: ($t) => `${$t('achievement')}: ${$t('joinedGuild')}`, + label: $t => `${$t('achievement')}: ${$t('joinedGuild')}`, achievement: true, modalId: 'joined-guild', }, INVITED_FRIEND_ACHIEVEMENT: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('invitedFriend')}`, + label: $t => `${$t('achievement')}: ${$t('invitedFriend')}`, modalId: 'invited-friend', }, NEW_CONTRIBUTOR_LEVEL: { achievement: true, - label: ($t) => $t('modalContribAchievement'), + label: $t => $t('modalContribAchievement'), modalId: 'contributor', }, ACHIEVEMENT_ALL_YOUR_BASE: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('achievementAllYourBase')}`, + label: $t => `${$t('achievement')}: ${$t('achievementAllYourBase')}`, modalId: 'generic-achievement', }, ACHIEVEMENT_BACK_TO_BASICS: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('achievementBackToBasics')}`, + label: $t => `${$t('achievement')}: ${$t('achievementBackToBasics')}`, modalId: 'generic-achievement', }, ACHIEVEMENT_DUST_DEVIL: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('achievementDustDevil')}`, + label: $t => `${$t('achievement')}: ${$t('achievementDustDevil')}`, modalId: 'generic-achievement', }, ACHIEVEMENT_ARID_AUTHORITY: { achievement: true, - label: ($t) => `${$t('achievement')}: ${$t('achievementAridAuthority')}`, + label: $t => `${$t('achievement')}: ${$t('achievementAridAuthority')}`, modalId: 'generic-achievement', }, }; export default { - mixins: [notifications, guide], components: { yesterdailyModal, wonChallenge, @@ -209,17 +208,18 @@ export default { mindOverMatter, justAddWater, }, + mixins: [notifications, guide], data () { // Levels that already display modals and should not trigger generic Level Up - let unlockLevels = { + const unlockLevels = { 3: 'drop system', 10: 'class system', 50: 'Orb of Rebirth', }; // Avoid showing the same notiication more than once - let lastShownNotifications = []; - let alreadyReadNotification = []; + const lastShownNotifications = []; + const alreadyReadNotification = []; // A list of notifications handled by this component, // NOTE: Those not listed here won't be handled at all! @@ -292,7 +292,7 @@ export default { if (after === before) return; if (this.user.stats.lvl === 0) return; - let money = after - before; + const money = after - before; let bonus; if (this.user._tmp) { bonus = this.user._tmp.streakBonus || 0; @@ -427,7 +427,7 @@ export default { } // Lvl evaluation - if (afterLvl !== beforeLvl) { + if (afterLvl !== beforeLvl) { if (afterLvl <= beforeLvl || this.$store.state.isRunningYesterdailies) return; this.showLevelUpNotifications(afterLvl); } @@ -472,8 +472,8 @@ export default { checkNextCron: throttle(function checkNextCron () { if (!this.$store.state.isRunningYesterdailies && this.nextCron && Date.now() > this.nextCron) { Promise.all([ - this.$store.dispatch('user:fetch', {forceLoad: true}), - this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}), + this.$store.dispatch('user:fetch', { forceLoad: true }), + this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true }), ]).then(() => this.runYesterDailies()); } }, 1000), @@ -482,8 +482,9 @@ export default { this.yesterDailies = []; // Open yesterdailies modal the next time cron runs - const dayStart = this.user.preferences.dayStart; - let nextCron = moment().hours(dayStart).minutes(0).seconds(0).milliseconds(0); + const { dayStart } = this.user.preferences; + let nextCron = moment().hours(dayStart).minutes(0).seconds(0) + .milliseconds(0); const currentHour = moment().format('H'); if (currentHour >= dayStart) { @@ -504,16 +505,16 @@ export default { return; } - let dailys = this.$store.state.tasks.data.dailys; + const { dailys } = this.$store.state.tasks.data; - let yesterDay = moment().subtract('1', 'day').startOf('day').add({ + const yesterDay = moment().subtract('1', 'day').startOf('day').add({ hours: this.user.preferences.dayStart, }); - dailys.forEach((task) => { + dailys.forEach(task => { if (task && task.group.approval && task.group.approval.requested) return; if (task.completed) return; - let due = shouldDo(yesterDay, task); + const due = shouldDo(yesterDay, task); if (task.yesterDaily && due) this.yesterDailies.push(task); }); @@ -533,8 +534,8 @@ export default { // Sync await Promise.all([ - this.$store.dispatch('user:fetch', {forceLoad: true}), - this.$store.dispatch('tasks:fetchUserTasks', {forceLoad: true}), + this.$store.dispatch('user:fetch', { forceLoad: true }), + this.$store.dispatch('tasks:fetchUserTasks', { forceLoad: true }), ]); this.$store.state.isRunningYesterdailies = false; @@ -551,10 +552,10 @@ export default { if (!after || after.length === 0 || !Array.isArray(after)) return; - let notificationsToRead = []; - let scoreTaskNotification = []; + const notificationsToRead = []; + const scoreTaskNotification = []; - after.forEach((notification) => { + after.forEach(notification => { // This notification type isn't implemented here if (!this.handledNotifications[notification.type]) return; @@ -644,7 +645,7 @@ export default { if (markAsRead) notificationsToRead.push(notification.id); }); - let userReadNotifsPromise = false; + const userReadNotifsPromise = false; if (notificationsToRead.length > 0) { await axios.post('/api/v4/notifications/read', { @@ -657,7 +658,7 @@ export default { userReadNotifsPromise.then(() => { // Only run this code for scoring approved tasks if (scoreTaskNotification.length > 0) { - let approvedTasks = []; + const approvedTasks = []; for (let i = 0; i < scoreTaskNotification.length; i++) { // Array with all approved tasks const scoreData = scoreTaskNotification[i].data; diff --git a/website/client/src/components/parentPage.vue b/website/client/src/components/parentPage.vue index 1e0681ba50..a645ba7eb3 100644 --- a/website/client/src/components/parentPage.vue +++ b/website/client/src/components/parentPage.vue @@ -2,4 +2,4 @@ .row .col router-view - \ No newline at end of file + diff --git a/website/client/src/components/payments/amazonButton.vue b/website/client/src/components/payments/amazonButton.vue index 4f1ffbef75..9924df7691 100644 --- a/website/client/src/components/payments/amazonButton.vue +++ b/website/client/src/components/payments/amazonButton.vue @@ -4,12 +4,19 @@ diff --git a/website/client/src/components/payments/cancelModalConfirm.vue b/website/client/src/components/payments/cancelModalConfirm.vue index a2c66f4d05..31a1ca21a1 100644 --- a/website/client/src/components/payments/cancelModalConfirm.vue +++ b/website/client/src/components/payments/cancelModalConfirm.vue @@ -50,7 +50,7 @@ export default { }; }, mounted () { - this.$root.$on('habitica:cancel-subscription-confirm', (config) => { + this.$root.$on('habitica:cancel-subscription-confirm', config => { this.config = config; this.$root.$emit('bv::show::modal', 'subscription-cancel-modal'); }); @@ -64,4 +64,4 @@ export default { }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/payments/canceledModal.vue b/website/client/src/components/payments/canceledModal.vue index e058d74165..ce59401ef7 100644 --- a/website/client/src/components/payments/canceledModal.vue +++ b/website/client/src/components/payments/canceledModal.vue @@ -4,7 +4,7 @@ :hideFooter="true", :modalClass="['modal-hidden-footer']" ) - div(slot="modal-header") + div(slot="modal-header") .svg-icon.close(v-html="icons.close", v-once, @click="close()") .icon-container.check-container.d-flex.align-items-center.justify-content-center .svg-icon.check(v-html="icons.check", v-once) @@ -80,7 +80,7 @@ export default { }; }, mounted () { - this.$root.$on('habitica:subscription-canceled', ({dateTerminated, isGroup}) => { + this.$root.$on('habitica:subscription-canceled', ({ dateTerminated, isGroup }) => { this.isGroup = isGroup; if (isGroup) { this.groupDateTerminated = dateTerminated; @@ -97,4 +97,4 @@ export default { }, }, }; - \ No newline at end of file + diff --git a/website/client/src/components/payments/sendGemsModal.vue b/website/client/src/components/payments/sendGemsModal.vue index 9ad1f65dbd..0174162ba9 100644 --- a/website/client/src/components/payments/sendGemsModal.vue +++ b/website/client/src/components/payments/sendGemsModal.vue @@ -49,7 +49,7 @@ b-modal#send-gems(:title="title", :hide-footer="true", size='md', @hide='onHide( :disabled="sendingInProgress" ) {{ $t("send") }} .payments-column.mx-auto(v-else, :class="{'payments-disabled': !gift.subscription.key && gift.gems.amount < 1}") - button.purchase.btn.btn-primary.payment-button.payment-item(@click='showStripe({gift, uuid: userReceivingGems._id, receiverName})', :disabled="!gift.subscription.key && gift.gems.amount < 1") + button.purchase.btn.btn-primary.payment-button.payment-item(@click='showStripe({gift, uuid: userReceivingGems._id, receiverName})', :disabled="!gift.subscription.key && gift.gems.amount < 1") .svg-icon.credit-card-icon(v-html="icons.creditCardIcon") | {{ $t('card') }} button.btn.payment-item.paypal-checkout.payment-button(@click="openPaypalGift({gift: gift, giftedTo: userReceivingGems._id, receiverName})", :disabled="!gift.subscription.key && gift.gems.amount < 1") @@ -106,10 +106,10 @@ import creditCardIcon from '@/assets/svg/credit-card-icon.svg'; const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com'; export default { - mixins: [paymentsMixin, notificationsMixin], components: { amazonButton, }, + mixins: [paymentsMixin, notificationsMixin], data () { return { planGemLimits, @@ -119,7 +119,7 @@ export default { amount: 0, fromBalance: true, }, - subscription: {key: ''}, + subscription: { key: '' }, message: '', }, amazonPayments: {}, @@ -140,9 +140,7 @@ export default { }), subscriptionBlocks () { let subscriptionBlocks = toArray(this.originalSubscriptionBlocks); - subscriptionBlocks = omitBy(subscriptionBlocks, (block) => { - return block.discount === true; - }); + subscriptionBlocks = omitBy(subscriptionBlocks, block => block.discount === true); subscriptionBlocks = orderBy(subscriptionBlocks, ['months']); return subscriptionBlocks; @@ -152,16 +150,21 @@ export default { }, title () { if (!this.userReceivingGems) return ''; - return this.$t('sendGiftHeading', {name: this.userReceivingGems.profile.name}); + return this.$t('sendGiftHeading', { name: this.userReceivingGems.profile.name }); }, receiverName () { if (this.userReceivingGems.auth && this.userReceivingGems.auth.local && this.userReceivingGems.auth.local.username) { return this.userReceivingGems.auth.local.username; - } else { - return this.userReceivingGems.profile.name; } + return this.userReceivingGems.profile.name; }, }, + mounted () { + this.$root.$on('habitica::send-gems', data => { + this.userReceivingGems = data; + this.$root.$emit('bv::show::modal', 'send-gems'); + }); + }, methods: { // @TODO move to payments mixin or action (problem is that we need notifications) async sendGift () { @@ -197,11 +200,5 @@ export default { this.$root.$emit('bv::hide::modal', 'send-gems'); }, }, - mounted () { - this.$root.$on('habitica::send-gems', (data) => { - this.userReceivingGems = data; - this.$root.$emit('bv::show::modal', 'send-gems'); - }); - }, }; diff --git a/website/client/src/components/payments/successModal.vue b/website/client/src/components/payments/successModal.vue index 47f3c8fb23..92f3d73b70 100644 --- a/website/client/src/components/payments/successModal.vue +++ b/website/client/src/components/payments/successModal.vue @@ -1,11 +1,11 @@ diff --git a/website/client/src/components/shops/buyModal.vue b/website/client/src/components/shops/buyModal.vue index ae9618caed..3a4756a257 100644 --- a/website/client/src/components/shops/buyModal.vue +++ b/website/client/src/components/shops/buyModal.vue @@ -274,250 +274,246 @@ diff --git a/website/client/src/components/shops/featuredItemsHeader.vue b/website/client/src/components/shops/featuredItemsHeader.vue index 522f3c6e06..6d89de56c2 100644 --- a/website/client/src/components/shops/featuredItemsHeader.vue +++ b/website/client/src/components/shops/featuredItemsHeader.vue @@ -34,36 +34,36 @@ div.featuredItems diff --git a/website/client/src/components/shops/quests/buyQuestModal.vue b/website/client/src/components/shops/quests/buyQuestModal.vue index 25ea671953..5573d003e3 100644 --- a/website/client/src/components/shops/quests/buyQuestModal.vue +++ b/website/client/src/components/shops/quests/buyQuestModal.vue @@ -196,146 +196,144 @@ diff --git a/website/client/src/components/shops/quests/index.vue b/website/client/src/components/shops/quests/index.vue index 13c88246a4..be963d5a3b 100644 --- a/website/client/src/components/shops/quests/index.vue +++ b/website/client/src/components/shops/quests/index.vue @@ -327,167 +327,164 @@ diff --git a/website/client/src/components/shops/quests/questDialogContent.vue b/website/client/src/components/shops/quests/questDialogContent.vue index 62660178d3..c84ccf45dc 100644 --- a/website/client/src/components/shops/quests/questDialogContent.vue +++ b/website/client/src/components/shops/quests/questDialogContent.vue @@ -32,32 +32,30 @@ diff --git a/website/client/src/components/shops/quests/questDialogDrops.vue b/website/client/src/components/shops/quests/questDialogDrops.vue index d6a4cbfb4b..4db7e3e32e 100644 --- a/website/client/src/components/shops/quests/questDialogDrops.vue +++ b/website/client/src/components/shops/quests/questDialogDrops.vue @@ -66,57 +66,56 @@ diff --git a/website/client/src/components/shops/quests/questInfo.vue b/website/client/src/components/shops/quests/questInfo.vue index b9f7635bbb..0609ae0b36 100644 --- a/website/client/src/components/shops/quests/questInfo.vue +++ b/website/client/src/components/shops/quests/questInfo.vue @@ -95,64 +95,63 @@ dt { diff --git a/website/client/src/components/shops/seasonal/index.vue b/website/client/src/components/shops/seasonal/index.vue index 827d4a38f1..5dec3bef91 100644 --- a/website/client/src/components/shops/seasonal/index.vue +++ b/website/client/src/components/shops/seasonal/index.vue @@ -284,257 +284,243 @@ diff --git a/website/client/src/components/shops/shopItem.vue b/website/client/src/components/shops/shopItem.vue index 6ccf2bd9d6..381b2cbe3d 100644 --- a/website/client/src/components/shops/shopItem.vue +++ b/website/client/src/components/shops/shopItem.vue @@ -150,104 +150,102 @@ div diff --git a/website/client/src/components/shops/timeTravelers/index.vue b/website/client/src/components/shops/timeTravelers/index.vue index b423ae0f18..7507ef738d 100644 --- a/website/client/src/components/shops/timeTravelers/index.vue +++ b/website/client/src/components/shops/timeTravelers/index.vue @@ -233,191 +233,183 @@ diff --git a/website/client/src/components/sidebarSection.vue b/website/client/src/components/sidebarSection.vue index 672ac9d430..c7e1033370 100644 --- a/website/client/src/components/sidebarSection.vue +++ b/website/client/src/components/sidebarSection.vue @@ -54,38 +54,38 @@ \ No newline at end of file + }, +}; + diff --git a/website/client/src/components/snackbars/notification.vue b/website/client/src/components/snackbars/notification.vue index afa265a809..24be51a77c 100644 --- a/website/client/src/components/snackbars/notification.vue +++ b/website/client/src/components/snackbars/notification.vue @@ -132,32 +132,6 @@ export default { show: true, }; }, - created () { - let timeout = this.notification.hasOwnProperty('timeout') ? this.notification.timeout : true; - if (timeout) { - let delay = this.notification.delay || 1500; - delay += this.$store.state.notificationStore.length * 1000; - this.timer = setTimeout(() => { - this.show = false; - }, delay); - } - }, - beforeDestroy () { - clearTimeout(this.timer); - }, - watch: { - show () { - this.$store.dispatch('snackbars:remove', this.notification); - }, - }, - methods: { - handleOnClick () { - if (typeof this.notification.onClick === 'function') { - this.notification.onClick(); - } - this.show = false; - }, - }, computed: { message () { if (this.notification.flavorMessage) { @@ -179,5 +153,31 @@ export default { return `${this.notification.type} ${this.negative}`; }, }, + watch: { + show () { + this.$store.dispatch('snackbars:remove', this.notification); + }, + }, + created () { + const timeout = this.notification.hasOwnProperty('timeout') ? this.notification.timeout : true; + if (timeout) { + let delay = this.notification.delay || 1500; + delay += this.$store.state.notificationStore.length * 1000; + this.timer = setTimeout(() => { + this.show = false; + }, delay); + } + }, + beforeDestroy () { + clearTimeout(this.timer); + }, + methods: { + handleOnClick () { + if (typeof this.notification.onClick === 'function') { + this.notification.onClick(); + } + this.show = false; + }, + }, }; diff --git a/website/client/src/components/static/clearBrowserData.vue b/website/client/src/components/static/clearBrowserData.vue index 39c97cda76..ef5de361cf 100644 --- a/website/client/src/components/static/clearBrowserData.vue +++ b/website/client/src/components/static/clearBrowserData.vue @@ -15,23 +15,23 @@ diff --git a/website/client/src/components/static/faq.vue b/website/client/src/components/static/faq.vue index bc74032d83..251cb5d284 100644 --- a/website/client/src/components/static/faq.vue +++ b/website/client/src/components/static/faq.vue @@ -41,57 +41,57 @@ diff --git a/website/client/src/components/static/features.vue b/website/client/src/components/static/features.vue index a578cffb17..efd1d1cd5d 100644 --- a/website/client/src/components/static/features.vue +++ b/website/client/src/components/static/features.vue @@ -90,16 +90,16 @@ diff --git a/website/client/src/components/static/groupPlans.vue b/website/client/src/components/static/groupPlans.vue index 3a34cd987a..f39b5e0ebd 100644 --- a/website/client/src/components/static/groupPlans.vue +++ b/website/client/src/components/static/groupPlans.vue @@ -195,58 +195,58 @@ diff --git a/website/client/src/components/static/home.vue b/website/client/src/components/static/home.vue index 5d3af7b932..4f0b96d4c6 100644 --- a/website/client/src/components/static/home.vue +++ b/website/client/src/components/static/home.vue @@ -558,176 +558,176 @@ diff --git a/website/client/src/components/static/merch.vue b/website/client/src/components/static/merch.vue index d4f3f440b9..d3faae8858 100644 --- a/website/client/src/components/static/merch.vue +++ b/website/client/src/components/static/merch.vue @@ -13,21 +13,31 @@ img.img-rendering-auto(:src="`/static/merch/${merchant.key}.png`") p {{ $t('merch-' + merchant.key + '-summary') }} a.btn.btn-primary(:href="merchant.link" target='_blank') {{$t('merch-' + merchant.key + '-goto')}} - + diff --git a/website/client/src/components/static/newStuff.vue b/website/client/src/components/static/newStuff.vue index bffec9d38e..9fc059a7dc 100644 --- a/website/client/src/components/static/newStuff.vue +++ b/website/client/src/components/static/newStuff.vue @@ -16,7 +16,7 @@ export default { }; }, async mounted () { - let response = await axios.get('/api/v4/news'); + const response = await axios.get('/api/v4/news'); this.html = response.data.html; }, }; diff --git a/website/client/src/components/static/pressKit.vue b/website/client/src/components/static/pressKit.vue index 150606dce0..85f25f75a1 100644 --- a/website/client/src/components/static/pressKit.vue +++ b/website/client/src/components/static/pressKit.vue @@ -32,99 +32,99 @@ diff --git a/website/client/src/components/tasks/approvalFooter.vue b/website/client/src/components/tasks/approvalFooter.vue index 09e270e80f..9c4809fb84 100644 --- a/website/client/src/components/tasks/approvalFooter.vue +++ b/website/client/src/components/tasks/approvalFooter.vue @@ -45,43 +45,40 @@ import approvalModal from './approvalModal'; import sync from '@/mixins/sync'; export default { - mixins: [sync], - props: ['task', 'group'], components: { approvalModal, }, + mixins: [sync], + props: ['task', 'group'], computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), userIsAssigned () { return this.task.group.assignedUsers && this.task.group.assignedUsers.indexOf(this.user._id) !== -1; }, message () { - let assignedUsers = this.task.group.assignedUsers; - let assignedUsersNames = []; - let assignedUsersLength = assignedUsers.length; + const { assignedUsers } = this.task.group; + const assignedUsersNames = []; + const assignedUsersLength = assignedUsers.length; // @TODO: Eh, I think we only ever display one user name if (this.group && this.group.members) { assignedUsers.forEach(userId => { - let index = findIndex(this.group.members, (member) => { - return member._id === userId; - }); - let assignedMember = this.group.members[index]; + const index = findIndex(this.group.members, member => member._id === userId); + const assignedMember = this.group.members[index]; assignedUsersNames.push(assignedMember.profile.name); }); } if (assignedUsersLength === 1 && !this.userIsAssigned) { - return this.$t('assignedToUser', {userName: assignedUsersNames[0]}); - } else if (assignedUsersLength > 1 && !this.userIsAssigned) { - return this.$t('assignedToMembers', {userCount: assignedUsersLength}); - } else if (assignedUsersLength > 1 && this.userIsAssigned) { - return this.$t('assignedToYouAndMembers', {userCount: assignedUsersLength - 1}); - } else if (this.userIsAssigned) { + return this.$t('assignedToUser', { userName: assignedUsersNames[0] }); + } if (assignedUsersLength > 1 && !this.userIsAssigned) { + return this.$t('assignedToMembers', { userCount: assignedUsersLength }); + } if (assignedUsersLength > 1 && this.userIsAssigned) { + return this.$t('assignedToYouAndMembers', { userCount: assignedUsersLength - 1 }); + } if (this.userIsAssigned) { return this.$t('youAreAssigned'); - } else { // if (assignedUsersLength === 0) { - return this.$t('taskIsUnassigned'); - } + } // if (assignedUsersLength === 0) { + return this.$t('taskIsUnassigned'); }, userIsManager () { if (this.group && (this.group.leader.id === this.user._id || this.group.managers[this.user._id])) return true; @@ -124,13 +121,13 @@ export default { taskId, userId: this.user._id, }); - let index = this.task.group.assignedUsers.indexOf(this.user._id); + const index = this.task.group.assignedUsers.indexOf(this.user._id); this.task.group.assignedUsers.splice(index, 1); this.sync(); }, approve () { - let userIdToApprove = this.task.group.assignedUsers[0]; + const userIdToApprove = this.task.group.assignedUsers[0]; this.$store.dispatch('tasks:approve', { taskId: this.task._id, userId: userIdToApprove, @@ -140,7 +137,7 @@ export default { }, needsWork () { if (!confirm(this.$t('confirmNeedsWork'))) return; - let userIdNeedsMoreWork = this.task.group.assignedUsers[0]; + const userIdNeedsMoreWork = this.task.group.assignedUsers[0]; this.$store.dispatch('tasks:needsWork', { taskId: this.task._id, userId: userIdNeedsMoreWork, diff --git a/website/client/src/components/tasks/approvalHeader.vue b/website/client/src/components/tasks/approvalHeader.vue index 577aea9f83..fa65fbb956 100644 --- a/website/client/src/components/tasks/approvalHeader.vue +++ b/website/client/src/components/tasks/approvalHeader.vue @@ -26,26 +26,24 @@ diff --git a/website/client/src/components/ui/countBadge.vue b/website/client/src/components/ui/countBadge.vue index ecbee290c9..7f4b828357 100644 --- a/website/client/src/components/ui/countBadge.vue +++ b/website/client/src/components/ui/countBadge.vue @@ -21,14 +21,14 @@ span.badge.badge-pill.badge-item.badge-count( diff --git a/website/client/src/components/ui/customMenuDropdown.vue b/website/client/src/components/ui/customMenuDropdown.vue index 3485080478..def253602a 100644 --- a/website/client/src/components/ui/customMenuDropdown.vue +++ b/website/client/src/components/ui/customMenuDropdown.vue @@ -69,7 +69,7 @@ export default { computed: { isOpen () { // Open status is a number so we can tell if the value was passed - if (this.openStatus !== undefined) return this.openStatus === 1 ? true : false; + if (this.openStatus !== undefined) return this.openStatus === 1; return this.isDropdownOpen; }, isPressed () { diff --git a/website/client/src/components/ui/drawer.vue b/website/client/src/components/ui/drawer.vue index 7fbdd5428d..db8aaa56ff 100644 --- a/website/client/src/components/ui/drawer.vue +++ b/website/client/src/components/ui/drawer.vue @@ -165,15 +165,19 @@ export default { computed: { isOpen () { // Open status is a number so we can tell if the value was passed - if (this.openStatus !== undefined) return this.openStatus === 1 ? true : false; + if (this.openStatus !== undefined) return this.openStatus === 1; return this.open; }, }, + mounted () { + // Make sure the page has enough space so the drawer does not overlap content + this.adjustPagePadding(); + }, methods: { adjustPagePadding () { - let minPaddingBottom = 20; - let drawerHeight = this.$el.offsetHeight; - let standardPage = document.getElementsByClassName('standard-page')[0]; + const minPaddingBottom = 20; + const drawerHeight = this.$el.offsetHeight; + const standardPage = document.getElementsByClassName('standard-page')[0]; if (standardPage) { standardPage.style.paddingBottom = `${drawerHeight + minPaddingBottom}px`; } @@ -183,9 +187,5 @@ export default { this.$emit('toggled', this.open); }, }, - mounted () { - // Make sure the page has enough space so the drawer does not overlap content - this.adjustPagePadding(); - }, }; diff --git a/website/client/src/components/ui/drawerHeaderTabs.vue b/website/client/src/components/ui/drawerHeaderTabs.vue index ec0738bf97..47cd79eaf3 100644 --- a/website/client/src/components/ui/drawerHeaderTabs.vue +++ b/website/client/src/components/ui/drawerHeaderTabs.vue @@ -56,23 +56,23 @@ diff --git a/website/client/src/components/ui/drawerSlider.vue b/website/client/src/components/ui/drawerSlider.vue index 85511cff96..1aaddab27d 100644 --- a/website/client/src/components/ui/drawerSlider.vue +++ b/website/client/src/components/ui/drawerSlider.vue @@ -100,90 +100,89 @@ diff --git a/website/client/src/components/ui/filterDropdown.vue b/website/client/src/components/ui/filterDropdown.vue index d1ebd52b3b..e712152e8f 100644 --- a/website/client/src/components/ui/filterDropdown.vue +++ b/website/client/src/components/ui/filterDropdown.vue @@ -16,28 +16,28 @@ span diff --git a/website/client/src/components/ui/layoutSection.vue b/website/client/src/components/ui/layoutSection.vue index 11c527c492..ec5e72383f 100644 --- a/website/client/src/components/ui/layoutSection.vue +++ b/website/client/src/components/ui/layoutSection.vue @@ -13,11 +13,11 @@ div diff --git a/website/client/src/components/ui/statsbar.vue b/website/client/src/components/ui/statsbar.vue index 84a44bd53a..e3f31ccbaf 100644 --- a/website/client/src/components/ui/statsbar.vue +++ b/website/client/src/components/ui/statsbar.vue @@ -75,52 +75,51 @@ diff --git a/website/client/src/components/ui/toggleSwitch.vue b/website/client/src/components/ui/toggleSwitch.vue index 13101b4590..a2e025779b 100644 --- a/website/client/src/components/ui/toggleSwitch.vue +++ b/website/client/src/components/ui/toggleSwitch.vue @@ -108,14 +108,6 @@ - diff --git a/website/client/src/components/userLink.vue b/website/client/src/components/userLink.vue index 06415d6f7b..1d4433c262 100644 --- a/website/client/src/components/userLink.vue +++ b/website/client/src/components/userLink.vue @@ -33,83 +33,82 @@ diff --git a/website/client/src/components/userMenu/achievements.vue b/website/client/src/components/userMenu/achievements.vue index 9f8bdf50fa..0424b94e5b 100644 --- a/website/client/src/components/userMenu/achievements.vue +++ b/website/client/src/components/userMenu/achievements.vue @@ -66,7 +66,7 @@ export default { this.achievements = achievementsLib.getAchievementsForProfile(this.user); }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), }, }; diff --git a/website/client/src/components/userMenu/inbox.vue b/website/client/src/components/userMenu/inbox.vue index 4afb7d9be9..d0727ddb51 100644 --- a/website/client/src/components/userMenu/inbox.vue +++ b/website/client/src/components/userMenu/inbox.vue @@ -238,11 +238,11 @@ import moment from 'moment'; import filter from 'lodash/filter'; import groupBy from 'lodash/groupBy'; import orderBy from 'lodash/orderBy'; -import { mapState } from '@/libs/store'; import habiticaMarkdown from 'habitica-markdown'; +import axios from 'axios'; +import { mapState } from '@/libs/store'; import styleHelper from '@/mixins/styleHelper'; import toggleSwitch from '@/components/ui/toggleSwitch'; -import axios from 'axios'; import chatMessages from '../chat/chatMessages'; import messageIcon from '@/assets/svg/message.svg'; @@ -259,44 +259,16 @@ import tier9 from '@/assets/svg/tier-staff.svg'; import tierNPC from '@/assets/svg/tier-npc.svg'; export default { - mixins: [styleHelper], components: { chatMessages, toggleSwitch, }, - mounted () { - this.$root.$on('habitica::new-inbox-message', (data) => { - this.$root.$emit('bv::show::modal', 'inbox-modal'); - - // Wait for messages to be loaded - const unwatchLoaded = this.$watch('loaded', (loaded) => { - if (!loaded) return; - - const conversation = this.conversations.find(convo => { - return convo.key === data.userIdToMessage; - }); - if (loaded) setImmediate(() => unwatchLoaded()); - - if (conversation) { - this.selectConversation(data.userIdToMessage); - return; - } - - this.initiatedConversation = { - uuid: data.userIdToMessage, - user: data.displayName, - username: data.username, - backer: data.backer, - contributor: data.contributor, - }; - - this.selectConversation(data.userIdToMessage); - }, {immediate: true}); - }); - }, - destroyed () { - this.$root.$off('habitica::new-inbox-message'); + filters: { + timeAgo (value) { + return moment(new Date(value)).fromNow(); + }, }, + mixins: [styleHelper], data () { return { icons: Object.freeze({ @@ -327,13 +299,39 @@ export default { updateConversionsCounter: 0, }; }, - filters: { - timeAgo (value) { - return moment(new Date(value)).fromNow(); - }, + mounted () { + this.$root.$on('habitica::new-inbox-message', data => { + this.$root.$emit('bv::show::modal', 'inbox-modal'); + + // Wait for messages to be loaded + const unwatchLoaded = this.$watch('loaded', loaded => { + if (!loaded) return; + + const conversation = this.conversations.find(convo => convo.key === data.userIdToMessage); + if (loaded) setImmediate(() => unwatchLoaded()); + + if (conversation) { + this.selectConversation(data.userIdToMessage); + return; + } + + this.initiatedConversation = { + uuid: data.userIdToMessage, + user: data.displayName, + username: data.username, + backer: data.backer, + contributor: data.contributor, + }; + + this.selectConversation(data.userIdToMessage); + }, { immediate: true }); + }); + }, + destroyed () { + this.$root.$off('habitica::new-inbox-message'); }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), canLoadMore () { return this.selectedConversation && this.selectedConversation.canLoadMore; }, @@ -354,7 +352,7 @@ export default { } // Create conversation objects const convos = []; - for (let key in inboxGroup) { + for (const key in inboxGroup) { const recentMessage = inboxGroup[key][0]; const convoModel = { @@ -381,9 +379,7 @@ export default { const selectedConversation = this.messagesByConversation[selectedConversationKey]; this.messages = selectedConversation || []; // eslint-disable-line vue/no-side-effects-in-computed-properties - const ordered = orderBy(this.messages, [(m) => { - return m.timestamp; - }], ['asc']); + const ordered = orderBy(this.messages, [m => m.timestamp], ['asc']); if (subScribeToUpdate) { return ordered; @@ -395,15 +391,11 @@ export default { // Vue-subscribe to changes const subScribeToUpdate = this.updateConversionsCounter > -1; - const filtered = subScribeToUpdate && !this.search ? - this.conversations : - filter(this.conversations, (conversation) => { - return conversation.name.toLowerCase().indexOf(this.search.toLowerCase()) !== -1; - }); + const filtered = subScribeToUpdate && !this.search + ? this.conversations + : filter(this.conversations, conversation => conversation.name.toLowerCase().indexOf(this.search.toLowerCase()) !== -1); - const ordered = orderBy(filtered, [(o) => { - return moment(o.date).toDate(); - }], ['desc']); + const ordered = orderBy(filtered, [o => moment(o.date).toDate()], ['desc']); return ordered; }, @@ -474,9 +466,7 @@ export default { this.$store.dispatch('user:togglePrivateMessagesOpt'); }, async selectConversation (key) { - let convoFound = this.conversations.find((conversation) => { - return conversation.key === key; - }); + const convoFound = this.conversations.find(conversation => conversation.key === key); this.selectedConversation = convoFound || {}; @@ -486,7 +476,7 @@ export default { Vue.nextTick(() => { if (!this.$refs.chatscroll) return; - let chatscroll = this.$refs.chatscroll.$el; + const chatscroll = this.$refs.chatscroll.$el; chatscroll.scrollTop = chatscroll.scrollHeight; }); }, @@ -527,7 +517,7 @@ export default { Vue.nextTick(() => { if (!this.$refs.chatscroll) return; - let chatscroll = this.$refs.chatscroll.$el; + const chatscroll = this.$refs.chatscroll.$el; chatscroll.scrollTop = chatscroll.scrollHeight; }); @@ -556,7 +546,7 @@ export default { return this.icons[`tier${message.contributor.level}`]; }, removeTags (html) { - let tmp = document.createElement('DIV'); + const tmp = document.createElement('DIV'); tmp.innerHTML = html; return tmp.textContent || tmp.innerText || ''; }, @@ -586,8 +576,7 @@ export default { this.messagesByConversation[this.selectedConversation.key] = this.messagesByConversation[this.selectedConversation.key] || []; const loadedMessagesToAdd = loadedMessages - .filter(m => this.messagesByConversation[this.selectedConversation.key].findIndex(mI => mI.id === m.id) === -1) - ; + .filter(m => this.messagesByConversation[this.selectedConversation.key].findIndex(mI => mI.id === m.id) === -1); this.messagesByConversation[this.selectedConversation.key].push(...loadedMessagesToAdd); // only show the load more Button if the max count was returned diff --git a/website/client/src/components/userMenu/profile.vue b/website/client/src/components/userMenu/profile.vue index 0a32de8fe0..e97e872791 100644 --- a/website/client/src/components/userMenu/profile.vue +++ b/website/client/src/components/userMenu/profile.vue @@ -393,14 +393,12 @@ import moment from 'moment'; import axios from 'axios'; import each from 'lodash/each'; -import { mapState } from '@/libs/store'; import cloneDeep from 'lodash/cloneDeep'; +import { mapState } from '@/libs/store'; import MemberDetails from '../memberDetails'; import markdown from '@/directives/markdown'; import achievementsLib from '@/../../common/script/libs/achievements'; -// @TODO: EMAILS.COMMUNITY_MANAGER_EMAIL -const COMMUNITY_MANAGER_EMAIL = 'admin@habitica.com'; import Content from '@/../../common/script/content'; import profileStats from './profileStats'; @@ -415,9 +413,10 @@ import lock from '@/assets/svg/lock.svg'; import challenge from '@/assets/svg/challenge.svg'; import member from '@/assets/svg/member-icon.svg'; import staff from '@/assets/svg/tier-staff.svg'; +// @TODO: EMAILS.COMMUNITY_MANAGER_EMAIL +const COMMUNITY_MANAGER_EMAIL = 'admin@habitica.com'; export default { - props: ['userId', 'startingPage'], directives: { markdown, }, @@ -425,6 +424,7 @@ export default { MemberDetails, profileStats, }, + props: ['userId', 'startingPage'], data () { return { icons: Object.freeze({ @@ -479,7 +479,7 @@ export default { }, classText () { - let classTexts = { + const classTexts = { warrior: this.$t('warrior'), wizard: this.$t('mage'), rogue: this.$t('rogue'), @@ -495,9 +495,6 @@ export default { return this.$store.getters['members:hasClass'](this.userLoggedIn); }, }, - mounted () { - this.loadUser(); - }, watch: { startingPage () { this.selectedPage = this.startingPage; @@ -509,6 +506,9 @@ export default { this.loadUser(); }, }, + mounted () { + this.loadUser(); + }, methods: { async loadUser () { let user = this.userLoggedIn; @@ -518,10 +518,10 @@ export default { this.hero = {}; this.adminToolsLoaded = false; - let profileUserId = this.userId; + const profileUserId = this.userId; if (profileUserId && profileUserId !== this.userLoggedIn._id) { - let response = await this.$store.dispatch('members:fetchMember', { memberId: profileUserId }); + const response = await this.$store.dispatch('members:fetchMember', { memberId: profileUserId }); user = response.data.data; } @@ -566,20 +566,20 @@ export default { // return `${this.$t('checkinProgressTitle')} ${start}/${end}`; }, getIncentivesProgress () { - let currentLoginDay = Content.loginIncentives[this.user.loginIncentives]; + const currentLoginDay = Content.loginIncentives[this.user.loginIncentives]; if (!currentLoginDay) return 0; - let previousRewardDay = currentLoginDay.prevRewardKey; - let nextRewardAt = currentLoginDay.nextRewardAt; + const previousRewardDay = currentLoginDay.prevRewardKey; + const { nextRewardAt } = currentLoginDay; return (this.user.loginIncentives - previousRewardDay) / (nextRewardAt - previousRewardDay) * 100; }, save () { - let values = {}; + const values = {}; - let edits = cloneDeep(this.editingProfile); + const edits = cloneDeep(this.editingProfile); each(edits, (value, key) => { // Using toString because we need to compare two arrays (websites) - let curVal = this.user.profile[key]; + const curVal = this.user.profile[key]; if (!curVal || value.toString() !== curVal.toString()) { values[`profile.${key}`] = value; @@ -596,7 +596,7 @@ export default { axios.post(`/api/v4/user/block/${this.user._id}`); }, unblockUser () { - let index = this.userLoggedIn.inbox.blocks.indexOf(this.user._id); + const index = this.userLoggedIn.inbox.blocks.indexOf(this.user._id); this.userLoggedIn.inbox.blocks.splice(index, 1); axios.post(`/api/v4/user/block/${this.user._id}`); }, diff --git a/website/client/src/components/userMenu/profileModal.vue b/website/client/src/components/userMenu/profileModal.vue index 2379c7ec64..4c04e95408 100644 --- a/website/client/src/components/userMenu/profileModal.vue +++ b/website/client/src/components/userMenu/profileModal.vue @@ -12,39 +12,39 @@ diff --git a/website/client/src/components/userMenu/profilePage.vue b/website/client/src/components/userMenu/profilePage.vue index e1ec222301..cfb7a0f50b 100644 --- a/website/client/src/components/userMenu/profilePage.vue +++ b/website/client/src/components/userMenu/profilePage.vue @@ -13,12 +13,12 @@ diff --git a/website/client/src/components/userMenu/profileStats.vue b/website/client/src/components/userMenu/profileStats.vue index a7f8cc0239..8c55dd7ad5 100644 --- a/website/client/src/components/userMenu/profileStats.vue +++ b/website/client/src/components/userMenu/profileStats.vue @@ -150,205 +150,202 @@ diff --git a/website/client/src/components/yesterdailyModal.vue b/website/client/src/components/yesterdailyModal.vue index 4d6a5ad6d4..62b0e7c900 100644 --- a/website/client/src/components/yesterdailyModal.vue +++ b/website/client/src/components/yesterdailyModal.vue @@ -69,17 +69,17 @@ import { mapState } from '@/libs/store'; import Task from './tasks/task'; export default { - props: ['yesterDailies'], components: { Task, }, + props: ['yesterDailies'], data () { return { dueDate: moment().subtract(1, 'days'), }; }, computed: { - ...mapState({user: 'user.data'}), + ...mapState({ user: 'user.data' }), tasksByType () { this.dueDate = moment().subtract(1, 'days'); // eslint-disable-line vue/no-side-effects-in-computed-properties diff --git a/website/client/src/directives/directive.common.js b/website/client/src/directives/directive.common.js index 151bc76870..a7321b864b 100644 --- a/website/client/src/directives/directive.common.js +++ b/website/client/src/directives/directive.common.js @@ -1,6 +1,6 @@ // https://stackoverflow.com/a/40720172/1298154 export const emit = (vnode, emitName, data) => { - let handlers = vnode.data && vnode.data.on || vnode.componentOptions && vnode.componentOptions.listeners; + const handlers = vnode.data && vnode.data.on || vnode.componentOptions && vnode.componentOptions.listeners; if (handlers && handlers[emitName]) { handlers[emitName].fns(data); diff --git a/website/client/src/directives/markdown.js b/website/client/src/directives/markdown.js index bc2cd0a458..99237ee1c8 100644 --- a/website/client/src/directives/markdown.js +++ b/website/client/src/directives/markdown.js @@ -1,6 +1,6 @@ import habiticaMarkdown from 'habitica-markdown'; -export default function markdown (el, {value, oldValue}) { +export default function markdown (el, { value, oldValue }) { if (value === oldValue) return; if (value) { @@ -10,4 +10,4 @@ export default function markdown (el, {value, oldValue}) { } el.classList.add('markdown'); -} \ No newline at end of file +} diff --git a/website/client/src/directives/mouseposition.directive.js b/website/client/src/directives/mouseposition.directive.js index 7206ef3102..b923408896 100644 --- a/website/client/src/directives/mouseposition.directive.js +++ b/website/client/src/directives/mouseposition.directive.js @@ -12,7 +12,7 @@ const EVENT_NAME = 'mouseMoved'; export default { bind (el, binding, vnode) { - el.handleMouseMove = _throttle((ev) => { + el.handleMouseMove = _throttle(ev => { emit(vnode, EVENT_NAME, { x: ev.clientX, y: ev.clientY, diff --git a/website/client/src/filters/floorWholeNumber.js b/website/client/src/filters/floorWholeNumber.js index 02e04b9ec6..3e30e2e5c3 100644 --- a/website/client/src/filters/floorWholeNumber.js +++ b/website/client/src/filters/floorWholeNumber.js @@ -1,3 +1,3 @@ export default function floorWholeNumber (val) { return Math.floor(val); -} \ No newline at end of file +} diff --git a/website/client/src/filters/registerGlobals.js b/website/client/src/filters/registerGlobals.js index d111cfd6dd..a6ae6e2d4e 100644 --- a/website/client/src/filters/registerGlobals.js +++ b/website/client/src/filters/registerGlobals.js @@ -7,4 +7,4 @@ import floorWholeNumber from './floorWholeNumber'; Vue.filter('round', round); Vue.filter('floor', floor); Vue.filter('roundBigNumber', roundBigNumber); -Vue.filter('floorWholeNumber', floorWholeNumber); \ No newline at end of file +Vue.filter('floorWholeNumber', floorWholeNumber); diff --git a/website/client/src/filters/round.js b/website/client/src/filters/round.js index 2fa5858670..5fdd3c10d9 100644 --- a/website/client/src/filters/round.js +++ b/website/client/src/filters/round.js @@ -1,3 +1,3 @@ export default function round (val) { return Math.round(val * 100) / 100; -} \ No newline at end of file +} diff --git a/website/client/src/filters/roundBigNumber.js b/website/client/src/filters/roundBigNumber.js index 4f7e94961d..92c48032bc 100644 --- a/website/client/src/filters/roundBigNumber.js +++ b/website/client/src/filters/roundBigNumber.js @@ -15,11 +15,10 @@ function _convertToBillion (num) { export default function roundBigNumber (num) { if (num > 999999999) { return _convertToBillion(num); - } else if (num > 999999) { + } if (num > 999999) { return _convertToMillion(num); - } else if (num > 999) { + } if (num > 999) { return _convertToThousand(num); - } else { - return round(num); } -} \ No newline at end of file + return round(num); +} diff --git a/website/client/src/libs/analytics.js b/website/client/src/libs/analytics.js index 0a202fed6f..1e687f635b 100644 --- a/website/client/src/libs/analytics.js +++ b/website/client/src/libs/analytics.js @@ -3,16 +3,16 @@ import isEqual from 'lodash/isEqual'; import keys from 'lodash/keys'; import pick from 'lodash/pick'; import includes from 'lodash/includes'; -import getStore from '@/store'; import amplitude from 'amplitude-js'; import Vue from 'vue'; +import getStore from '@/store'; const IS_PRODUCTION = process.env.NODE_ENV === 'production'; // eslint-disable-line no-process-env -const AMPLITUDE_KEY = process.env.AMPLITUDE_KEY; // eslint-disable-line no-process-env -const GA_ID = process.env.GA_ID; // eslint-disable-line no-process-env +const { AMPLITUDE_KEY } = process.env; // eslint-disable-line no-process-env +const { GA_ID } = process.env; // eslint-disable-line no-process-env -let REQUIRED_FIELDS = ['hitType', 'eventCategory', 'eventAction']; -let ALLOWED_HIT_TYPES = [ +const REQUIRED_FIELDS = ['hitType', 'eventCategory', 'eventAction']; +const ALLOWED_HIT_TYPES = [ 'pageview', 'screenview', 'event', @@ -73,7 +73,7 @@ export function setUser () { const store = getStore(); const user = store.state.user.data; amplitude.getInstance().setUserId(user._id); - window.ga('set', {userId: user._id}); + window.ga('set', { userId: user._id }); } export function track (properties) { diff --git a/website/client/src/libs/asyncResource.js b/website/client/src/libs/asyncResource.js index c620295865..5d74d99f32 100644 --- a/website/client/src/libs/asyncResource.js +++ b/website/client/src/libs/asyncResource.js @@ -10,7 +10,9 @@ export function asyncResourceFactory () { }; } -export function loadAsyncResource ({store, path, url, deserialize, forceLoad = false}) { +export function loadAsyncResource ({ + store, path, url, deserialize, forceLoad = false, +}) { if (!store) throw new Error('"store" is required and must be the application store.'); if (!path) throw new Error('The path to the resource in the application state is required.'); if (!url) throw new Error('The resource\'s url on the server is required.'); @@ -18,22 +20,21 @@ export function loadAsyncResource ({store, path, url, deserialize, forceLoad = f const resource = get(store.state, path); if (!resource) throw new Error(`No resouce found at path "${path}".`); - const loadingStatus = resource.loadingStatus; + const { loadingStatus } = resource; if (loadingStatus === 'LOADED' && !forceLoad) { return Promise.resolve(resource); - } else if (loadingStatus === 'LOADING') { + } if (loadingStatus === 'LOADING') { return new Promise((resolve, reject) => { - const resourceWatcher = store.watch(state => get(state, `${path}.loadingStatus`), (newLoadingStatus) => { + const resourceWatcher = store.watch(state => get(state, `${path}.loadingStatus`), newLoadingStatus => { resourceWatcher(); // remove the watcher if (newLoadingStatus === 'LOADED') { return resolve(resource); - } else { - return reject(); // TODO add reason? } + return reject(); // TODO add reason? }); }); - } else if (loadingStatus === 'NOT_LOADED' || forceLoad) { + } if (loadingStatus === 'NOT_LOADED' || forceLoad) { return axios.get(url).then(response => { // TODO support more params resource.loadingStatus = 'LOADED'; // deserialize can be a promise @@ -42,7 +43,6 @@ export function loadAsyncResource ({store, path, url, deserialize, forceLoad = f return resource; }); }); - } else { - return Promise.reject(new Error(`Invalid loading status "${loadingStatus} for resource at "${path}".`)); } + return Promise.reject(new Error(`Invalid loading status "${loadingStatus} for resource at "${path}".`)); } diff --git a/website/client/src/libs/auth.js b/website/client/src/libs/auth.js index 8c31ba0179..432222436c 100644 --- a/website/client/src/libs/auth.js +++ b/website/client/src/libs/auth.js @@ -8,7 +8,7 @@ export function setUpAxios (AUTH_SETTINGS) { AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS); } - let browserTimezoneOffset = moment().zone(); + const browserTimezoneOffset = moment().zone(); if (AUTH_SETTINGS.auth && AUTH_SETTINGS.auth.apiId && AUTH_SETTINGS.auth.apiToken) { axios.defaults.headers.common['x-api-user'] = AUTH_SETTINGS.auth.apiId; diff --git a/website/client/src/libs/createAnimal.js b/website/client/src/libs/createAnimal.js index 87df5b46b4..01c10ed13c 100644 --- a/website/client/src/libs/createAnimal.js +++ b/website/client/src/libs/createAnimal.js @@ -7,9 +7,8 @@ const wackyPets = Object.keys(content.wackyPets); function getText (textOrFunction) { if (textOrFunction instanceof Function) { return textOrFunction(); - } else { - return textOrFunction; } + return textOrFunction; } export function isOwned (type, animal, userItems) { @@ -17,16 +16,16 @@ export function isOwned (type, animal, userItems) { } export function isHatchable (animal, userItems) { - return !isOwned('pet', animal, userItems) && - userItems.eggs[animal.eggKey] && - userItems.hatchingPotions[animal.potionKey]; + return !isOwned('pet', animal, userItems) + && userItems.eggs[animal.eggKey] + && userItems.hatchingPotions[animal.potionKey]; } export function isAllowedToFeed (animal, userItems) { - return !specialPets.includes(animal.key) && - !wackyPets.includes(animal.key) && - isOwned('pet', animal, userItems) && - !isOwned('mount', animal, userItems); + return !specialPets.includes(animal.key) + && !wackyPets.includes(animal.key) + && isOwned('pet', animal, userItems) + && !isOwned('mount', animal, userItems); } export function isSpecial (animal) { @@ -34,7 +33,7 @@ export function isSpecial (animal) { } export function createAnimal (egg, potion, type, _content, userItems) { - let animalKey = `${egg.key}-${potion.key}`; + const animalKey = `${egg.key}-${potion.key}`; return { key: animalKey, diff --git a/website/client/src/libs/encodeParams.js b/website/client/src/libs/encodeParams.js index 1666e92fa5..f208a89405 100644 --- a/website/client/src/libs/encodeParams.js +++ b/website/client/src/libs/encodeParams.js @@ -1,7 +1,5 @@ // Equivalent of jQuery's param export default function (params) { - return Object.keys(params).map((k) => { - return `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`; - }).join('&'); + return Object.keys(params).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`).join('&'); } diff --git a/website/client/src/libs/i18n.js b/website/client/src/libs/i18n.js index c3f8df67f5..bdf4888f57 100644 --- a/website/client/src/libs/i18n.js +++ b/website/client/src/libs/i18n.js @@ -1,17 +1,17 @@ // Vue plugin to globally expose a '$t' method that calls common/i18n.t. // Can be anywhere inside vue as 'this.$t' or '$t' in templates. -import i18n from '@/../../common/script/i18n'; import moment from 'moment'; +import i18n from '@/../../common/script/i18n'; export default { - install (Vue, {i18nData}) { + install (Vue, { i18nData }) { if (i18nData) { // Load i18n strings i18n.strings = i18nData.strings; // Load Moment.js locale - const language = i18nData.language; + const { language } = i18nData; if (language && i18nData.momentLang && language.momentLangCode) { // Make moment available under `window` so that the locale can be set @@ -31,4 +31,4 @@ export default { return i18n.t.apply(null, arguments); }; }, -}; \ No newline at end of file +}; diff --git a/website/client/src/libs/notifications.js b/website/client/src/libs/notifications.js index 0c1c696560..7ab27a27a2 100644 --- a/website/client/src/libs/notifications.js +++ b/website/client/src/libs/notifications.js @@ -1,4 +1,4 @@ -export function getDropClass ({type, key}) { +export function getDropClass ({ type, key }) { let dropClass = ''; if (type) { @@ -48,4 +48,4 @@ export function round (number, nDigits) { export function getXPMessage (val) { return `${getSign(val)} ${round(val)}`; -} \ No newline at end of file +} diff --git a/website/client/src/libs/store/helpers/filterTasks.js b/website/client/src/libs/store/helpers/filterTasks.js index 6d88e9563d..2068bfadb5 100644 --- a/website/client/src/libs/store/helpers/filterTasks.js +++ b/website/client/src/libs/store/helpers/filterTasks.js @@ -38,15 +38,15 @@ const taskFilters = { }; function typeLabel (filterList) { - return (type) => filterList[type].label; + return type => filterList[type].label; } export const getTypeLabel = typeLabel(taskFilters); function filterLabel (filterList) { - return (type) => { - let filterListByType = filterList[type].filters; - let filterListOfLabels = new Array(filterListByType.length); + return type => { + const filterListByType = filterList[type].filters; + const filterListOfLabels = new Array(filterListByType.length); filterListByType.forEach(({ label }, i) => filterListOfLabels[i] = label); return filterListOfLabels; @@ -57,7 +57,7 @@ export const getFilterLabels = filterLabel(taskFilters); function activeFilter (filterList) { return (type, filterType = '') => { - let filterListByType = filterList[type].filters; + const filterListByType = filterList[type].filters; if (filterType) { return filterListByType.find(f => f.label === filterType); } diff --git a/website/client/src/libs/store/helpers/internals.js b/website/client/src/libs/store/helpers/internals.js index e6999e932e..c3083d0670 100644 --- a/website/client/src/libs/store/helpers/internals.js +++ b/website/client/src/libs/store/helpers/internals.js @@ -20,7 +20,7 @@ Example: tasks:dailys */ export function flattenAndNamespace (namespaces) { - let result = {}; + const result = {}; Object.keys(namespaces).forEach(namespace => { Object.keys(namespaces[namespace]).forEach(itemName => { @@ -29,4 +29,4 @@ export function flattenAndNamespace (namespaces) { }); return result; -} \ No newline at end of file +} diff --git a/website/client/src/libs/store/helpers/orderTasks.js b/website/client/src/libs/store/helpers/orderTasks.js index 1f4957e2bd..400cd9770f 100644 --- a/website/client/src/libs/store/helpers/orderTasks.js +++ b/website/client/src/libs/store/helpers/orderTasks.js @@ -28,4 +28,4 @@ export function orderMultipleTypeTasks (rawTasks, tasksOrder) { todos: orderSingleTypeTasks(rawTasks.todos, tasksOrder.todos), rewards: orderSingleTypeTasks(rawTasks.rewards, tasksOrder.rewards), }; -} \ No newline at end of file +} diff --git a/website/client/src/libs/store/helpers/public.js b/website/client/src/libs/store/helpers/public.js index 7b46aff7a7..d6ae5ea759 100644 --- a/website/client/src/libs/store/helpers/public.js +++ b/website/client/src/libs/store/helpers/public.js @@ -25,9 +25,9 @@ The code has been slightly changed to match our code style and to support nested import get from 'lodash/get'; function normalizeMap (map) { - return Array.isArray(map) ? - map.map(key => ({ key, val: key })) : - Object.keys(map).map(key => ({ key, val: map[key] })); + return Array.isArray(map) + ? map.map(key => ({ key, val: key })) + : Object.keys(map).map(key => ({ key, val: map[key] })); } export function mapState (states) { @@ -35,9 +35,9 @@ export function mapState (states) { normalizeMap(states).forEach(({ key, val }) => { res[key] = function mappedState () { - return typeof val === 'function' ? - val.call(this, this.$store.state, this.$store.getters) : - get(this.$store.state, val); + return typeof val === 'function' + ? val.call(this, this.$store.state, this.$store.getters) + : get(this.$store.state, val); }; }); @@ -66,4 +66,4 @@ export function mapActions (actions) { }); return res; -} \ No newline at end of file +} diff --git a/website/client/src/libs/store/index.js b/website/client/src/libs/store/index.js index 502c28828c..e288479108 100644 --- a/website/client/src/libs/store/index.js +++ b/website/client/src/libs/store/index.js @@ -5,7 +5,7 @@ import Vue from 'vue'; // similar internal implementation (thanks!), main difference is the absence of mutations. export default class Store { - constructor ({state, getters, actions}) { + constructor ({ state, getters, actions }) { // Store actions this._actions = actions; @@ -16,7 +16,7 @@ export default class Store { const _computed = {}; Object.keys(getters).forEach(key => { - let getter = getters[key]; + const getter = getters[key]; // Each getter is compiled to a computed property on the internal VM _computed[key] = () => getter(this); @@ -41,7 +41,7 @@ export default class Store { // Actions should be called using store.dispatch(ACTION_NAME, ...ARGS) // They get passed the store instance and any additional argument passed to dispatch() dispatch (type, ...args) { - let action = this._actions[type]; + const action = this._actions[type]; if (!action) throw new Error(`Action "${type}" not found.`); return action(this, ...args); diff --git a/website/client/src/main.js b/website/client/src/main.js index 9bd0a92b12..b0836c73cc 100644 --- a/website/client/src/main.js +++ b/website/client/src/main.js @@ -26,7 +26,7 @@ Vue.config.performance = !IS_PRODUCTION; Vue.config.productionTip = IS_PRODUCTION; // window['habitica-i18n] is injected by the server -Vue.use(i18n, {i18nData: window && window['habitica-i18n']}); +Vue.use(i18n, { i18nData: window && window['habitica-i18n'] }); Vue.use(StoreModule); Vue.use(BootstrapVue); diff --git a/website/client/src/mixins/avatarEditUtilities.js b/website/client/src/mixins/avatarEditUtilities.js index 622c2193c8..69d53aedeb 100644 --- a/website/client/src/mixins/avatarEditUtilities.js +++ b/website/client/src/mixins/avatarEditUtilities.js @@ -1,15 +1,15 @@ import moment from 'moment'; import axios from 'axios'; +import get from 'lodash/get'; import unlock from '@/../../common/script/ops/unlock'; import buy from '@/../../common/script/ops/buy/buy'; -import get from 'lodash/get'; import appearanceSets from '@/../../common/script/content/appearance/sets'; -import {userStateMixin} from './userState'; +import { userStateMixin } from './userState'; export const avatarEditorUtilies = { mixins: [userStateMixin], @@ -31,16 +31,14 @@ export const avatarEditorUtilies = { option.pathKey = pathKey; option.active = userPreference === key; option.class = this.createClass(type, subType, key); - option.click = (optionParam) => { - return option.gemLocked ? this.unlock(`${optionParam.pathKey}.${key}`) : this.set({[`preferences.${optionParam.pathKey}`]: optionParam.key}); - }; + option.click = optionParam => (option.gemLocked ? this.unlock(`${optionParam.pathKey}.${key}`) : this.set({ [`preferences.${optionParam.pathKey}`]: optionParam.key })); return option; }, mapKeysToOption (key, type, subType, set) { const option = this.mapKeysToFreeOption(key, type, subType); - let userPurchased = subType ? this.user.purchased[type][subType] : this.user.purchased[type]; - let locked = !userPurchased || !userPurchased[key]; + const userPurchased = subType ? this.user.purchased[type][subType] : this.user.purchased[type]; + const locked = !userPurchased || !userPurchased[key]; let hide = false; if (set && appearanceSets[set]) { @@ -104,7 +102,7 @@ export const avatarEditorUtilies = { this.$store.dispatch('user:set', settings); }, equip (key, type) { - this.$store.dispatch('common:equip', {key, type}); + this.$store.dispatch('common:equip', { key, type }); }, /** * For gem-unlockable preferences, (a) if owned, select preference (b) else, purchase @@ -112,8 +110,8 @@ export const avatarEditorUtilies = { * Pass in this paramater as "skin.abc". Alternatively, pass as an array ["skin.abc", "skin.xyz"] to unlock sets */ async unlock (path) { - let fullSet = path.indexOf(',') !== -1; - let isBackground = path.indexOf('background.') !== -1; + const fullSet = path.indexOf(',') !== -1; + const isBackground = path.indexOf('background.') !== -1; let cost; @@ -123,7 +121,7 @@ export const avatarEditorUtilies = { cost = fullSet ? 1.25 : 0.5; // (Hair, skin, etc) 5G per set, 2G per individual } - let loginIncentives = [ + const loginIncentives = [ 'background.blue', 'background.green', 'background.red', @@ -134,11 +132,11 @@ export const avatarEditorUtilies = { if (loginIncentives.indexOf(path) === -1) { if (fullSet) { - if (confirm(this.$t('purchaseFor', {cost: cost * 4})) !== true) return; + if (confirm(this.$t('purchaseFor', { cost: cost * 4 })) !== true) return; // @TODO: implement gem modal // if (this.user.balance < cost) return $rootScope.openModal('buyGems'); } else if (!get(this.user, `purchased.${path}`)) { - if (confirm(this.$t('purchaseFor', {cost: cost * 4})) !== true) return; + if (confirm(this.$t('purchaseFor', { cost: cost * 4 })) !== true) return; // @TODO: implement gem modal // if (this.user.balance < cost) return $rootScope.openModal('buyGems'); } diff --git a/website/client/src/mixins/buy.js b/website/client/src/mixins/buy.js index 7b709861e4..dd537e8db4 100644 --- a/website/client/src/mixins/buy.js +++ b/website/client/src/mixins/buy.js @@ -18,9 +18,8 @@ export default { type: 'error', }); return; - } else { - throw e; } + throw e; } this.$root.$emit('playSound', 'Reward'); diff --git a/website/client/src/mixins/groupsUtilities.js b/website/client/src/mixins/groupsUtilities.js index ce6f22b938..1bab4ce001 100644 --- a/website/client/src/mixins/groupsUtilities.js +++ b/website/client/src/mixins/groupsUtilities.js @@ -3,13 +3,13 @@ import intersection from 'lodash/intersection'; export default { filters: { // https://stackoverflow.com/questions/2685911/is-there-a-way-to-round-numbers-into-a-reader-friendly-format-e-g-1-1k - abbrNum: (number) => { + abbrNum: number => { let decPlaces = 1; decPlaces = Math.pow(10, decPlaces); - let abbrev = ['k', 'm', 'b', 't']; + const abbrev = ['k', 'm', 'b', 't']; for (let i = abbrev.length - 1; i >= 0; i--) { - let size = Math.pow(10, (i + 1) * 3); + const size = Math.pow(10, (i + 1) * 3); if (size <= number) { number = Math.floor(number * decPlaces / size) / decPlaces; @@ -61,11 +61,11 @@ export default { } if (filters.categories && filters.categories.length > 0) { - let intersectingCats = intersection(filters.categories, group.categorySlugs); + const intersectingCats = intersection(filters.categories, group.categorySlugs); hasCategories = intersectingCats.length > 0; } - let filteringRole = filters.roles && filters.roles.length > 0; + const filteringRole = filters.roles && filters.roles.length > 0; if (filteringRole && filters.roles.indexOf('member') !== -1) { isMember = this.isMemberOfGroup(user, group); } diff --git a/website/client/src/mixins/guide.js b/website/client/src/mixins/guide.js index 10a82b1201..c82e525e27 100644 --- a/website/client/src/mixins/guide.js +++ b/website/client/src/mixins/guide.js @@ -109,8 +109,8 @@ export default { ]], }; - for (let key in this.chapters) { - let chapter = this.chapters[key][0][0]; + for (const key in this.chapters) { + const chapter = this.chapters[key][0][0]; chapter.intro = `