From 2c2b84d31dbe906b89dfb995394d887af110e04c Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 5 Jul 2019 10:02:14 +0300 Subject: [PATCH] npm eslint --fix . --- src/boot/routes.js | 4 +- src/components/attachment/attachment.js | 2 +- src/components/autosuggest/autosuggest.js | 4 +- src/components/chat_panel/chat_panel.js | 2 +- src/components/conversation/conversation.js | 8 +-- src/components/emoji-input/emoji-input.js | 2 +- .../favorite_button/favorite_button.js | 4 +- src/components/login_form/login_form.js | 4 +- src/components/media_upload/media_upload.js | 6 +- src/components/mfa_form/recovery_form.js | 2 +- src/components/mfa_form/totp_form.js | 2 +- .../mobile_post_status_modal.js | 4 +- .../moderation_tools/moderation_tools.js | 12 ++-- src/components/registration/registration.js | 4 +- .../retweet_button/retweet_button.js | 4 +- .../scope_selector/scope_selector.js | 8 +-- src/components/tab_switcher/tab_switcher.js | 48 ++++++------- src/components/timeline/timeline.js | 2 +- src/components/user_card/user_card.js | 14 ++-- src/components/user_settings/mfa.js | 2 +- src/components/user_settings/user_settings.js | 22 +++--- src/components/who_to_follow/who_to_follow.js | 2 +- .../who_to_follow_panel.js | 2 +- src/hocs/with_load_more/with_load_more.js | 56 +++++++-------- .../with_subscription/with_subscription.js | 68 +++++++++---------- src/modules/auth_flow.js | 4 +- src/modules/chat.js | 4 +- src/modules/config.js | 4 +- src/modules/errors.js | 1 - src/modules/instance.js | 2 +- src/modules/oauth_tokens.js | 4 +- src/modules/statuses.js | 8 +-- src/modules/users.js | 14 ++-- src/services/api/api.service.js | 2 +- src/services/color_convert/color_convert.js | 2 +- src/services/completion/completion.js | 2 +- .../file_size_format/file_size_format.js | 2 +- .../follow_request_fetcher.service.js | 2 +- src/services/new_api/mfa.js | 4 +- src/services/new_api/oauth.js | 4 +- src/services/new_api/user_search.js | 6 +- src/services/new_api/utils.js | 2 +- .../notification_utils/notification_utils.js | 2 +- .../notifications_fetcher.service.js | 6 +- .../status_poster/status_poster.service.js | 2 +- src/services/style_setter/style_setter.js | 12 ++-- .../timeline_fetcher.service.js | 10 +-- .../user_highlighter/user_highlighter.js | 2 +- test/e2e/nightwatch.conf.js | 54 +++++++-------- test/unit/karma.conf.js | 2 +- test/unit/specs/modules/statuses.spec.js | 58 ++++++++-------- test/unit/specs/modules/users.spec.js | 4 +- .../services/date_utils/date_utils.spec.js | 2 +- .../entity_normalizer.spec.js | 10 +-- .../file_size_format/file_size_format.spec.js | 66 +++++++++--------- .../status_parser/status_parses.spec.js | 4 +- 56 files changed, 294 insertions(+), 295 deletions(-) diff --git a/src/boot/routes.js b/src/boot/routes.js index 055a0aea5b..ca4a6a3ee1 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -24,8 +24,8 @@ export default (store) => { path: '/', redirect: _to => { return (store.state.users.currentUser - ? store.state.instance.redirectRootLogin - : store.state.instance.redirectRootNoLogin) || '/main/all' + ? store.state.instance.redirectRootLogin + : store.state.instance.redirectRootNoLogin) || '/main/all' } }, { name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline }, diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 3b7f08dcdb..e93921fe11 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -51,7 +51,7 @@ const Attachment = { } }, methods: { - linkClicked ({target}) { + linkClicked ({ target }) { if (target.tagName === 'A') { window.open(target.href, '_blank') } diff --git a/src/components/autosuggest/autosuggest.js b/src/components/autosuggest/autosuggest.js index d4efe912a7..f58f17bb6c 100644 --- a/src/components/autosuggest/autosuggest.js +++ b/src/components/autosuggest/autosuggest.js @@ -2,11 +2,11 @@ const debounceMilliseconds = 500 export default { props: { - query: { // function to query results and return a promise + query: { // function to query results and return a promise type: Function, required: true }, - filter: { // function to filter results in real time + filter: { // function to filter results in real time type: Function }, placeholder: { diff --git a/src/components/chat_panel/chat_panel.js b/src/components/chat_panel/chat_panel.js index bbc9b49fe5..f2e3adf097 100644 --- a/src/components/chat_panel/chat_panel.js +++ b/src/components/chat_panel/chat_panel.js @@ -16,7 +16,7 @@ const chatPanel = { }, methods: { submit (message) { - this.$store.state.chat.channel.push('new_msg', {text: message}, 10000) + this.$store.state.chat.channel.push('new_msg', { text: message }, 10000) this.currentMessage = '' }, togglePanel () { diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 8ae89421b8..cc0b0b4178 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -86,7 +86,7 @@ const conversation = { }, replies () { let i = 1 - return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => { + return reduce(this.conversation, (result, { id, in_reply_to_status_id }) => { /* eslint-disable camelcase */ const irid = in_reply_to_status_id /* eslint-enable camelcase */ @@ -119,15 +119,15 @@ const conversation = { methods: { fetchConversation () { if (this.status) { - this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id}) - .then(({ancestors, descendants}) => { + this.$store.state.api.backendInteractor.fetchConversation({ id: this.status.id }) + .then(({ ancestors, descendants }) => { this.$store.dispatch('addNewStatuses', { statuses: ancestors }) this.$store.dispatch('addNewStatuses', { statuses: descendants }) }) .then(() => this.setHighlight(this.statusId)) } else { const id = this.$route.params.id - this.$store.state.api.backendInteractor.fetchStatus({id}) + this.$store.state.api.backendInteractor.fetchStatus({ id }) .then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] })) .then(() => this.fetchConversation()) } diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js index b09dc628a3..fab64a6976 100644 --- a/src/components/emoji-input/emoji-input.js +++ b/src/components/emoji-input/emoji-input.js @@ -53,7 +53,7 @@ const EmojiInput = { required: true, type: String } - }, + }, data () { return { input: undefined, diff --git a/src/components/favorite_button/favorite_button.js b/src/components/favorite_button/favorite_button.js index a2b4cb656b..a24eacbf21 100644 --- a/src/components/favorite_button/favorite_button.js +++ b/src/components/favorite_button/favorite_button.js @@ -11,9 +11,9 @@ const FavoriteButton = { methods: { favorite () { if (!this.status.favorited) { - this.$store.dispatch('favorite', {id: this.status.id}) + this.$store.dispatch('favorite', { id: this.status.id }) } else { - this.$store.dispatch('unfavorite', {id: this.status.id}) + this.$store.dispatch('unfavorite', { id: this.status.id }) } this.animated = true setTimeout(() => { diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index 4a5b196557..10f52fe240 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -58,7 +58,7 @@ const LoginForm = { ).then((result) => { if (result.error) { if (result.error === 'mfa_required') { - this.requireMFA({app: app, settings: result}) + this.requireMFA({ app: app, settings: result }) } else { this.error = result.error this.focusOnPasswordInput() @@ -66,7 +66,7 @@ const LoginForm = { return } this.login(result).then(() => { - this.$router.push({name: 'friends'}) + this.$router.push({ name: 'friends' }) }) }) }) diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index e4b3d460e9..f457d0220b 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -16,7 +16,7 @@ const mediaUpload = { if (file.size > store.state.instance.uploadlimit) { const filesize = fileSizeFormatService.fileSizeFormat(file.size) const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit) - self.$emit('upload-failed', 'file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit}) + self.$emit('upload-failed', 'file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit }) return } const formData = new FormData() @@ -36,7 +36,7 @@ const mediaUpload = { }, fileDrop (e) { if (e.dataTransfer.files.length > 0) { - e.preventDefault() // allow dropping text like before + e.preventDefault() // allow dropping text like before this.uploadFile(e.dataTransfer.files[0]) } }, @@ -54,7 +54,7 @@ const mediaUpload = { this.uploadReady = true }) }, - change ({target}) { + change ({ target }) { for (var i = 0; i < target.files.length; i++) { let file = target.files[i] this.uploadFile(file) diff --git a/src/components/mfa_form/recovery_form.js b/src/components/mfa_form/recovery_form.js index fbe9b437a9..7a3cc22d51 100644 --- a/src/components/mfa_form/recovery_form.js +++ b/src/components/mfa_form/recovery_form.js @@ -33,7 +33,7 @@ export default { } this.login(result).then(() => { - this.$router.push({name: 'friends'}) + this.$router.push({ name: 'friends' }) }) }) } diff --git a/src/components/mfa_form/totp_form.js b/src/components/mfa_form/totp_form.js index 6c94fe52bf..778bf8dce1 100644 --- a/src/components/mfa_form/totp_form.js +++ b/src/components/mfa_form/totp_form.js @@ -32,7 +32,7 @@ export default { } this.login(result).then(() => { - this.$router.push({name: 'friends'}) + this.$router.push({ name: 'friends' }) }) }) } diff --git a/src/components/mobile_post_status_modal/mobile_post_status_modal.js b/src/components/mobile_post_status_modal/mobile_post_status_modal.js index 91b730e72a..3cec23c64f 100644 --- a/src/components/mobile_post_status_modal/mobile_post_status_modal.js +++ b/src/components/mobile_post_status_modal/mobile_post_status_modal.js @@ -96,12 +96,12 @@ const MobilePostStatusModal = { this.hidden = false } this.oldScrollPos = window.scrollY - }, 100, {leading: true, trailing: false}), + }, 100, { leading: true, trailing: false }), handleScrollEnd: debounce(function () { this.hidden = false this.oldScrollPos = window.scrollY - }, 100, {leading: false, trailing: true}) + }, 100, { leading: false, trailing: true }) } } diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js index 3eedeaa1b0..11de9f93e3 100644 --- a/src/components/moderation_tools/moderation_tools.js +++ b/src/components/moderation_tools/moderation_tools.js @@ -52,12 +52,12 @@ const ModerationTools = { if (this.tagsSet.has(tag)) { store.state.api.backendInteractor.untagUser(this.user, tag).then(response => { if (!response.ok) { return } - store.commit('untagUser', {user: this.user, tag}) + store.commit('untagUser', { user: this.user, tag }) }) } else { store.state.api.backendInteractor.tagUser(this.user, tag).then(response => { if (!response.ok) { return } - store.commit('tagUser', {user: this.user, tag}) + store.commit('tagUser', { user: this.user, tag }) }) } }, @@ -66,12 +66,12 @@ const ModerationTools = { if (this.user.rights[right]) { store.state.api.backendInteractor.deleteRight(this.user, right).then(response => { if (!response.ok) { return } - store.commit('updateRight', {user: this.user, right: right, value: false}) + store.commit('updateRight', { user: this.user, right: right, value: false }) }) } else { store.state.api.backendInteractor.addRight(this.user, right).then(response => { if (!response.ok) { return } - store.commit('updateRight', {user: this.user, right: right, value: true}) + store.commit('updateRight', { user: this.user, right: right, value: true }) }) } }, @@ -80,7 +80,7 @@ const ModerationTools = { const status = !!this.user.deactivated store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => { if (!response.ok) { return } - store.commit('updateActivationStatus', {user: this.user, status: status}) + store.commit('updateActivationStatus', { user: this.user, status: status }) }) }, deleteUserDialog (show) { @@ -89,7 +89,7 @@ const ModerationTools = { deleteUser () { const store = this.$store const user = this.user - const {id, name} = user + const { id, name } = user store.state.api.backendInteractor.deleteUser(user) .then(e => { this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id) diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index 8dc0042087..57f3caf015 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -28,7 +28,7 @@ const registration = { }, created () { if ((!this.registrationOpen && !this.token) || this.signedIn) { - this.$router.push({name: 'root'}) + this.$router.push({ name: 'root' }) } this.setCaptcha() @@ -61,7 +61,7 @@ const registration = { if (!this.$v.$invalid) { try { await this.signUp(this.user) - this.$router.push({name: 'friends'}) + this.$router.push({ name: 'friends' }) } catch (error) { console.warn('Registration failed: ' + error) } diff --git a/src/components/retweet_button/retweet_button.js b/src/components/retweet_button/retweet_button.js index eb4e4b412d..fb543a9c62 100644 --- a/src/components/retweet_button/retweet_button.js +++ b/src/components/retweet_button/retweet_button.js @@ -11,9 +11,9 @@ const RetweetButton = { methods: { retweet () { if (!this.status.repeated) { - this.$store.dispatch('retweet', {id: this.status.id}) + this.$store.dispatch('retweet', { id: this.status.id }) } else { - this.$store.dispatch('unretweet', {id: this.status.id}) + this.$store.dispatch('unretweet', { id: this.status.id }) } this.animated = true setTimeout(() => { diff --git a/src/components/scope_selector/scope_selector.js b/src/components/scope_selector/scope_selector.js index 8a42ee7bea..e9ccdefc34 100644 --- a/src/components/scope_selector/scope_selector.js +++ b/src/components/scope_selector/scope_selector.js @@ -29,10 +29,10 @@ const ScopeSelector = { }, css () { return { - public: {selected: this.currentScope === 'public'}, - unlisted: {selected: this.currentScope === 'unlisted'}, - private: {selected: this.currentScope === 'private'}, - direct: {selected: this.currentScope === 'direct'} + public: { selected: this.currentScope === 'public' }, + unlisted: { selected: this.currentScope === 'unlisted' }, + private: { selected: this.currentScope === 'private' }, + direct: { selected: this.currentScope === 'direct' } } } }, diff --git a/src/components/tab_switcher/tab_switcher.js b/src/components/tab_switcher/tab_switcher.js index c949b458cd..81e4d333ff 100644 --- a/src/components/tab_switcher/tab_switcher.js +++ b/src/components/tab_switcher/tab_switcher.js @@ -10,6 +10,12 @@ export default Vue.component('tab-switcher', { active: this.$slots.default.findIndex(_ => _.tag) } }, + beforeUpdate () { + const currentSlot = this.$slots.default[this.active] + if (!currentSlot.tag) { + this.active = this.$slots.default.findIndex(_ => _.tag) + } + }, methods: { activateTab (index, dataset) { return () => { @@ -20,34 +26,28 @@ export default Vue.component('tab-switcher', { } } }, - beforeUpdate () { - const currentSlot = this.$slots.default[this.active] - if (!currentSlot.tag) { - this.active = this.$slots.default.findIndex(_ => _.tag) - } - }, render (h) { const tabs = this.$slots.default - .map((slot, index) => { - if (!slot.tag) return - const classesTab = ['tab'] - const classesWrapper = ['tab-wrapper'] + .map((slot, index) => { + if (!slot.tag) return + const classesTab = ['tab'] + const classesWrapper = ['tab-wrapper'] - if (index === this.active) { - classesTab.push('active') - classesWrapper.push('active') - } + if (index === this.active) { + classesTab.push('active') + classesWrapper.push('active') + } - return ( -
- -
- ) - }) + return ( +
+ +
+ ) + }) const contents = this.$slots.default.map((slot, index) => { if (!slot.tag) return diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 9dafcbd8f4..791a8e45d9 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -139,7 +139,7 @@ const Timeline = { if (top < 15 && !this.paused && !(this.unfocused && this.$store.state.config.pauseOnUnfocused) - ) { + ) { this.showNewStatuses() } else { this.paused = true diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 7c6ffa8986..63dfa6ed83 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -23,15 +23,15 @@ export default { computed: { classes () { return [{ - 'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius - 'user-card-rounded': this.rounded === true, // set border-radius for all sides - 'user-card-bordered': this.bordered === true // set border for all sides + 'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius + 'user-card-rounded': this.rounded === true, // set border-radius for all sides + 'user-card-bordered': this.bordered === true // set border for all sides }] }, style () { const color = this.$store.state.config.customTheme.colors - ? this.$store.state.config.customTheme.colors.bg // v2 - : this.$store.state.config.colors.bg // v1 + ? this.$store.state.config.customTheme.colors.bg // v2 + : this.$store.state.config.colors.bg // v1 if (color) { const rgb = (typeof color === 'string') ? hex2rgb(color) : color @@ -110,7 +110,7 @@ export default { followUser () { const store = this.$store this.followRequestInProgress = true - requestFollow(this.user, store).then(({sent}) => { + requestFollow(this.user, store).then(({ sent }) => { this.followRequestInProgress = false this.followRequestSent = sent }) @@ -141,7 +141,7 @@ export default { store.commit('setProfileView', { v }) } }, - linkClicked ({target}) { + linkClicked ({ target }) { if (target.tagName === 'SPAN') { target = target.parentNode } diff --git a/src/components/user_settings/mfa.js b/src/components/user_settings/mfa.js index d44a3ab717..3090138a22 100644 --- a/src/components/user_settings/mfa.js +++ b/src/components/user_settings/mfa.js @@ -107,7 +107,7 @@ const Mfa = { this.setupState.setupOTPState = 'confirm' }) }, - doConfirmOTP () { // handler confirm enable OTP + doConfirmOTP () { // handler confirm enable OTP this.error = null this.backendInteractor.mfaConfirmOTP({ token: this.otpConfirmToken, diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index ced3efaa1e..19f4604f28 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -99,7 +99,7 @@ const UserSettings = { return suggestor({ emoji: [ ...this.$store.state.instance.emoji, ...this.$store.state.instance.customEmoji - ]}) + ] }) }, pleromaBackend () { return this.$store.state.instance.pleromaBackend @@ -144,10 +144,10 @@ const UserSettings = { hide_followers: this.hideFollowers, show_role: this.showRole /* eslint-enable camelcase */ - }}).then((user) => { - this.$store.commit('addNewUsers', [user]) - this.$store.commit('setCurrentUser', user) - }) + } }).then((user) => { + this.$store.commit('addNewUsers', [user]) + this.$store.commit('setCurrentUser', user) + }) }, updateNotificationSettings () { this.$store.state.api.backendInteractor @@ -162,12 +162,12 @@ const UserSettings = { if (file.size > this.$store.state.instance[slot + 'limit']) { const filesize = fileSizeFormatService.fileSizeFormat(file.size) const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit']) - this[slot + 'UploadError'] = this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit}) + this[slot + 'UploadError'] = this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit }) return } // eslint-disable-next-line no-undef const reader = new FileReader() - reader.onload = ({target}) => { + reader.onload = ({ target }) => { const img = target.result this[slot + 'Preview'] = img this[slot] = file @@ -203,7 +203,7 @@ const UserSettings = { if (!this.bannerPreview) { return } this.bannerUploading = true - this.$store.state.api.backendInteractor.updateBanner({banner: this.banner}) + this.$store.state.api.backendInteractor.updateBanner({ banner: this.banner }) .then((user) => { this.$store.commit('addNewUsers', [user]) this.$store.commit('setCurrentUser', user) @@ -269,11 +269,11 @@ const UserSettings = { this.deletingAccount = true }, deleteAccount () { - this.$store.state.api.backendInteractor.deleteAccount({password: this.deleteAccountConfirmPasswordInput}) + this.$store.state.api.backendInteractor.deleteAccount({ password: this.deleteAccountConfirmPasswordInput }) .then((res) => { if (res.status === 'success') { this.$store.dispatch('logout') - this.$router.push({name: 'root'}) + this.$router.push({ name: 'root' }) } else { this.deleteAccountError = res.error } @@ -322,7 +322,7 @@ const UserSettings = { }) }, queryUserIds (query) { - return userSearchApi.search({query, store: this.$store}) + return userSearchApi.search({ query, store: this.$store }) .then((users) => { this.$store.dispatch('addNewUsers', users) return map(users, 'id') diff --git a/src/components/who_to_follow/who_to_follow.js b/src/components/who_to_follow/who_to_follow.js index 7ae602a2fd..f8100257bf 100644 --- a/src/components/who_to_follow/who_to_follow.js +++ b/src/components/who_to_follow/who_to_follow.js @@ -37,7 +37,7 @@ const WhoToFollow = { getWhoToFollow () { const credentials = this.$store.state.users.currentUser.credentials if (credentials) { - apiService.suggestions({credentials: credentials}) + apiService.suggestions({ credentials: credentials }) .then((reply) => { this.showWhoToFollow(reply) }) diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js index a56a27eafa..7d01678b30 100644 --- a/src/components/who_to_follow_panel/who_to_follow_panel.js +++ b/src/components/who_to_follow_panel/who_to_follow_panel.js @@ -29,7 +29,7 @@ function getWhoToFollow (panel) { panel.usersToFollow.forEach(toFollow => { toFollow.name = 'Loading...' }) - apiService.suggestions({credentials: credentials}) + apiService.suggestions({ credentials: credentials }) .then((reply) => { showWhoToFollow(panel, reply) }) diff --git a/src/hocs/with_load_more/with_load_more.js b/src/hocs/with_load_more/with_load_more.js index 74979b8795..1e1b2a747b 100644 --- a/src/hocs/with_load_more/with_load_more.js +++ b/src/hocs/with_load_more/with_load_more.js @@ -4,39 +4,16 @@ import { getComponentProps } from '../../services/component_utils/component_util import './with_load_more.scss' const withLoadMore = ({ - fetch, // function to fetch entries and return a promise - select, // function to select data from store - destroy, // function called at "destroyed" lifecycle - childPropName = 'entries', // name of the prop to be passed into the wrapped component - additionalPropNames = [] // additional prop name list of the wrapper component + fetch, // function to fetch entries and return a promise + select, // function to select data from store + destroy, // function called at "destroyed" lifecycle + childPropName = 'entries', // name of the prop to be passed into the wrapped component + additionalPropNames = [] // additional prop name list of the wrapper component }) => (WrappedComponent) => { const originalProps = Object.keys(getComponentProps(WrappedComponent)) const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames) return Vue.component('withLoadMore', { - render (createElement) { - const props = { - props: { - ...this.$props, - [childPropName]: this.entries - }, - on: this.$listeners, - scopedSlots: this.$scopedSlots - } - const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value)) - return ( -
- - {children} - - -
- ) - }, props, data () { return { @@ -87,6 +64,29 @@ const withLoadMore = ({ this.fetchEntries() } } + }, + render (createElement) { + const props = { + props: { + ...this.$props, + [childPropName]: this.entries + }, + on: this.$listeners, + scopedSlots: this.$scopedSlots + } + const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value)) + return ( +
+ + {children} + + +
+ ) } }) } diff --git a/src/hocs/with_subscription/with_subscription.js b/src/hocs/with_subscription/with_subscription.js index 679409cf8b..91fc4ccaad 100644 --- a/src/hocs/with_subscription/with_subscription.js +++ b/src/hocs/with_subscription/with_subscription.js @@ -4,10 +4,10 @@ import { getComponentProps } from '../../services/component_utils/component_util import './with_subscription.scss' const withSubscription = ({ - fetch, // function to fetch entries and return a promise - select, // function to select data from store - childPropName = 'content', // name of the prop to be passed into the wrapped component - additionalPropNames = [] // additional prop name list of the wrapper component + fetch, // function to fetch entries and return a promise + select, // function to select data from store + childPropName = 'content', // name of the prop to be passed into the wrapped component + additionalPropNames = [] // additional prop name list of the wrapper component }) => (WrappedComponent) => { const originalProps = Object.keys(getComponentProps(WrappedComponent)) const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames) @@ -15,37 +15,8 @@ const withSubscription = ({ return Vue.component('withSubscription', { props: [ ...props, - 'refresh' // boolean saying to force-fetch data whenever created + 'refresh' // boolean saying to force-fetch data whenever created ], - render (createElement) { - if (!this.error && !this.loading) { - const props = { - props: { - ...this.$props, - [childPropName]: this.fetchedData - }, - on: this.$listeners, - scopedSlots: this.$scopedSlots - } - const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value)) - return ( -
- - {children} - -
- ) - } else { - return ( -
- {this.error - ? {this.$t('general.generic_error')} - : - } -
- ) - } - }, data () { return { loading: false, @@ -77,6 +48,35 @@ const withSubscription = ({ }) } } + }, + render (createElement) { + if (!this.error && !this.loading) { + const props = { + props: { + ...this.$props, + [childPropName]: this.fetchedData + }, + on: this.$listeners, + scopedSlots: this.$scopedSlots + } + const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value)) + return ( +
+ + {children} + +
+ ) + } else { + return ( +
+ {this.error + ? {this.$t('general.generic_error')} + : + } +
+ ) + } } }) } diff --git a/src/modules/auth_flow.js b/src/modules/auth_flow.js index 86328cf3f6..34e1505389 100644 --- a/src/modules/auth_flow.js +++ b/src/modules/auth_flow.js @@ -55,7 +55,7 @@ const mutations = { requireToken (state) { state.strategy = TOKEN_STRATEGY }, - requireMFA (state, {app, settings}) { + requireMFA (state, { app, settings }) { state.settings = settings state.app = app state.strategy = TOTP_STRATEGY // default strategy of MFA @@ -73,7 +73,7 @@ const mutations = { // actions const actions = { - async login ({state, dispatch, commit}, {access_token}) { + async login ({ state, dispatch, commit }, { access_token }) { commit('setToken', access_token, { root: true }) await dispatch('loginUser', access_token, { root: true }) resetState(state) diff --git a/src/modules/chat.js b/src/modules/chat.js index 4d8d669961..e1b03bca42 100644 --- a/src/modules/chat.js +++ b/src/modules/chat.js @@ -1,7 +1,7 @@ const chat = { state: { messages: [], - channel: {state: ''}, + channel: { state: '' }, socket: null }, mutations: { @@ -29,7 +29,7 @@ const chat = { channel.on('new_msg', (msg) => { store.commit('addMessage', msg) }) - channel.on('messages', ({messages}) => { + channel.on('messages', ({ messages }) => { store.commit('setMessages', messages) }) channel.join() diff --git a/src/modules/config.js b/src/modules/config.js index a8da525a01..2bfad8f6f4 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -56,10 +56,10 @@ const config = { }, actions: { setHighlight ({ commit, dispatch }, { user, color, type }) { - commit('setHighlight', {user, color, type}) + commit('setHighlight', { user, color, type }) }, setOption ({ commit, dispatch }, { name, value }) { - commit('setOption', {name, value}) + commit('setOption', { name, value }) switch (name) { case 'theme': setPreset(value, commit) diff --git a/src/modules/errors.js b/src/modules/errors.js index c809e1b5fb..ca89dc0fa8 100644 --- a/src/modules/errors.js +++ b/src/modules/errors.js @@ -9,4 +9,3 @@ export function humanizeErrors (errors) { return [...errs, message] }, []) } - diff --git a/src/modules/instance.js b/src/modules/instance.js index 22addb9b4d..93b56577ad 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -74,7 +74,7 @@ const instance = { }, actions: { setInstanceOption ({ commit, dispatch }, { name, value }) { - commit('setInstanceOption', {name, value}) + commit('setInstanceOption', { name, value }) switch (name) { case 'name': dispatch('setPageTitle') diff --git a/src/modules/oauth_tokens.js b/src/modules/oauth_tokens.js index 00ac143107..0159a3f11a 100644 --- a/src/modules/oauth_tokens.js +++ b/src/modules/oauth_tokens.js @@ -3,12 +3,12 @@ const oauthTokens = { tokens: [] }, actions: { - fetchTokens ({rootState, commit}) { + fetchTokens ({ rootState, commit }) { rootState.api.backendInteractor.fetchOAuthTokens().then((tokens) => { commit('swapTokens', tokens) }) }, - revokeToken ({rootState, commit, state}, id) { + revokeToken ({ rootState, commit, state }, id) { rootState.api.backendInteractor.revokeOAuthToken(id).then((response) => { if (response.status === 201) { commit('swapTokens', state.tokens.filter(token => token.id !== id)) diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 9b11a13e03..e00293c1df 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -80,13 +80,13 @@ const mergeOrAdd = (arr, obj, item) => { merge(oldItem, omitBy(item, (v, k) => v === null || k === 'user')) // Reactivity fix. oldItem.attachments.splice(oldItem.attachments.length) - return {item: oldItem, new: false} + return { item: oldItem, new: false } } else { // This is a new item, prepare it prepareStatus(item) arr.push(item) set(obj, item.id, item) - return {item, new: true} + return { item, new: true } } } @@ -137,7 +137,7 @@ const removeStatusFromGlobalStorage = (state, status) => { // TODO: Need to remove from allStatusesObject? // Remove possible notification - remove(state.notifications.data, ({action: {id}}) => id === status.id) + remove(state.notifications.data, ({ action: { id } }) => id === status.id) // Remove from conversation const conversationId = status.statusnet_conversation_id @@ -270,7 +270,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us }, 'deletion': (deletion) => { const uri = deletion.uri - const status = find(allStatuses, {uri}) + const status = find(allStatuses, { uri }) if (!status) { return } diff --git a/src/modules/users.js b/src/modules/users.js index 1e0b16f59d..3cd38d56b9 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -346,8 +346,8 @@ const users = { const notificationsObject = store.rootState.statuses.notifications.idStore const relevantNotifications = Object.entries(notificationsObject) - .filter(([k, val]) => notificationIds.includes(k)) - .map(([k, val]) => val) + .filter(([k, val]) => notificationIds.includes(k)) + .map(([k, val]) => val) // Reconnect users to notifications each(relevantNotifications, (notification) => { @@ -459,11 +459,11 @@ const users = { commit('endLogin') resolve() }) - .catch((error) => { - console.log(error) - commit('endLogin') - reject('Failed to connect to server, try again') - }) + .catch((error) => { + console.log(error) + commit('endLogin') + reject('Failed to connect to server, try again') + }) }) } } diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index d5fc418d66..22db671e8a 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -315,7 +315,7 @@ const exportFriends = ({ id, credentials }) => { let more = true while (more) { const maxId = friends.length > 0 ? last(friends).id : undefined - const users = await fetchFriends({id, maxId, credentials}) + const users = await fetchFriends({ id, maxId, credentials }) friends = concat(friends, users) if (users.length === 0) { more = false diff --git a/src/services/color_convert/color_convert.js b/src/services/color_convert/color_convert.js index 7576c51894..d1b17c61a2 100644 --- a/src/services/color_convert/color_convert.js +++ b/src/services/color_convert/color_convert.js @@ -59,7 +59,7 @@ const srgbToLinear = (srgb) => { * @returns {Number} relative luminance */ const relativeLuminance = (srgb) => { - const {r, g, b} = srgbToLinear(srgb) + const { r, g, b } = srgbToLinear(srgb) return 0.2126 * r + 0.7152 * g + 0.0722 * b } diff --git a/src/services/completion/completion.js b/src/services/completion/completion.js index 11c4586715..df83d03d14 100644 --- a/src/services/completion/completion.js +++ b/src/services/completion/completion.js @@ -8,7 +8,7 @@ export const wordAtPosition = (str, pos) => { const words = splitIntoWords(str) const wordsWithPosition = addPositionToWords(words) - return find(wordsWithPosition, ({start, end}) => start <= pos && end > pos) + return find(wordsWithPosition, ({ start, end }) => start <= pos && end > pos) } export const addPositionToWords = (words) => { diff --git a/src/services/file_size_format/file_size_format.js b/src/services/file_size_format/file_size_format.js index add56ee03e..7e6cd4d79c 100644 --- a/src/services/file_size_format/file_size_format.js +++ b/src/services/file_size_format/file_size_format.js @@ -9,7 +9,7 @@ const fileSizeFormat = (num) => { exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1) num = (num / Math.pow(1024, exponent)).toFixed(2) * 1 unit = units[exponent] - return {num: num, unit: unit} + return { num: num, unit: unit } } const fileSizeFormatService = { fileSizeFormat diff --git a/src/services/follow_request_fetcher/follow_request_fetcher.service.js b/src/services/follow_request_fetcher/follow_request_fetcher.service.js index 125ff3e1df..786740b7e2 100644 --- a/src/services/follow_request_fetcher/follow_request_fetcher.service.js +++ b/src/services/follow_request_fetcher/follow_request_fetcher.service.js @@ -8,7 +8,7 @@ const fetchAndUpdate = ({ store, credentials }) => { .catch(() => {}) } -const startFetching = ({credentials, store}) => { +const startFetching = ({ credentials, store }) => { fetchAndUpdate({ credentials, store }) const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) return setInterval(boundFetchAndUpdate, 10000) diff --git a/src/services/new_api/mfa.js b/src/services/new_api/mfa.js index ddf90e6b01..cbba06d54c 100644 --- a/src/services/new_api/mfa.js +++ b/src/services/new_api/mfa.js @@ -1,4 +1,4 @@ -const verifyOTPCode = ({app, instance, mfaToken, code}) => { +const verifyOTPCode = ({ app, instance, mfaToken, code }) => { const url = `${instance}/oauth/mfa/challenge` const form = new window.FormData() @@ -14,7 +14,7 @@ const verifyOTPCode = ({app, instance, mfaToken, code}) => { }).then((data) => data.json()) } -const verifyRecoveryCode = ({app, instance, mfaToken, code}) => { +const verifyRecoveryCode = ({ app, instance, mfaToken, code }) => { const url = `${instance}/oauth/mfa/challenge` const form = new window.FormData() diff --git a/src/services/new_api/oauth.js b/src/services/new_api/oauth.js index 030e998010..0767ccf8da 100644 --- a/src/services/new_api/oauth.js +++ b/src/services/new_api/oauth.js @@ -93,7 +93,7 @@ export const getClientToken = ({ clientId, clientSecret, instance }) => { body: form }).then((data) => data.json()) } -const verifyOTPCode = ({app, instance, mfaToken, code}) => { +const verifyOTPCode = ({ app, instance, mfaToken, code }) => { const url = `${instance}/oauth/mfa/challenge` const form = new window.FormData() @@ -109,7 +109,7 @@ const verifyOTPCode = ({app, instance, mfaToken, code}) => { }).then((data) => data.json()) } -const verifyRecoveryCode = ({app, instance, mfaToken, code}) => { +const verifyRecoveryCode = ({ app, instance, mfaToken, code }) => { const url = `${instance}/oauth/mfa/challenge` const form = new window.FormData() diff --git a/src/services/new_api/user_search.js b/src/services/new_api/user_search.js index c5a87cce3f..5936fef98e 100644 --- a/src/services/new_api/user_search.js +++ b/src/services/new_api/user_search.js @@ -1,7 +1,7 @@ import utils from './utils.js' import { parseUser } from '../entity_normalizer/entity_normalizer.service.js' -const search = ({query, store}) => { +const search = ({ query, store }) => { return utils.request({ store, url: '/api/v1/accounts/search', @@ -10,8 +10,8 @@ const search = ({query, store}) => { resolve: true } }) - .then((data) => data.json()) - .then((data) => data.map(parseUser)) + .then((data) => data.json()) + .then((data) => data.map(parseUser)) } const UserSearch = { search diff --git a/src/services/new_api/utils.js b/src/services/new_api/utils.js index 6696573b3b..571110268a 100644 --- a/src/services/new_api/utils.js +++ b/src/services/new_api/utils.js @@ -13,7 +13,7 @@ const headers = (store) => { } } -const request = ({method = 'GET', url, params, store}) => { +const request = ({ method = 'GET', url, params, store }) => { const instance = store.state.instance.server let fullUrl = `${instance}${url}` diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index f9cbbade25..7021adbdd2 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -35,4 +35,4 @@ export const visibleNotificationsFromStore = (store, types) => { } export const unseenNotificationsFromStore = store => - filter(visibleNotificationsFromStore(store), ({seen}) => !seen) + filter(visibleNotificationsFromStore(store), ({ seen }) => !seen) diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 60c497ae0c..f9ec3f6e99 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -1,12 +1,12 @@ import apiService from '../api/api.service.js' -const update = ({store, notifications, older}) => { +const update = ({ store, notifications, older }) => { store.dispatch('setNotificationsError', { value: false }) store.dispatch('addNewNotifications', { notifications, older }) } -const fetchAndUpdate = ({store, credentials, older = false}) => { +const fetchAndUpdate = ({ store, credentials, older = false }) => { const args = { credentials } const rootState = store.rootState || store.state const timelineData = rootState.statuses.notifications @@ -45,7 +45,7 @@ const fetchNotifications = ({ store, args, older }) => { .catch(() => store.dispatch('setNotificationsError', { value: true })) } -const startFetching = ({credentials, store}) => { +const startFetching = ({ credentials, store }) => { fetchAndUpdate({ credentials, store }) const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store }) // Initially there's set flag to silence all desktop notifications so diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js index 1efecf907a..9e904d3af0 100644 --- a/src/services/status_poster/status_poster.service.js +++ b/src/services/status_poster/status_poster.service.js @@ -13,7 +13,7 @@ const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, m mediaIds, inReplyToStatusId, contentType, - poll}) + poll }) .then((data) => { if (!data.error) { store.dispatch('addNewStatuses', { diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index d73106b83e..f186d2024e 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -239,12 +239,12 @@ const generateColors = (input) => { }) const htmlColors = Object.entries(colors) - .reduce((acc, [k, v]) => { - if (!v) return acc - acc.solid[k] = rgb2hex(v) - acc.complete[k] = typeof v.a === 'undefined' ? rgb2hex(v) : rgb2rgba(v) - return acc - }, { complete: {}, solid: {} }) + .reduce((acc, [k, v]) => { + if (!v) return acc + acc.solid[k] = rgb2hex(v) + acc.complete[k] = typeof v.a === 'undefined' ? rgb2hex(v) : rgb2rgba(v) + return acc + }, { complete: {}, solid: {} }) return { rules: { colors: Object.entries(htmlColors.complete) diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 8e954cdf4e..f72688f854 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -2,7 +2,7 @@ import { camelCase } from 'lodash' import apiService from '../api/api.service.js' -const update = ({store, statuses, timeline, showImmediately, userId}) => { +const update = ({ store, statuses, timeline, showImmediately, userId }) => { const ccTimeline = camelCase(timeline) store.dispatch('setError', { value: false }) @@ -15,7 +15,7 @@ const update = ({store, statuses, timeline, showImmediately, userId}) => { }) } -const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until}) => { +const fetchAndUpdate = ({ store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until }) => { const args = { timeline, credentials } const rootState = store.rootState || store.state const timelineData = rootState.statuses.timelines[camelCase(timeline)] @@ -40,17 +40,17 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) { store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId }) } - update({store, statuses, timeline, showImmediately, userId}) + update({ store, statuses, timeline, showImmediately, userId }) return statuses }, () => store.dispatch('setError', { value: true })) } -const startFetching = ({timeline = 'friends', credentials, store, userId = false, tag = false}) => { +const startFetching = ({ timeline = 'friends', credentials, store, userId = false, tag = false }) => { const rootState = store.rootState || store.state const timelineData = rootState.statuses.timelines[camelCase(timeline)] const showImmediately = timelineData.visibleStatuses.length === 0 timelineData.userId = userId - fetchAndUpdate({timeline, credentials, store, showImmediately, userId, tag}) + fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag }) const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag }) return setInterval(boundFetchAndUpdate, 10000) } diff --git a/src/services/user_highlighter/user_highlighter.js b/src/services/user_highlighter/user_highlighter.js index f6ddfb9c5e..b91c0f784d 100644 --- a/src/services/user_highlighter/user_highlighter.js +++ b/src/services/user_highlighter/user_highlighter.js @@ -1,7 +1,7 @@ import { hex2rgb } from '../color_convert/color_convert.js' const highlightStyle = (prefs) => { if (prefs === undefined) return - const {color, type} = prefs + const { color, type } = prefs if (typeof color !== 'string') return const rgb = hex2rgb(color) if (rgb == null) return diff --git a/test/e2e/nightwatch.conf.js b/test/e2e/nightwatch.conf.js index a5e55e908c..2fc3af0b56 100644 --- a/test/e2e/nightwatch.conf.js +++ b/test/e2e/nightwatch.conf.js @@ -3,43 +3,43 @@ var config = require('../../config') // http://nightwatchjs.org/guide#settings-file module.exports = { - "src_folders": ["test/e2e/specs"], - "output_folder": "test/e2e/reports", - "custom_assertions_path": ["test/e2e/custom-assertions"], + 'src_folders': ['test/e2e/specs'], + 'output_folder': 'test/e2e/reports', + 'custom_assertions_path': ['test/e2e/custom-assertions'], - "selenium": { - "start_process": true, - "server_path": "node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar", - "host": "127.0.0.1", - "port": 4444, - "cli_args": { - "webdriver.chrome.driver": require('chromedriver').path + 'selenium': { + 'start_process': true, + 'server_path': 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar', + 'host': '127.0.0.1', + 'port': 4444, + 'cli_args': { + 'webdriver.chrome.driver': require('chromedriver').path } }, - "test_settings": { - "default": { - "selenium_port": 4444, - "selenium_host": "localhost", - "silent": true, - "globals": { - "devServerURL": "http://localhost:" + (process.env.PORT || config.dev.port) + 'test_settings': { + 'default': { + 'selenium_port': 4444, + 'selenium_host': 'localhost', + 'silent': true, + 'globals': { + 'devServerURL': 'http://localhost:' + (process.env.PORT || config.dev.port) } }, - "chrome": { - "desiredCapabilities": { - "browserName": "chrome", - "javascriptEnabled": true, - "acceptSslCerts": true + 'chrome': { + 'desiredCapabilities': { + 'browserName': 'chrome', + 'javascriptEnabled': true, + 'acceptSslCerts': true } }, - "firefox": { - "desiredCapabilities": { - "browserName": "firefox", - "javascriptEnabled": true, - "acceptSslCerts": true + 'firefox': { + 'desiredCapabilities': { + 'browserName': 'firefox', + 'javascriptEnabled': true, + 'acceptSslCerts': true } } } diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js index 8465523a17..f9500ce894 100644 --- a/test/unit/karma.conf.js +++ b/test/unit/karma.conf.js @@ -60,7 +60,7 @@ module.exports = function (config) { 'FirefoxHeadless': { base: 'Firefox', flags: [ - '-headless', + '-headless' ] } }, diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js index 0bbcb25a3e..ba93138ff4 100644 --- a/test/unit/specs/modules/statuses.spec.js +++ b/test/unit/specs/modules/statuses.spec.js @@ -1,10 +1,10 @@ import { defaultState, mutations, prepareStatus } from '../../../../src/modules/statuses.js' // eslint-disable-next-line camelcase -const makeMockStatus = ({id, text, type = 'status'}) => { +const makeMockStatus = ({ id, text, type = 'status' }) => { return { id, - user: {id: '0'}, + user: { id: '0' }, name: 'status', text: text || `Text number ${id}`, fave_num: 0, @@ -17,7 +17,7 @@ const makeMockStatus = ({id, text, type = 'status'}) => { describe('Statuses module', () => { describe('prepareStatus', () => { it('sets deleted flag to false', () => { - const aStatus = makeMockStatus({id: '1', text: 'Hello oniichan'}) + const aStatus = makeMockStatus({ id: '1', text: 'Hello oniichan' }) expect(prepareStatus(aStatus).deleted).to.eq(false) }) }) @@ -25,7 +25,7 @@ describe('Statuses module', () => { describe('addNewStatuses', () => { it('adds the status to allStatuses and to the given timeline', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) + const status = makeMockStatus({ id: '1' }) mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' }) @@ -37,7 +37,7 @@ describe('Statuses module', () => { it('counts the status as new if it has not been seen on this timeline', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) + const status = makeMockStatus({ id: '1' }) mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' }) mutations.addNewStatuses(state, { statuses: [status], timeline: 'friends' }) @@ -55,7 +55,7 @@ describe('Statuses module', () => { it('add the statuses to allStatuses if no timeline is given', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) + const status = makeMockStatus({ id: '1' }) mutations.addNewStatuses(state, { statuses: [status] }) @@ -67,7 +67,7 @@ describe('Statuses module', () => { it('adds the status to allStatuses and to the given timeline, directly visible', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) + const status = makeMockStatus({ id: '1' }) mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' }) @@ -79,10 +79,10 @@ describe('Statuses module', () => { it('removes statuses by tag on deletion', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) - const otherStatus = makeMockStatus({id: '3'}) + const status = makeMockStatus({ id: '1' }) + const otherStatus = makeMockStatus({ id: '3' }) status.uri = 'xxx' - const deletion = makeMockStatus({id: '2', type: 'deletion'}) + const deletion = makeMockStatus({ id: '2', type: 'deletion' }) deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.' deletion.uri = 'xxx' @@ -97,8 +97,8 @@ describe('Statuses module', () => { it('does not update the maxId when the noIdUpdate flag is set', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) - const secondStatus = makeMockStatus({id: '2'}) + const status = makeMockStatus({ id: '1' }) + const secondStatus = makeMockStatus({ id: '2' }) mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' }) expect(state.timelines.public.maxId).to.eql('1') @@ -111,10 +111,10 @@ describe('Statuses module', () => { it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => { const state = defaultState() - const nonVisibleStatus = makeMockStatus({id: '1'}) - const status = makeMockStatus({id: '3'}) - const statusTwo = makeMockStatus({id: '2'}) - const statusThree = makeMockStatus({id: '4'}) + const nonVisibleStatus = makeMockStatus({ id: '1' }) + const status = makeMockStatus({ id: '3' }) + const statusTwo = makeMockStatus({ id: '2' }) + const statusThree = makeMockStatus({ id: '4' }) mutations.addNewStatuses(state, { statuses: [nonVisibleStatus], showImmediately: false, timeline: 'public' }) @@ -131,9 +131,9 @@ describe('Statuses module', () => { it('splits retweets from their status and links them', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) - const retweet = makeMockStatus({id: '2', type: 'retweet'}) - const modStatus = makeMockStatus({id: '1', text: 'something else'}) + const status = makeMockStatus({ id: '1' }) + const retweet = makeMockStatus({ id: '2', type: 'retweet' }) + const modStatus = makeMockStatus({ id: '1', text: 'something else' }) retweet.retweeted_status = status @@ -156,8 +156,8 @@ describe('Statuses module', () => { it('replaces existing statuses with the same id', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) - const modStatus = makeMockStatus({id: '1', text: 'something else'}) + const status = makeMockStatus({ id: '1' }) + const modStatus = makeMockStatus({ id: '1', text: 'something else' }) // Add original status mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' }) @@ -173,9 +173,9 @@ describe('Statuses module', () => { it('replaces existing statuses with the same id, coming from a retweet', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) - const modStatus = makeMockStatus({id: '1', text: 'something else'}) - const retweet = makeMockStatus({id: '2', type: 'retweet'}) + const status = makeMockStatus({ id: '1' }) + const modStatus = makeMockStatus({ id: '1', text: 'something else' }) + const retweet = makeMockStatus({ id: '2', type: 'retweet' }) retweet.retweeted_status = modStatus // Add original status @@ -194,7 +194,7 @@ describe('Statuses module', () => { it('handles favorite actions', () => { const state = defaultState() - const status = makeMockStatus({id: '1'}) + const status = makeMockStatus({ id: '1' }) const favorite = { id: '2', @@ -272,14 +272,14 @@ describe('Statuses module', () => { it('removes a notification when the notice gets removed', () => { const user = { id: '1' } const state = defaultState() - const status = makeMockStatus({id: '1'}) - const otherStatus = makeMockStatus({id: '3'}) - const mentionedStatus = makeMockStatus({id: '2'}) + const status = makeMockStatus({ id: '1' }) + const otherStatus = makeMockStatus({ id: '3' }) + const mentionedStatus = makeMockStatus({ id: '2' }) mentionedStatus.attentions = [user] mentionedStatus.uri = 'xxx' otherStatus.attentions = [user] - const deletion = makeMockStatus({id: '4', type: 'deletion'}) + const deletion = makeMockStatus({ id: '4', type: 'deletion' }) deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.' deletion.uri = 'xxx' diff --git a/test/unit/specs/modules/users.spec.js b/test/unit/specs/modules/users.spec.js index c8bc0ae7a5..eeb7afefe0 100644 --- a/test/unit/specs/modules/users.spec.js +++ b/test/unit/specs/modules/users.spec.js @@ -24,11 +24,11 @@ describe('The users module', () => { const user = { id: '1', name: 'Guy' } mutations.addNewUsers(state, [user]) - mutations.setMuted(state, {user, muted: true}) + mutations.setMuted(state, { user, muted: true }) expect(user.muted).to.eql(true) - mutations.setMuted(state, {user, muted: false}) + mutations.setMuted(state, { user, muted: false }) expect(user.muted).to.eql(false) }) diff --git a/test/unit/specs/services/date_utils/date_utils.spec.js b/test/unit/specs/services/date_utils/date_utils.spec.js index b94de76028..2d61dbacf4 100644 --- a/test/unit/specs/services/date_utils/date_utils.spec.js +++ b/test/unit/specs/services/date_utils/date_utils.spec.js @@ -37,4 +37,4 @@ describe('DateUtils', () => { expect(DateUtils.relativeTimeShort(time)).to.eql({ num: 2, key: 'time.years_short' }) }) }) -}) \ No newline at end of file +}) 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 3d34c5cc1e..556049b8c3 100644 --- a/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js +++ b/test/unit/specs/services/entity_normalizer/entity_normalizer.spec.js @@ -206,15 +206,15 @@ describe('API Entities normalizer', () => { }) it('sets nsfw for statuses with the #nsfw tag', () => { - const safe = makeMockStatusQvitter({id: '1', text: 'Hello oniichan'}) - const nsfw = makeMockStatusQvitter({id: '1', text: 'Hello oniichan #nsfw'}) + const safe = makeMockStatusQvitter({ id: '1', text: 'Hello oniichan' }) + const nsfw = makeMockStatusQvitter({ id: '1', text: 'Hello oniichan #nsfw' }) expect(parseStatus(safe).nsfw).to.eq(false) expect(parseStatus(nsfw).nsfw).to.eq(true) }) it('leaves existing nsfw settings alone', () => { - const nsfw = makeMockStatusQvitter({id: '1', text: 'Hello oniichan #nsfw', nsfw: false}) + const nsfw = makeMockStatusQvitter({ id: '1', text: 'Hello oniichan #nsfw', nsfw: false }) expect(parseStatus(nsfw).nsfw).to.eq(false) }) @@ -323,9 +323,9 @@ describe('API Entities normalizer', () => { describe('MastoAPI emoji adder', () => { const emojis = makeMockEmojiMasto() const imageHtml = 'image' - .replace(/"/g, '\'') + .replace(/"/g, '\'') const thinkHtml = 'thinking' - .replace(/"/g, '\'') + .replace(/"/g, '\'') it('correctly replaces shortcodes in supplied string', () => { const result = addEmojis('This post has :image: emoji and :thinking: emoji', emojis) diff --git a/test/unit/specs/services/file_size_format/file_size_format.spec.js b/test/unit/specs/services/file_size_format/file_size_format.spec.js index 0a5a82b7fc..e02ac37986 100644 --- a/test/unit/specs/services/file_size_format/file_size_format.spec.js +++ b/test/unit/specs/services/file_size_format/file_size_format.spec.js @@ -1,34 +1,34 @@ - import fileSizeFormatService from '../../../../../src/services/file_size_format/file_size_format.js' - describe('fileSizeFormat', () => { - it('Formats file size', () => { - const values = [1, 1024, 1048576, 1073741824, 1099511627776] - const expected = [ - { - num: 1, - unit: 'B' - }, - { - num: 1, - unit: 'KiB' - }, - { - num: 1, - unit: 'MiB' - }, - { - num: 1, - unit: 'GiB' - }, - { - num: 1, - unit: 'TiB' - } - ] +import fileSizeFormatService from '../../../../../src/services/file_size_format/file_size_format.js' +describe('fileSizeFormat', () => { + it('Formats file size', () => { + const values = [1, 1024, 1048576, 1073741824, 1099511627776] + const expected = [ + { + num: 1, + unit: 'B' + }, + { + num: 1, + unit: 'KiB' + }, + { + num: 1, + unit: 'MiB' + }, + { + num: 1, + unit: 'GiB' + }, + { + num: 1, + unit: 'TiB' + } + ] - var res = [] - for (var value in values) { - res.push(fileSizeFormatService.fileSizeFormat(values[value])) - } - expect(res).to.eql(expected) - }) - }) + var res = [] + for (var value in values) { + res.push(fileSizeFormatService.fileSizeFormat(values[value])) + } + expect(res).to.eql(expected) + }) +}) diff --git a/test/unit/specs/services/status_parser/status_parses.spec.js b/test/unit/specs/services/status_parser/status_parses.spec.js index 65808d84ef..7afd5042c8 100644 --- a/test/unit/specs/services/status_parser/status_parses.spec.js +++ b/test/unit/specs/services/status_parser/status_parses.spec.js @@ -1,7 +1,7 @@ -const example = '' - import { removeAttachmentLinks } from '../../../../../src/services/status_parser/status_parser.js' +const example = '' + describe('statusParser.removeAttachmentLinks', () => { const exampleWithoutAttachmentLinks = ''