From 020c6d1bcfaf67ccb9ecdab13a39a1ddea868bb6 Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Sun, 7 Jul 2019 00:54:17 +0300
Subject: [PATCH] all the manual fixes

---
 .eslintrc.js                                  | 22 +--------------
 src/components/attachment/attachment.vue      |  2 ++
 .../basic_user_card/basic_user_card.vue       |  2 ++
 src/components/chat_panel/chat_panel.vue      |  2 +-
 src/components/conversation/conversation.js   |  1 +
 src/components/font_control/font_control.vue  |  1 +
 src/components/gallery/gallery.vue            |  3 +-
 .../instance_specific_panel.vue               |  2 ++
 .../interface_language_switcher.vue           |  1 +
 src/components/link-preview/link-preview.vue  |  2 +-
 src/components/media_modal/media_modal.vue    |  2 +-
 src/components/media_upload/media_upload.vue  |  2 +-
 src/components/notification/notification.vue  |  2 ++
 src/components/poll/poll.vue                  |  2 +-
 src/components/poll/poll_form.vue             |  1 +
 .../post_status_form/post_status_form.vue     |  3 +-
 src/components/registration/registration.vue  |  7 ++++-
 .../shadow_control/shadow_control.vue         |  1 +
 src/components/status/status.js               |  2 +-
 src/components/status/status.vue              | 28 +++++++++++--------
 .../style_switcher/style_switcher.vue         |  2 ++
 .../terms_of_service_panel.vue                |  2 ++
 src/components/user_card/user_card.js         |  4 +--
 src/components/user_card/user_card.vue        |  4 +++
 .../user_settings/mfa_backup_codes.vue        |  5 +++-
 .../who_to_follow_panel.vue                   |  1 +
 src/modules/auth_flow.js                      |  1 +
 src/modules/users.js                          |  8 +++---
 .../backend_interactor_service.js             |  6 ++++
 test/unit/karma.conf.js                       |  4 +--
 .../entity_normalizer.spec.js                 |  6 ----
 31 files changed, 74 insertions(+), 57 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index 7d090208..3c48baa8 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -21,26 +21,6 @@ module.exports = {
     'generator-star-spacing': 0,
     // allow debugger during development
     'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
-    // Webpack 4 update commit, most of these probably should be fixed and removed in a separate MR
-    // A lot of errors come from .vue files that are now properly linted
-    'vue/valid-v-if': 1,
-    'vue/use-v-on-exact': 1,
-    'vue/no-parsing-error': 1,
-    'vue/require-v-for-key': 1,
-    'vue/valid-v-for': 1,
-    'vue/require-prop-types': 1,
-    'vue/no-use-v-if-with-v-for': 1,
-    'indent': 1,
-    'import/first': 1,
-    'object-curly-spacing': 1,
-    'prefer-promise-reject-errors': 1,
-    'eol-last': 1,
-    'no-return-await': 1,
-    'no-multi-spaces': 1,
-    'no-trailing-spaces': 1,
-    'no-unused-expressions': 1,
-    'no-mixed-operators': 1,
-    'camelcase': 1,
-    'no-multiple-empty-lines': 1
+    'vue/require-prop-types': 0
   }
 }
diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue
index 55d81691..108dc36e 100644
--- a/src/components/attachment/attachment.vue
+++ b/src/components/attachment/attachment.vue
@@ -97,8 +97,10 @@
         <img :src="attachment.thumb_url">
       </div>
       <div class="text">
+        <!-- eslint-disable vue/no-v-html -->
         <h1><a :href="attachment.url">{{ attachment.oembed.title }}</a></h1>
         <div v-html="attachment.oembed.oembedHTML" />
+        <!-- eslint-enabled vue/no-v-html -->
       </div>
     </div>
   </div>
diff --git a/src/components/basic_user_card/basic_user_card.vue b/src/components/basic_user_card/basic_user_card.vue
index 8ad0da2d..568e9359 100644
--- a/src/components/basic_user_card/basic_user_card.vue
+++ b/src/components/basic_user_card/basic_user_card.vue
@@ -25,11 +25,13 @@
         :title="user.name"
         class="basic-user-card-user-name"
       >
+        <!-- eslint-disable vue/no-v-html -->
         <span
           v-if="user.name_html"
           class="basic-user-card-user-name-value"
           v-html="user.name_html"
         />
+        <!-- eslint-enable vue/no-v-html -->
         <span
           v-else
           class="basic-user-card-user-name-value"
diff --git a/src/components/chat_panel/chat_panel.vue b/src/components/chat_panel/chat_panel.vue
index ca2c64a3..3677722f 100644
--- a/src/components/chat_panel/chat_panel.vue
+++ b/src/components/chat_panel/chat_panel.vue
@@ -1,6 +1,6 @@
 <template>
   <div
-    v-if="!this.collapsed || !this.floating"
+    v-if="!collapsed || !floating"
     class="chat-panel"
   >
     <div class="panel panel-default">
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js
index cc0b0b41..a2b3aeab 100644
--- a/src/components/conversation/conversation.js
+++ b/src/components/conversation/conversation.js
@@ -86,6 +86,7 @@ const conversation = {
     },
     replies () {
       let i = 1
+      // eslint-disable-next-line camelcase
       return reduce(this.conversation, (result, { id, in_reply_to_status_id }) => {
         /* eslint-disable camelcase */
         const irid = in_reply_to_status_id
diff --git a/src/components/font_control/font_control.vue b/src/components/font_control/font_control.vue
index 87644628..61f0384b 100644
--- a/src/components/font_control/font_control.vue
+++ b/src/components/font_control/font_control.vue
@@ -35,6 +35,7 @@
       >
         <option
           v-for="option in availableOptions"
+          :key="option"
           :value="option"
         >
           {{ option === 'custom' ? $t('settings.style.fonts.custom') : option }}
diff --git a/src/components/gallery/gallery.vue b/src/components/gallery/gallery.vue
index 577f2144..6adfb76c 100644
--- a/src/components/gallery/gallery.vue
+++ b/src/components/gallery/gallery.vue
@@ -4,7 +4,8 @@
     style="width: 100%;"
   >
     <div
-      v-for="row in rows"
+      v-for="(row, index) in rows"
+      :key="index"
       class="gallery-row"
       :style="rowHeight(row.length)"
       :class="{ 'contain-fit': useContainFit, 'cover-fit': !useContainFit }"
diff --git a/src/components/instance_specific_panel/instance_specific_panel.vue b/src/components/instance_specific_panel/instance_specific_panel.vue
index 64ce4f8a..a7cf6b48 100644
--- a/src/components/instance_specific_panel/instance_specific_panel.vue
+++ b/src/components/instance_specific_panel/instance_specific_panel.vue
@@ -5,7 +5,9 @@
   >
     <div class="panel panel-default">
       <div class="panel-body">
+        <!-- eslint-disable vue/no-v-html -->
         <div v-html="instanceSpecificPanelContent" />
+        <!-- eslint-enable vue/no-v-html -->
       </div>
     </div>
   </div>
diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue
index 28c811bd..83df9a0b 100644
--- a/src/components/interface_language_switcher/interface_language_switcher.vue
+++ b/src/components/interface_language_switcher/interface_language_switcher.vue
@@ -13,6 +13,7 @@
       >
         <option
           v-for="(langCode, i) in languageCodes"
+          :key="langCode"
           :value="langCode"
         >
           {{ languageNames[i] }}
diff --git a/src/components/link-preview/link-preview.vue b/src/components/link-preview/link-preview.vue
index 5041dd1d..493774c2 100644
--- a/src/components/link-preview/link-preview.vue
+++ b/src/components/link-preview/link-preview.vue
@@ -11,7 +11,7 @@
         class="card-image"
         :class="{ 'small-image': size === 'small' }"
       >
-        <img :src="card.image"></img>
+        <img :src="card.image">
       </div>
       <div class="card-content">
         <span class="card-host faint">{{ card.provider_name }}</span>
diff --git a/src/components/media_modal/media_modal.vue b/src/components/media_modal/media_modal.vue
index f14740f6..0543e677 100644
--- a/src/components/media_modal/media_modal.vue
+++ b/src/components/media_modal/media_modal.vue
@@ -8,7 +8,7 @@
       v-if="type === 'image'"
       class="modal-image"
       :src="currentMedia.url"
-    ></img>
+    >
     <VideoAttachment
       v-if="type === 'video'"
       class="modal-image"
diff --git a/src/components/media_upload/media_upload.vue b/src/components/media_upload/media_upload.vue
index 60ce2d42..ac32ae83 100644
--- a/src/components/media_upload/media_upload.vue
+++ b/src/components/media_upload/media_upload.vue
@@ -23,7 +23,7 @@
         style="position: fixed; top: -100em"
         multiple="true"
         @change="change"
-      ></input>
+      >
     </label>
   </div>
 </template>
diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue
index 88f4e886..bafcd026 100644
--- a/src/components/notification/notification.vue
+++ b/src/components/notification/notification.vue
@@ -30,12 +30,14 @@
       />
       <span class="notification-details">
         <div class="name-and-action">
+          <!-- eslint-disable vue/no-v-html -->
           <span
             v-if="!!notification.from_profile.name_html"
             class="username"
             :title="'@'+notification.from_profile.screen_name"
             v-html="notification.from_profile.name_html"
           />
+          <!-- eslint-enable vue/no-v-html -->
           <span
             v-else
             class="username"
diff --git a/src/components/poll/poll.vue b/src/components/poll/poll.vue
index 0fc81b46..db8e33b3 100644
--- a/src/components/poll/poll.vue
+++ b/src/components/poll/poll.vue
@@ -60,7 +60,7 @@
       </div>
       <i18n :path="expired ? 'polls.expired' : 'polls.expires_in'">
         <Timeago
-          :time="this.expiresAt"
+          :time="expiresAt"
           :auto-update="60"
           :now-threshold="0"
         />
diff --git a/src/components/poll/poll_form.vue b/src/components/poll/poll_form.vue
index 2bd3d058..d53f3837 100644
--- a/src/components/poll/poll_form.vue
+++ b/src/components/poll/poll_form.vue
@@ -77,6 +77,7 @@
           >
             <option
               v-for="unit in expiryUnits"
+              :key="unit"
               :value="unit"
             >
               {{ $t(`time.${unit}_short`, ['']) }}
diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue
index 379c9f3b..1f389eda 100644
--- a/src/components/post_status_form/post_status_form.vue
+++ b/src/components/post_status_form/post_status_form.vue
@@ -206,6 +206,7 @@
       <div class="attachments">
         <div
           v-for="file in newStatus.files"
+          :key="file.url"
           class="media-upload-wrapper"
         >
           <i
@@ -217,7 +218,7 @@
               v-if="type(file) === 'image'"
               class="thumbnail media-upload"
               :src="file.url"
-            ></img>
+            >
             <video
               v-if="type(file) === 'video'"
               :src="file.url"
diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue
index 8cc4ba56..e0fa214a 100644
--- a/src/components/registration/registration.vue
+++ b/src/components/registration/registration.vue
@@ -215,17 +215,22 @@
             </div>
           </div>
 
+          <!-- eslint-disable vue/no-v-html -->
           <div
             class="terms-of-service"
             v-html="termsOfService"
           />
+          <!-- eslint-enable vue/no-v-html -->
         </div>
         <div
           v-if="serverValidationErrors.length"
           class="form-group"
         >
           <div class="alert error">
-            <span v-for="error in serverValidationErrors">{{ error }}</span>
+            <span
+              v-for="error in serverValidationErrors"
+              :key="error"
+            >{{ error }}</span>
           </div>
         </div>
       </form>
diff --git a/src/components/shadow_control/shadow_control.vue b/src/components/shadow_control/shadow_control.vue
index faefe1ff..de8a42d1 100644
--- a/src/components/shadow_control/shadow_control.vue
+++ b/src/components/shadow_control/shadow_control.vue
@@ -72,6 +72,7 @@
           >
             <option
               v-for="(shadow, index) in cValue"
+              :key="index"
               :value="index"
             >
               {{ $t('settings.style.shadows.shadow_id', { value: index }) }}
diff --git a/src/components/status/status.js b/src/components/status/status.js
index d2452935..199351cb 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -221,7 +221,7 @@ const Status = {
         ? this.$store.state.instance.subjectLineBehavior
         : this.$store.state.config.subjectLineBehavior
       const startsWithRe = decodedSummary.match(/^re[: ]/i)
-      if (behavior !== 'noop' && startsWithRe || behavior === 'masto') {
+      if ((behavior !== 'noop' && startsWithRe) || behavior === 'masto') {
         return decodedSummary
       } else if (behavior === 'email') {
         return 're: '.concat(decodedSummary)
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index e482cfd8..6f7f826b 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -1,4 +1,5 @@
 <template>
+  <!-- eslint-disable vue/no-v-html -->
   <div
     v-if="!hideStatus"
     class="status-el"
@@ -205,18 +206,20 @@
                   v-if="replies && replies.length"
                   class="faint"
                 >{{ $t('status.replies_list') }}</span>
-                <span
-                  v-for="reply in replies"
-                  v-if="replies"
-                  class="reply-link faint"
-                >
-                  <a
-                    href="#"
-                    @click.prevent="gotoOriginal(reply.id)"
-                    @mouseenter="replyEnter(reply.id, $event)"
-                    @mouseout="replyLeave()"
-                  >{{ reply.name }}</a>
-                </span>
+                <template v-if="replies">
+                  <span
+                    v-for="reply in replies"
+                    :key="reply.id"
+                    class="reply-link faint"
+                  >
+                    <a
+                      href="#"
+                      @click.prevent="gotoOriginal(reply.id)"
+                      @mouseenter="replyEnter(reply.id, $event)"
+                      @mouseout="replyLeave()"
+                    >{{ reply.name }}</a>
+                  </span>
+                </template>
               </div>
             </div>
           </div>
@@ -422,6 +425,7 @@
       </div>
     </template>
   </div>
+<!-- eslint-enable vue/no-v-html -->
 </template>
 
 <script src="./status.js" ></script>
diff --git a/src/components/style_switcher/style_switcher.vue b/src/components/style_switcher/style_switcher.vue
index 97dba99d..d24394a4 100644
--- a/src/components/style_switcher/style_switcher.vue
+++ b/src/components/style_switcher/style_switcher.vue
@@ -24,6 +24,7 @@
                 >
                   <option
                     v-for="style in availableStyles"
+                    :key="style.name"
                     :value="style"
                     :style="{
                       backgroundColor: style[1] || style.theme.colors.bg,
@@ -463,6 +464,7 @@
                 >
                   <option
                     v-for="shadow in shadowsAvailable"
+                    :key="shadow"
                     :value="shadow"
                   >
                     {{ $t('settings.style.shadows.components.' + shadow) }}
diff --git a/src/components/terms_of_service_panel/terms_of_service_panel.vue b/src/components/terms_of_service_panel/terms_of_service_panel.vue
index f79345cb..63dc58b8 100644
--- a/src/components/terms_of_service_panel/terms_of_service_panel.vue
+++ b/src/components/terms_of_service_panel/terms_of_service_panel.vue
@@ -2,10 +2,12 @@
   <div>
     <div class="panel panel-default">
       <div class="panel-body">
+        <!-- eslint-disable vue/no-v-html -->
         <div
           class="tos-content"
           v-html="content"
         />
+      <!-- eslint-enable vue/no-v-html -->
       </div>
     </div>
   </div>
diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js
index 63dfa6ed..92cd0e54 100644
--- a/src/components/user_card/user_card.js
+++ b/src/components/user_card/user_card.js
@@ -73,12 +73,12 @@ export default {
     userHighlightType: {
       get () {
         const data = this.$store.state.config.highlight[this.user.screen_name]
-        return data && data.type || 'disabled'
+        return (data && data.type) || 'disabled'
       },
       set (type) {
         const data = this.$store.state.config.highlight[this.user.screen_name]
         if (type !== 'disabled') {
-          this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: data && data.color || '#FFFFFF', type })
+          this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: (data && data.color) || '#FFFFFF', type })
         } else {
           this.$store.dispatch('setHighlight', { user: this.user.screen_name, color: undefined })
         }
diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue
index 7ad8aa1d..5a5a4881 100644
--- a/src/components/user_card/user_card.vue
+++ b/src/components/user_card/user_card.vue
@@ -15,12 +15,14 @@
           </router-link>
           <div class="user-summary">
             <div class="top-line">
+              <!-- eslint-disable vue/no-v-html -->
               <div
                 v-if="user.name_html"
                 :title="user.name"
                 class="user-name"
                 v-html="user.name_html"
               />
+              <!-- eslint-enable vue/no-v-html -->
               <div
                 v-else
                 :title="user.name"
@@ -237,12 +239,14 @@
           <span>{{ user.followers_count }}</span>
         </div>
       </div>
+      <!-- eslint-disable vue/no-v-html -->
       <p
         v-if="!hideBio && user.description_html"
         class="user-card-bio"
         @click.prevent="linkClicked"
         v-html="user.description_html"
       />
+      <!-- eslint-enable vue/no-v-html -->
       <p
         v-else-if="!hideBio"
         class="user-card-bio"
diff --git a/src/components/user_settings/mfa_backup_codes.vue b/src/components/user_settings/mfa_backup_codes.vue
index 62542839..e6c8ede2 100644
--- a/src/components/user_settings/mfa_backup_codes.vue
+++ b/src/components/user_settings/mfa_backup_codes.vue
@@ -9,7 +9,10 @@
         {{ $t('settings.mfa.recovery_codes_warning') }}
       </p>
       <ul class="backup-codes">
-        <li v-for="code in backupCodes.codes">
+        <li
+          v-for="code in backupCodes.codes"
+          :key="code"
+        >
           {{ code }}
         </li>
       </ul>
diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.vue b/src/components/who_to_follow_panel/who_to_follow_panel.vue
index b26e5f4f..518acd97 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.vue
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.vue
@@ -9,6 +9,7 @@
       <div class="who-to-follow">
         <p
           v-for="user in usersToFollow"
+          :key="user.id"
           class="who-to-follow-items"
         >
           <img :src="user.img">
diff --git a/src/modules/auth_flow.js b/src/modules/auth_flow.js
index 34e15053..d0a90feb 100644
--- a/src/modules/auth_flow.js
+++ b/src/modules/auth_flow.js
@@ -73,6 +73,7 @@ const mutations = {
 
 // actions
 const actions = {
+  // eslint-disable-next-line camelcase
   async login ({ state, dispatch, commit }, { access_token }) {
     commit('setToken', access_token, { root: true })
     await dispatch('loginUser', access_token, { root: true })
diff --git a/src/modules/users.js b/src/modules/users.js
index 3cd38d56..d06e77c7 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -393,7 +393,7 @@ const users = {
       }
     },
     async getCaptcha (store) {
-      return await store.rootState.api.backendInteractor.getCaptcha()
+      return store.rootState.api.backendInteractor.getCaptcha()
     },
 
     logout (store) {
@@ -451,9 +451,9 @@ const users = {
               // Authentication failed
               commit('endLogin')
               if (response.status === 401) {
-                reject('Wrong username or password')
+                reject(new Error('Wrong username or password'))
               } else {
-                reject('An error occurred, please try again')
+                reject(new Error('An error occurred, please try again'))
               }
             }
             commit('endLogin')
@@ -462,7 +462,7 @@ const users = {
           .catch((error) => {
             console.log(error)
             commit('endLogin')
-            reject('Failed to connect to server, try again')
+            reject(new Error('Failed to connect to server, try again'))
           })
       })
     }
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index e095d3d2..3550aafd 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -63,26 +63,32 @@ const backendInteractorService = credentials => {
     return notificationsFetcher.startFetching({ store, credentials })
   }
 
+  // eslint-disable-next-line camelcase
   const tagUser = ({ screen_name }, tag) => {
     return apiService.tagUser({ screen_name, tag, credentials })
   }
 
+  // eslint-disable-next-line camelcase
   const untagUser = ({ screen_name }, tag) => {
     return apiService.untagUser({ screen_name, tag, credentials })
   }
 
+  // eslint-disable-next-line camelcase
   const addRight = ({ screen_name }, right) => {
     return apiService.addRight({ screen_name, right, credentials })
   }
 
+  // eslint-disable-next-line camelcase
   const deleteRight = ({ screen_name }, right) => {
     return apiService.deleteRight({ screen_name, right, credentials })
   }
 
+  // eslint-disable-next-line camelcase
   const setActivationStatus = ({ screen_name }, status) => {
     return apiService.setActivationStatus({ screen_name, status, credentials })
   }
 
+  // eslint-disable-next-line camelcase
   const deleteUser = ({ screen_name }) => {
     return apiService.deleteUser({ screen_name, credentials })
   }
diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js
index f9500ce8..8af05c24 100644
--- a/test/unit/karma.conf.js
+++ b/test/unit/karma.conf.js
@@ -3,12 +3,12 @@
 // we are also using it with karma-webpack
 //   https://github.com/webpack/karma-webpack
 
-var path = require('path')
+// var path = require('path')
 var merge = require('webpack-merge')
 var baseConfig = require('../../build/webpack.base.conf')
 var utils = require('../../build/utils')
 var webpack = require('webpack')
-var projectRoot = path.resolve(__dirname, '../../')
+// var projectRoot = path.resolve(__dirname, '../../')
 
 var webpackConfig = merge(baseConfig, {
   // use inline sourcemap for karma-sourcemap-loader
diff --git a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
index 556049b8..4ec643e2 100644
--- a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
+++ b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js
@@ -163,12 +163,6 @@ const makeMockEmojiMasto = (overrides = [{}]) => {
   ]
 }
 
-parseNotification
-parseUser
-parseStatus
-makeMockStatusQvitter
-makeMockUserQvitter
-
 describe('API Entities normalizer', () => {
   describe('parseStatus', () => {
     describe('QVitter preprocessing', () => {