diff --git a/webapp/components/Badges.vue b/webapp/components/Badges.vue index b28412abe..ff8a2bd35 100644 --- a/webapp/components/Badges.vue +++ b/webapp/components/Badges.vue @@ -23,14 +23,14 @@ import HcImage from './Image' export default { components: { - HcImage + HcImage, }, props: { badges: { type: Array, - default: () => [] - } - } + default: () => [], + }, + }, } diff --git a/webapp/components/Category/index.spec.js b/webapp/components/Category/index.spec.js index 149f96189..7ce0b7243 100644 --- a/webapp/components/Category/index.spec.js +++ b/webapp/components/Category/index.spec.js @@ -14,8 +14,8 @@ describe('Category', () => { localVue, propsData: { icon, - name - } + name, + }, }) } diff --git a/webapp/components/Category/index.vue b/webapp/components/Category/index.vue index 028d8c4a4..31c1aa97b 100644 --- a/webapp/components/Category/index.vue +++ b/webapp/components/Category/index.vue @@ -13,7 +13,7 @@ export default { name: 'HcCategory', props: { icon: { type: String, required: true }, - name: { type: String, default: '' } - } + name: { type: String, default: '' }, + }, } diff --git a/webapp/components/Comment.spec.js b/webapp/components/Comment.spec.js index 83a738956..6b5339ec2 100644 --- a/webapp/components/Comment.spec.js +++ b/webapp/components/Comment.spec.js @@ -1,6 +1,5 @@ -import { config, shallowMount, mount, createLocalVue } from '@vue/test-utils' +import { config, shallowMount, createLocalVue } from '@vue/test-utils' import Comment from './Comment.vue' -import Vue from 'vue' import Vuex from 'vuex' import Styleguide from '@human-connection/styleguide' @@ -12,8 +11,6 @@ localVue.use(Styleguide) config.stubs['no-ssr'] = '' describe('Comment.vue', () => { - let wrapper - let Wrapper let propsData let mocks let getters @@ -21,20 +18,20 @@ describe('Comment.vue', () => { beforeEach(() => { propsData = {} mocks = { - $t: jest.fn() + $t: jest.fn(), } getters = { 'auth/user': () => { return {} }, - 'auth/isModerator': () => false + 'auth/isModerator': () => false, } }) describe('shallowMount', () => { const Wrapper = () => { const store = new Vuex.Store({ - getters + getters, }) return shallowMount(Comment, { store, propsData, mocks, localVue }) } @@ -43,7 +40,7 @@ describe('Comment.vue', () => { beforeEach(() => { propsData.comment = { id: '2', - contentExcerpt: 'Hello I am a comment content' + contentExcerpt: 'Hello I am a comment content', } }) @@ -68,7 +65,6 @@ describe('Comment.vue', () => { }) it('translates a placeholder', () => { - const wrapper = Wrapper() const calls = mocks.$t.mock.calls const expected = [['comment.content.unavailable-placeholder']] expect(calls).toEqual(expect.arrayContaining(expected)) diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue index 13edc9c0d..dcad2a2ac 100644 --- a/webapp/components/Comment.vue +++ b/webapp/components/Comment.vue @@ -43,20 +43,20 @@ import ContentMenu from '~/components/ContentMenu' export default { components: { HcUser, - ContentMenu + ContentMenu, }, props: { comment: { type: Object, default() { return {} - } - } + }, + }, }, computed: { ...mapGetters({ user: 'auth/user', - isModerator: 'auth/isModerator' + isModerator: 'auth/isModerator', }), displaysComment() { return !this.unavailable || this.isModerator @@ -64,12 +64,12 @@ export default { author() { if (this.deleted) return {} return this.comment.author || {} - } + }, }, methods: { isAuthor(id) { return this.user.id === id - } - } + }, + }, } diff --git a/webapp/components/ContentMenu.vue b/webapp/components/ContentMenu.vue index 29473d6b2..a2e73b8af 100644 --- a/webapp/components/ContentMenu.vue +++ b/webapp/components/ContentMenu.vue @@ -48,7 +48,7 @@ import Dropdown from '~/components/Dropdown' export default { components: { - Dropdown + Dropdown, }, props: { placement: { type: String, default: 'top-end' }, @@ -59,8 +59,8 @@ export default { required: true, validator: value => { return value.match(/(contribution|comment|organization|user)/) - } - } + }, + }, }, computed: { routes() { @@ -72,17 +72,17 @@ export default { path: this.$router.resolve({ name: 'post-edit-id', params: { - id: this.resource.id - } + id: this.resource.id, + }, }).href, - icon: 'edit' + icon: 'edit', }) routes.push({ name: this.$t(`post.delete.title`), callback: () => { this.openModal('delete') }, - icon: 'trash' + icon: 'trash', }) } if (this.isOwner && this.resourceType === 'comment') { @@ -92,7 +92,7 @@ export default { /* eslint-disable-next-line no-console */ console.log('EDIT COMMENT') }, - icon: 'edit' + icon: 'edit', }) } @@ -102,7 +102,7 @@ export default { callback: () => { this.openModal('report') }, - icon: 'flag' + icon: 'flag', }) } @@ -112,7 +112,7 @@ export default { callback: () => { this.openModal('disable') }, - icon: 'eye-slash' + icon: 'eye-slash', }) } @@ -120,14 +120,14 @@ export default { routes.push({ name: this.$t(`settings.name`), path: '/settings', - icon: 'edit' + icon: 'edit', }) } return routes }, isModerator() { return this.$store.getters['auth/isModerator'] - } + }, }, methods: { openItem(route, toggleMenu) { @@ -143,11 +143,11 @@ export default { name: dialog, data: { type: this.resourceType, - resource: this.resource - } + resource: this.resource, + }, }) - } - } + }, + }, } diff --git a/webapp/components/ContributionForm/index.vue b/webapp/components/ContributionForm/index.vue index 6dc74f104..48ad99315 100644 --- a/webapp/components/ContributionForm/index.vue +++ b/webapp/components/ContributionForm/index.vue @@ -53,26 +53,26 @@ import HcEditor from '~/components/Editor' export default { components: { - HcEditor + HcEditor, }, props: { - contribution: { type: Object, default: () => {} } + contribution: { type: Object, default: () => {} }, }, data() { return { form: { title: '', - content: '' + content: '', }, formSchema: { title: { required: true, min: 3, max: 64 }, - content: { required: true, min: 3 } + content: { required: true, min: 3 }, }, id: null, loading: false, disabled: false, slug: null, - users: [] + users: [], } }, watch: { @@ -86,8 +86,8 @@ export default { this.slug = contribution.slug this.form.content = contribution.content this.form.title = contribution.title - } - } + }, + }, }, methods: { submit() { @@ -96,14 +96,12 @@ export default { this.$apollo .mutate({ - mutation: this.id - ? postMutations.UpdatePost - : postMutations.CreatePost, + mutation: this.id ? postMutations.UpdatePost : postMutations.CreatePost, variables: { id: this.id, title: this.form.title, - content: this.form.content - } + content: this.form.content, + }, }) .then(res => { this.loading = false @@ -114,7 +112,7 @@ export default { this.$router.push({ name: 'post-id-slug', - params: { id: result.id, slug: result.slug } + params: { id: result.id, slug: result.slug }, }) }) .catch(err => { @@ -126,7 +124,7 @@ export default { updateEditorContent(value) { // this.form.content = value this.$refs.contributionForm.update('content', value) - } + }, }, apollo: { User: { @@ -140,9 +138,9 @@ export default { }, result(result) { this.users = result.data.User - } - } - } + }, + }, + }, } diff --git a/webapp/components/CountTo.vue b/webapp/components/CountTo.vue index 3083040f5..89f3d5cf8 100644 --- a/webapp/components/CountTo.vue +++ b/webapp/components/CountTo.vue @@ -19,19 +19,19 @@ import CountTo from 'vue-count-to' export default { components: { - CountTo + CountTo, }, props: { startVal: { type: Number, default: 0 }, endVal: { type: Number, required: true }, duration: { type: Number, default: 3000 }, autoplay: { type: Boolean, default: true }, - separator: { type: String, default: '.' } + separator: { type: String, default: '.' }, }, data() { return { lastEndVal: null, - isReady: false + isReady: false, } }, watch: { @@ -39,12 +39,12 @@ export default { if (this.isReady && this.startVal === 0 && !this.lastEndVal) { this.lastEndVal = this.endVal } - } + }, }, mounted() { setTimeout(() => { this.isReady = true }, 500) - } + }, } diff --git a/webapp/components/Dropdown.vue b/webapp/components/Dropdown.vue index 1cfe84c2b..89b05aced 100644 --- a/webapp/components/Dropdown.vue +++ b/webapp/components/Dropdown.vue @@ -30,8 +30,6 @@ diff --git a/webapp/components/Editor/index.vue b/webapp/components/Editor/index.vue index 5b542b3ce..ac1391a42 100644 --- a/webapp/components/Editor/index.vue +++ b/webapp/components/Editor/index.vue @@ -166,12 +166,7 @@ import linkify from 'linkify-it' import stringHash from 'string-hash' import Fuse from 'fuse.js' import tippy from 'tippy.js' -import { - Editor, - EditorContent, - EditorFloatingMenu, - EditorMenuBubble -} from 'tiptap' +import { Editor, EditorContent, EditorFloatingMenu, EditorMenuBubble } from 'tiptap' import EventHandler from './plugins/eventHandler.js' import { Heading, @@ -187,7 +182,7 @@ import { Strike, Underline, Link, - History + History, } from 'tiptap-extensions' import Mention from './nodes/Mention.js' @@ -197,12 +192,12 @@ export default { components: { EditorContent, EditorFloatingMenu, - EditorMenuBubble + EditorMenuBubble, }, props: { users: { type: Array, default: () => [] }, value: { type: String, default: '' }, - doc: { type: Object, default: () => {} } + doc: { type: Object, default: () => {} }, }, data() { return { @@ -227,7 +222,7 @@ export default { new ListItem(), new Placeholder({ emptyNodeClass: 'is-empty', - emptyNodeText: this.$t('editor.placeholder') + emptyNodeText: this.$t('editor.placeholder'), }), new History(), new Mention({ @@ -290,16 +285,16 @@ export default { } const fuse = new Fuse(items, { threshold: 0.2, - keys: ['slug'] + keys: ['slug'], }) return fuse.search(query) - } - }) + }, + }), ], onUpdate: e => { clearTimeout(throttleInputEvent) throttleInputEvent = setTimeout(() => this.onUpdate(e), 300) - } + }, }), linkUrl: null, linkMenuIsActive: false, @@ -308,7 +303,7 @@ export default { filteredUsers: [], navigatedUserIndex: 0, insertMention: () => {}, - observer: null + observer: null, } }, computed: { @@ -317,7 +312,7 @@ export default { }, showSuggestions() { return this.query || this.hasResults - } + }, }, watch: { value: { @@ -329,8 +324,8 @@ export default { } this.lastValueHash = contentHash this.editor.setContent(content) - } - } + }, + }, }, beforeDestroy() { this.editor.destroy() @@ -340,14 +335,12 @@ export default { // if it's the first item, navigate to the last one upHandler() { this.navigatedUserIndex = - (this.navigatedUserIndex + this.filteredUsers.length - 1) % - this.filteredUsers.length + (this.navigatedUserIndex + this.filteredUsers.length - 1) % this.filteredUsers.length }, // navigate to the next item // if it's the last item, navigate to the first one downHandler() { - this.navigatedUserIndex = - (this.navigatedUserIndex + 1) % this.filteredUsers.length + this.navigatedUserIndex = (this.navigatedUserIndex + 1) % this.filteredUsers.length }, enterHandler() { const user = this.filteredUsers[this.navigatedUserIndex] @@ -363,8 +356,8 @@ export default { attrs: { // TODO: use router here url: `/profile/${user.id}`, - label: user.slug - } + label: user.slug, + }, }) this.editor.focus() }, @@ -384,7 +377,7 @@ export default { duration: [400, 200], showOnInit: true, arrow: true, - arrowType: 'round' + arrowType: 'round', }) // we have to update tippy whenever the DOM is updated if (MutationObserver) { @@ -394,7 +387,7 @@ export default { this.observer.observe(this.$refs.suggestions, { childList: true, subtree: true, - characterData: true + characterData: true, }) } }, @@ -440,7 +433,7 @@ export default { if (links) { // add valid link command({ - href: links.pop().url + href: links.pop().url, }) this.hideLinkMenu() this.editor.focus() @@ -451,8 +444,8 @@ export default { }, clear() { this.editor.clearContent(true) - } - } + }, + }, } diff --git a/webapp/components/Editor/nodes/Mention.js b/webapp/components/Editor/nodes/Mention.js index 134fdc64b..dc34a05ff 100644 --- a/webapp/components/Editor/nodes/Mention.js +++ b/webapp/components/Editor/nodes/Mention.js @@ -1,5 +1,3 @@ -import { Node } from 'tiptap' -import { replaceText } from 'tiptap-commands' import { Mention as TipTapMention } from 'tiptap-extensions' export default class Mention extends TipTapMention { @@ -8,7 +6,7 @@ export default class Mention extends TipTapMention { patchedSchema.attrs = { url: {}, - label: {} + label: {}, } patchedSchema.toDOM = node => { return [ @@ -16,9 +14,9 @@ export default class Mention extends TipTapMention { { class: this.options.mentionClass, href: node.attrs.url, - target: '_blank' + target: '_blank', }, - `${this.options.matcher.char}${node.attrs.label}` + `${this.options.matcher.char}${node.attrs.label}`, ] } patchedSchema.parseDOM = [ diff --git a/webapp/components/Editor/plugins/eventHandler.js b/webapp/components/Editor/plugins/eventHandler.js index 6086421b8..c390a066d 100644 --- a/webapp/components/Editor/plugins/eventHandler.js +++ b/webapp/components/Editor/plugins/eventHandler.js @@ -18,10 +18,7 @@ export default class EventHandler extends Extension { // remove all tags with "space only" .replace(/<[a-z-]+>[\s]+<\/[a-z-]+>/gim, '') // remove all iframes - .replace( - /(]*)(>)[^>]*\/*>/gim, - '' - ) + .replace(/(]*)(>)[^>]*\/*>/gim, '') .replace(/[\n]{3,}/gim, '\n\n') .replace(/(\r\n|\n\r|\r|\n)/g, '
$1') @@ -29,22 +26,16 @@ export default class EventHandler extends Extension { // limit linebreaks to max 2 (equivalent to html "br" linebreak) .replace(/(
\s*){2,}/gim, '
') // remove additional linebreaks after p tags - .replace( - /<\/(p|div|th|tr)>\s*(
\s*)+\s*<(p|div|th|tr)>/gim, - '

' - ) + .replace(/<\/(p|div|th|tr)>\s*(
\s*)+\s*<(p|div|th|tr)>/gim, '

') // remove additional linebreaks inside p tags - .replace( - /<[a-z-]+>(<[a-z-]+>)*\s*(
\s*)+\s*(<\/[a-z-]+>)*<\/[a-z-]+>/gim, - '' - ) + .replace(/<[a-z-]+>(<[a-z-]+>)*\s*(
\s*)+\s*(<\/[a-z-]+>)*<\/[a-z-]+>/gim, '') // remove additional linebreaks when first child inside p tags .replace(/

(\s*
\s*)+/gim, '

') // remove additional linebreaks when last child inside p tags .replace(/(\s*
\s*)+<\/p>/gim, '

') // console.log('#### transformPastedHTML', html) return html - } + }, // transformPasted(slice) { // // console.log('#### transformPasted', slice.content) // let content = [] @@ -76,8 +67,8 @@ export default class EventHandler extends Extension { // return slice // // return newSlice // } - } - }) + }, + }), ] } } diff --git a/webapp/components/Editor/spec.js b/webapp/components/Editor/spec.js index 3e1784ed7..249192b57 100644 --- a/webapp/components/Editor/spec.js +++ b/webapp/components/Editor/spec.js @@ -14,7 +14,7 @@ describe('Editor.vue', () => { beforeEach(() => { propsData = {} mocks = { - $t: () => {} + $t: () => {}, } }) @@ -25,7 +25,7 @@ describe('Editor.vue', () => { propsData, localVue, sync: false, - stubs: { transition: false } + stubs: { transition: false }, })) } @@ -40,9 +40,7 @@ describe('Editor.vue', () => { it.skip('renders', () => { wrapper = Wrapper() - expect(wrapper.find('.ProseMirror').text()).toContain( - 'I am a piece of text' - ) + expect(wrapper.find('.ProseMirror').text()).toContain('I am a piece of text') }) }) }) diff --git a/webapp/components/Empty.vue b/webapp/components/Empty.vue index 082d18f83..25deb9fd3 100644 --- a/webapp/components/Empty.vue +++ b/webapp/components/Empty.vue @@ -11,7 +11,7 @@ class="hc-empty-icon" style="margin-bottom: 5px" alt="Empty" - />
+ >
{ return value.match(/(messages|events|alert|tasks|docs|file)/) - } + }, }, /** * Message that appears under the icon */ message: { type: String, - default: null + default: null, }, /** * Vertical spacing */ margin: { type: [String, Object], - default: 'x-large' - } + default: 'x-large', + }, }, computed: { iconPath() { return `/img/empty/${this.icon}.svg` - } - } + }, + }, } diff --git a/webapp/components/FollowButton.vue b/webapp/components/FollowButton.vue index f5c705a8d..7372b8a78 100644 --- a/webapp/components/FollowButton.vue +++ b/webapp/components/FollowButton.vue @@ -22,13 +22,13 @@ export default { props: { followId: { type: String, default: null }, - isFollowed: { type: Boolean, default: false } + isFollowed: { type: Boolean, default: false }, }, data() { return { disabled: false, loading: false, - hovered: false + hovered: false, } }, computed: { @@ -45,13 +45,13 @@ export default { } else { return this.$t('followButton.follow') } - } + }, }, watch: { isFollowed() { this.loading = false this.hovered = false - } + }, }, methods: { onHover() { @@ -75,8 +75,8 @@ export default { } `, variables: { - id: this.followId - } + id: this.followId, + }, }) .then(res => { // this.$emit('optimistic', follow ? res.data.follow : follow) @@ -85,7 +85,7 @@ export default { .catch(() => { this.$emit('optimistic', !follow) }) - } - } + }, + }, } diff --git a/webapp/components/Image/index.vue b/webapp/components/Image/index.vue index e2f504578..9a4428b2e 100644 --- a/webapp/components/Image/index.vue +++ b/webapp/components/Image/index.vue @@ -10,14 +10,14 @@ export default { props: { imageProps: { type: Object, - required: true - } + required: true, + }, }, computed: { imageSrc() { const src = this.imageProps.src return src.startsWith('/') ? src.replace('/', '/api/') : src - } - } + }, + }, } diff --git a/webapp/components/Image/spec.js b/webapp/components/Image/spec.js index cbc4d34cf..be568964a 100644 --- a/webapp/components/Image/spec.js +++ b/webapp/components/Image/spec.js @@ -22,9 +22,7 @@ describe('Image', () => { }) it('adds a prefix to load the image from the backend', () => { - expect(Wrapper().attributes('src')).toBe( - '/api/img/badges/fundraisingbox_de_airship.svg' - ) + expect(Wrapper().attributes('src')).toBe('/api/img/badges/fundraisingbox_de_airship.svg') }) }) @@ -35,9 +33,7 @@ describe('Image', () => { it('keeps the URL as is', () => { // e.g. our seeds have absolute image URLs - expect(Wrapper().attributes('src')).toBe( - 'http://lorempixel.com/640/480/animals' - ) + expect(Wrapper().attributes('src')).toBe('http://lorempixel.com/640/480/animals') }) }) }) diff --git a/webapp/components/LoadMore.vue b/webapp/components/LoadMore.vue index dfe00a693..c2a3b6e83 100644 --- a/webapp/components/LoadMore.vue +++ b/webapp/components/LoadMore.vue @@ -17,7 +17,7 @@ diff --git a/webapp/components/LocaleSwitch.vue b/webapp/components/LocaleSwitch.vue index f69d107a9..a00f38109 100644 --- a/webapp/components/LocaleSwitch.vue +++ b/webapp/components/LocaleSwitch.vue @@ -49,15 +49,15 @@ import orderBy from 'lodash/orderBy' export default { components: { - Dropdown + Dropdown, }, props: { placement: { type: String, default: 'bottom-start' }, - offset: { type: [String, Number], default: '16' } + offset: { type: [String, Number], default: '16' }, }, data() { return { - locales: orderBy(process.env.locales, 'name') + locales: orderBy(process.env.locales, 'name'), } }, computed: { @@ -68,11 +68,11 @@ export default { let routes = this.locales.map(locale => { return { name: locale.name, - path: locale.code + path: locale.code, } }) return routes - } + }, }, methods: { changeLanguage(locale, toggleMenu) { @@ -81,8 +81,8 @@ export default { }, matcher(locale) { return locale === this.$i18n.locale() - } - } + }, + }, } diff --git a/webapp/components/Modal.spec.js b/webapp/components/Modal.spec.js index 1ec032edb..52d13c4a0 100644 --- a/webapp/components/Modal.spec.js +++ b/webapp/components/Modal.spec.js @@ -1,8 +1,7 @@ -import { shallowMount, mount, createLocalVue } from '@vue/test-utils' +import { shallowMount, createLocalVue } from '@vue/test-utils' import Modal from './Modal.vue' import DisableModal from './Modal/DisableModal.vue' import ReportModal from './Modal/ReportModal.vue' -import Vue from 'vue' import Vuex from 'vuex' import { getters, mutations } from '../store/modal' import Styleguide from '@human-connection/styleguide' @@ -13,7 +12,6 @@ localVue.use(Vuex) localVue.use(Styleguide) describe('Modal.vue', () => { - let Wrapper let wrapper let store let state @@ -25,11 +23,11 @@ describe('Modal.vue', () => { state, getters: { 'modal/open': getters.open, - 'modal/data': getters.data + 'modal/data': getters.data, }, mutations: { - 'modal/SET_OPEN': mutations.SET_OPEN - } + 'modal/SET_OPEN': mutations.SET_OPEN, + }, }) return mountMethod(Modal, { store, mocks, localVue }) } @@ -38,17 +36,17 @@ describe('Modal.vue', () => { beforeEach(() => { mocks = { $filters: { - truncate: a => a + truncate: a => a, }, $toast: { success: () => {}, - error: () => {} + error: () => {}, }, - $t: () => {} + $t: () => {}, } state = { open: null, - data: {} + data: {}, } }) @@ -69,9 +67,9 @@ describe('Modal.vue', () => { type: 'contribution', resource: { id: 'c456', - title: 'some title' - } - } + title: 'some title', + }, + }, } wrapper = Wrapper() }) @@ -84,7 +82,7 @@ describe('Modal.vue', () => { expect(wrapper.find(DisableModal).props()).toEqual({ type: 'contribution', name: 'some title', - id: 'c456' + id: 'c456', }) }) @@ -99,13 +97,13 @@ describe('Modal.vue', () => { it('passes author name to disable modal', () => { state.data = { type: 'comment', - resource: { id: 'c456', author: { name: 'Author name' } } + resource: { id: 'c456', author: { name: 'Author name' } }, } wrapper = Wrapper() expect(wrapper.find(DisableModal).props()).toEqual({ type: 'comment', name: 'Author name', - id: 'c456' + id: 'c456', }) }) @@ -115,7 +113,7 @@ describe('Modal.vue', () => { expect(wrapper.find(DisableModal).props()).toEqual({ type: 'comment', name: '', - id: 'c456' + id: 'c456', }) }) }) diff --git a/webapp/components/Modal.vue b/webapp/components/Modal.vue index 2ea482190..88b89d407 100644 --- a/webapp/components/Modal.vue +++ b/webapp/components/Modal.vue @@ -35,17 +35,17 @@ export default { components: { DisableModal, ReportModal, - DeleteModal + DeleteModal, }, computed: { ...mapGetters({ data: 'modal/data', - open: 'modal/open' + open: 'modal/open', }), name() { if (!this.data || !this.data.resource) return '' const { - resource: { name, title, author } + resource: { name, title, author }, } = this.data switch (this.data.type) { case 'user': @@ -57,12 +57,12 @@ export default { default: return null } - } + }, }, methods: { close() { this.$store.commit('modal/SET_OPEN', {}) - } - } + }, + }, } diff --git a/webapp/components/Modal/DeleteModal.spec.js b/webapp/components/Modal/DeleteModal.spec.js index e52c252ca..bb463be5f 100644 --- a/webapp/components/Modal/DeleteModal.spec.js +++ b/webapp/components/Modal/DeleteModal.spec.js @@ -1,6 +1,5 @@ import { shallowMount, mount, createLocalVue } from '@vue/test-utils' import DeleteModal from './DeleteModal.vue' -import Vue from 'vue' import Vuex from 'vuex' import Styleguide from '@human-connection/styleguide' import VueRouter from 'vue-router' @@ -15,27 +14,26 @@ localVue.use(VueRouter) describe('DeleteModal.vue', () => { let wrapper - let Wrapper let propsData let mocks beforeEach(() => { propsData = { type: 'contribution', - id: 'c300' + id: 'c300', } mocks = { $t: jest.fn(), $filters: { - truncate: a => a + truncate: a => a, }, $toast: { success: () => {}, - error: () => {} + error: () => {}, }, $apollo: { - mutate: jest.fn().mockResolvedValue() - } + mutate: jest.fn().mockResolvedValue(), + }, } }) @@ -59,7 +57,7 @@ describe('DeleteModal.vue', () => { propsData = { id: 'p23', type: 'post', - name: 'It is a post' + name: 'It is a post', } }) @@ -87,7 +85,7 @@ describe('DeleteModal.vue', () => { beforeEach(() => { propsData = { type: 'user', - id: 'u3' + id: 'u3', } wrapper = Wrapper() }) diff --git a/webapp/components/Modal/DeleteModal.vue b/webapp/components/Modal/DeleteModal.vue index 0f9fc0d7b..ccbb5a096 100644 --- a/webapp/components/Modal/DeleteModal.vue +++ b/webapp/components/Modal/DeleteModal.vue @@ -48,18 +48,18 @@ import { SweetalertIcon } from 'vue-sweetalert-icons' export default { name: 'DeleteModal', components: { - SweetalertIcon + SweetalertIcon, }, props: { name: { type: String, default: '' }, type: { type: String, required: true }, - id: { type: String, required: true } + id: { type: String, required: true }, }, data() { return { isOpen: true, success: false, - loading: false + loading: false, } }, computed: { @@ -69,7 +69,7 @@ export default { message() { const name = this.$filters.truncate(this.name, 30) return this.$t(`post.delete.message`, { name }) - } + }, }, methods: { async cancel() { @@ -89,7 +89,7 @@ export default { } } `, - variables: { id: this.id } + variables: { id: this.id }, }) this.success = true this.$toast.success(this.$t('post.delete.success')) @@ -113,8 +113,8 @@ export default { } finally { this.loading = false } - } - } + }, + }, } diff --git a/webapp/components/Modal/DisableModal.spec.js b/webapp/components/Modal/DisableModal.spec.js index e4debdc70..2d98fce52 100644 --- a/webapp/components/Modal/DisableModal.spec.js +++ b/webapp/components/Modal/DisableModal.spec.js @@ -1,6 +1,5 @@ import { shallowMount, mount, createLocalVue } from '@vue/test-utils' import DisableModal from './DisableModal.vue' -import Vue from 'vue' import Styleguide from '@human-connection/styleguide' const localVue = createLocalVue() @@ -8,7 +7,6 @@ const localVue = createLocalVue() localVue.use(Styleguide) describe('DisableModal.vue', () => { - let store let mocks let propsData let wrapper @@ -17,20 +15,20 @@ describe('DisableModal.vue', () => { propsData = { type: 'contribution', name: 'blah', - id: 'c42' + id: 'c42', } mocks = { $filters: { - truncate: a => a + truncate: a => a, }, $toast: { success: () => {}, - error: () => {} + error: () => {}, }, $t: jest.fn(), $apollo: { - mutate: jest.fn().mockResolvedValue() - } + mutate: jest.fn().mockResolvedValue(), + }, } }) @@ -44,7 +42,7 @@ describe('DisableModal.vue', () => { propsData = { type: 'user', id: 'u2', - name: 'Bob Ross' + name: 'Bob Ross', } }) @@ -61,16 +59,14 @@ describe('DisableModal.vue', () => { propsData = { type: 'contribution', id: 'c3', - name: 'This is some post title.' + name: 'This is some post title.', } }) it('mentions contribution title', () => { Wrapper() const calls = mocks.$t.mock.calls - const expected = [ - ['disable.contribution.message', { name: 'This is some post title.' }] - ] + const expected = [['disable.contribution.message', { name: 'This is some post title.' }]] expect(calls).toEqual(expect.arrayContaining(expected)) }) }) @@ -86,7 +82,7 @@ describe('DisableModal.vue', () => { beforeEach(() => { propsData = { type: 'user', - id: 'u4711' + id: 'u4711', } }) diff --git a/webapp/components/Modal/DisableModal.vue b/webapp/components/Modal/DisableModal.vue index 4ab0293cd..3a30cbce3 100644 --- a/webapp/components/Modal/DisableModal.vue +++ b/webapp/components/Modal/DisableModal.vue @@ -34,13 +34,13 @@ export default { props: { name: { type: String, default: '' }, type: { type: String, required: true }, - id: { type: String, required: true } + id: { type: String, required: true }, }, data() { return { isOpen: true, success: false, - loading: false + loading: false, } }, computed: { @@ -50,7 +50,7 @@ export default { message() { const name = this.$filters.truncate(this.name, 30) return this.$t(`disable.${this.type}.message`, { name }) - } + }, }, methods: { cancel() { @@ -67,7 +67,7 @@ export default { disable(id: $id) } `, - variables: { id: this.id } + variables: { id: this.id }, }) this.$toast.success(this.$t('disable.success')) this.isOpen = false @@ -77,7 +77,7 @@ export default { } catch (err) { this.$toast.error(err.message) } - } - } + }, + }, } diff --git a/webapp/components/Modal/ReportModal.spec.js b/webapp/components/Modal/ReportModal.spec.js index 865348512..c08788c3b 100644 --- a/webapp/components/Modal/ReportModal.spec.js +++ b/webapp/components/Modal/ReportModal.spec.js @@ -1,6 +1,5 @@ import { shallowMount, mount, createLocalVue } from '@vue/test-utils' import ReportModal from './ReportModal.vue' -import Vue from 'vue' import Vuex from 'vuex' import Styleguide from '@human-connection/styleguide' @@ -11,27 +10,26 @@ localVue.use(Styleguide) describe('ReportModal.vue', () => { let wrapper - let Wrapper let propsData let mocks beforeEach(() => { propsData = { type: 'contribution', - id: 'c43' + id: 'c43', } mocks = { $t: jest.fn(), $filters: { - truncate: a => a + truncate: a => a, }, $toast: { success: () => {}, - error: () => {} + error: () => {}, }, $apollo: { - mutate: jest.fn().mockResolvedValue() - } + mutate: jest.fn().mockResolvedValue(), + }, } }) @@ -55,7 +53,7 @@ describe('ReportModal.vue', () => { propsData = { type: 'user', id: 'u4', - name: 'Bob Ross' + name: 'Bob Ross', } }) @@ -72,7 +70,7 @@ describe('ReportModal.vue', () => { propsData = { id: 'p23', type: 'post', - name: 'It is a post' + name: 'It is a post', } }) @@ -100,7 +98,7 @@ describe('ReportModal.vue', () => { beforeEach(() => { propsData = { type: 'user', - id: 'u4711' + id: 'u4711', } wrapper = Wrapper() }) diff --git a/webapp/components/Modal/ReportModal.vue b/webapp/components/Modal/ReportModal.vue index 846fe5420..078707700 100644 --- a/webapp/components/Modal/ReportModal.vue +++ b/webapp/components/Modal/ReportModal.vue @@ -48,18 +48,18 @@ import { SweetalertIcon } from 'vue-sweetalert-icons' export default { name: 'ReportModal', components: { - SweetalertIcon + SweetalertIcon, }, props: { name: { type: String, default: '' }, type: { type: String, required: true }, - id: { type: String, required: true } + id: { type: String, required: true }, }, data() { return { isOpen: true, success: false, - loading: false + loading: false, } }, computed: { @@ -69,7 +69,7 @@ export default { message() { const name = this.$filters.truncate(this.name, 30) return this.$t(`report.${this.type}.message`, { name }) - } + }, }, methods: { async cancel() { @@ -89,7 +89,7 @@ export default { } } `, - variables: { id: this.id } + variables: { id: this.id }, }) this.success = true this.$toast.success(this.$t('report.success')) @@ -106,8 +106,8 @@ export default { } finally { this.loading = false } - } - } + }, + }, } diff --git a/webapp/components/Password/Change.spec.js b/webapp/components/Password/Change.spec.js index 77b7ee5b3..cffe86466 100644 --- a/webapp/components/Password/Change.spec.js +++ b/webapp/components/Password/Change.spec.js @@ -1,6 +1,5 @@ import { mount, createLocalVue } from '@vue/test-utils' import ChangePassword from './Change.vue' -import Vue from 'vue' import Styleguide from '@human-connection/styleguide' const localVue = createLocalVue() @@ -9,25 +8,24 @@ localVue.use(Styleguide) describe('ChangePassword.vue', () => { let mocks - let wrapper beforeEach(() => { mocks = { validate: jest.fn(), $toast: { error: jest.fn(), - success: jest.fn() + success: jest.fn(), }, $t: jest.fn(), $store: { - commit: jest.fn() + commit: jest.fn(), }, $apollo: { mutate: jest .fn() .mockRejectedValue({ message: 'Ouch!' }) - .mockResolvedValueOnce({ data: { changePassword: 'NEWTOKEN' } }) - } + .mockResolvedValueOnce({ data: { changePassword: 'NEWTOKEN' } }), + }, } }) @@ -63,9 +61,7 @@ describe('ChangePassword.vue', () => { it.skip('displays a warning', () => { const calls = mocks.validate.mock.calls - const expected = [ - ['change-password.validations.old-and-new-password-match'] - ] + const expected = [['change-password.validations.old-and-new-password-match']] expect(calls).toEqual(expect.arrayContaining(expected)) }) }) @@ -112,9 +108,9 @@ describe('ChangePassword.vue', () => { variables: { oldPassword: 'supersecret', newPassword: 'superdupersecret', - confirmPassword: 'superdupersecret' - } - }) + confirmPassword: 'superdupersecret', + }, + }), ) }) @@ -124,16 +120,11 @@ describe('ChangePassword.vue', () => { }) it('calls auth/SET_TOKEN with response', () => { - expect(mocks.$store.commit).toHaveBeenCalledWith( - 'auth/SET_TOKEN', - 'NEWTOKEN' - ) + expect(mocks.$store.commit).toHaveBeenCalledWith('auth/SET_TOKEN', 'NEWTOKEN') }) it('displays success message', () => { - expect(mocks.$t).toHaveBeenCalledWith( - 'settings.security.change-password.success' - ) + expect(mocks.$t).toHaveBeenCalledWith('settings.security.change-password.success') expect(mocks.$toast.success).toHaveBeenCalled() }) }) diff --git a/webapp/components/Password/Change.vue b/webapp/components/Password/Change.vue index 4998bbfb4..dd6626019 100644 --- a/webapp/components/Password/Change.vue +++ b/webapp/components/Password/Change.vue @@ -46,29 +46,25 @@ import PasswordStrength from './Strength' export default { name: 'ChangePassword', components: { - PasswordStrength + PasswordStrength, }, data() { return { formData: { oldPassword: '', newPassword: '', - confirmPassword: '' + confirmPassword: '', }, formSchema: { oldPassword: { type: 'string', required: true, - message: this.$t( - 'settings.security.change-password.message-old-password-required' - ) + message: this.$t('settings.security.change-password.message-old-password-required'), }, newPassword: { type: 'string', required: true, - message: this.$t( - 'settings.security.change-password.message-new-password-required' - ) + message: this.$t('settings.security.change-password.message-new-password-required'), }, confirmPassword: [ { validator: this.matchPassword }, @@ -76,13 +72,13 @@ export default { type: 'string', required: true, message: this.$t( - 'settings.security.change-password.message-new-password-confirm-required' - ) - } - ] + 'settings.security.change-password.message-new-password-confirm-required', + ), + }, + ], }, loading: false, - disabled: true + disabled: true, } }, methods: { @@ -104,13 +100,11 @@ export default { try { const { data } = await this.$apollo.mutate({ mutation, variables }) this.$store.commit('auth/SET_TOKEN', data.changePassword) - this.$toast.success( - this.$t('settings.security.change-password.success') - ) + this.$toast.success(this.$t('settings.security.change-password.success')) this.formData = { oldPassword: '', newPassword: '', - confirmPassword: '' + confirmPassword: '', } } catch (err) { this.$toast.error(err.message) @@ -122,15 +116,11 @@ export default { var errors = [] if (this.formData.newPassword !== value) { errors.push( - new Error( - this.$t( - 'settings.security.change-password.message-new-password-missmatch' - ) - ) + new Error(this.$t('settings.security.change-password.message-new-password-missmatch')), ) } callback(errors) - } - } + }, + }, } diff --git a/webapp/components/Password/Strength.vue b/webapp/components/Password/Strength.vue index 778cfb0d4..c6b8a09ab 100644 --- a/webapp/components/Password/Strength.vue +++ b/webapp/components/Password/Strength.vue @@ -28,14 +28,14 @@ export default { props: { password: { type: String, - required: true - } + required: true, + }, }, data() { return { strength: null, isSecure: false, - pass: this.password || null + pass: this.password || null, } }, watch: { @@ -50,11 +50,11 @@ export default { this.isSecure = Boolean(strength >= 3) this.$emit('change', { strength, - isSecure: this.isSecure + isSecure: this.isSecure, }) } - } - } + }, + }, } diff --git a/webapp/components/PostCard/index.vue b/webapp/components/PostCard/index.vue index cde334bfd..d3ede45eb 100644 --- a/webapp/components/PostCard/index.vue +++ b/webapp/components/PostCard/index.vue @@ -89,17 +89,17 @@ export default { HcUser, HcCategory, HcRibbon, - ContentMenu + ContentMenu, }, props: { post: { type: Object, - required: true - } + required: true, + }, }, computed: { ...mapGetters({ - user: 'auth/user' + user: 'auth/user', }), excerpt() { return this.$filters.removeLinks(this.post.contentExcerpt) @@ -108,8 +108,8 @@ export default { const { author } = this.post if (!author) return false return this.user.id === this.post.author.id - } - } + }, + }, } diff --git a/webapp/components/PostCard/spec.js b/webapp/components/PostCard/spec.js index 1914733c0..8f818b26b 100644 --- a/webapp/components/PostCard/spec.js +++ b/webapp/components/PostCard/spec.js @@ -14,7 +14,6 @@ config.stubs['no-ssr'] = '' config.stubs['v-popover'] = '' describe('PostCard', () => { - let wrapper let stubs let mocks let propsData @@ -23,35 +22,35 @@ describe('PostCard', () => { beforeEach(() => { propsData = {} stubs = { - NuxtLink: RouterLinkStub + NuxtLink: RouterLinkStub, } mocks = { - $t: jest.fn() + $t: jest.fn(), } getters = { 'auth/user': () => { return {} - } + }, } }) const Wrapper = () => { const store = new Vuex.Store({ - getters + getters, }) return mount(PostCard, { stubs, mocks, propsData, store, - localVue + localVue, }) } describe('given a post', () => { beforeEach(() => { propsData.post = { - title: "It's a title" + title: "It's a title", } }) diff --git a/webapp/components/RelativeDateTime/index.vue b/webapp/components/RelativeDateTime/index.vue index 1f9ca2bda..a6187425f 100644 --- a/webapp/components/RelativeDateTime/index.vue +++ b/webapp/components/RelativeDateTime/index.vue @@ -4,14 +4,14 @@ diff --git a/webapp/components/RelativeDateTime/spec.js b/webapp/components/RelativeDateTime/spec.js index 446a5a8a1..15574f539 100644 --- a/webapp/components/RelativeDateTime/spec.js +++ b/webapp/components/RelativeDateTime/spec.js @@ -4,7 +4,6 @@ import RelativeDateTime from './' const localVue = createLocalVue() describe('RelativeDateTime', () => { - let wrapper let mocks let locale let dateTime @@ -12,8 +11,8 @@ describe('RelativeDateTime', () => { beforeEach(() => { mocks = { $i18n: { - locale: () => locale - } + locale: () => locale, + }, } }) @@ -22,8 +21,8 @@ describe('RelativeDateTime', () => { mocks, localVue, propsData: { - dateTime - } + dateTime, + }, }) } diff --git a/webapp/components/Ribbon/index.spec.js b/webapp/components/Ribbon/index.spec.js index 8c6507e88..b1c519992 100644 --- a/webapp/components/Ribbon/index.spec.js +++ b/webapp/components/Ribbon/index.spec.js @@ -10,8 +10,8 @@ describe('Ribbon', () => { return shallowMount(Ribbon, { localVue, propsData: { - text - } + text, + }, }) } diff --git a/webapp/components/Ribbon/index.vue b/webapp/components/Ribbon/index.vue index 783bf974f..c92935352 100644 --- a/webapp/components/Ribbon/index.vue +++ b/webapp/components/Ribbon/index.vue @@ -10,9 +10,9 @@ export default { props: { text: { type: String, - default: '' - } - } + default: '', + }, + }, } @@ -43,8 +43,7 @@ export default { bottom: -6px; border-width: 3px 4px 3px 3px; border-style: solid; - border-color: $background-color-secondary transparent transparent - $background-color-secondary; + border-color: $background-color-secondary transparent transparent $background-color-secondary; } } diff --git a/webapp/components/SearchInput.spec.js b/webapp/components/SearchInput.spec.js index 2f3f31987..bf44b906b 100644 --- a/webapp/components/SearchInput.spec.js +++ b/webapp/components/SearchInput.spec.js @@ -10,7 +10,6 @@ localVue.filter('truncate', () => 'truncated string') localVue.filter('dateTime', () => Date.now) describe('SearchInput.vue', () => { - let wrapper let mocks let propsData @@ -21,7 +20,7 @@ describe('SearchInput.vue', () => { describe('mount', () => { const Wrapper = () => { mocks = { - $t: () => {} + $t: () => {}, } return mount(SearchInput, { mocks, localVue, propsData }) } @@ -121,7 +120,7 @@ describe('SearchInput.vue', () => { __typename: 'User', id: 'u5', name: 'Trick', - slug: 'trick' + slug: 'trick', }, commentsCount: 0, createdAt: '2019-03-13T11:00:20.835Z', @@ -129,9 +128,9 @@ describe('SearchInput.vue', () => { label: 'Eos aut illo omnis quis eaque et iure aut.', shoutedCount: 0, slug: 'eos-aut-illo-omnis-quis-eaque-et-iure-aut', - value: 'Eos aut illo omnis quis eaque et iure aut.' - } - ] + value: 'Eos aut illo omnis quis eaque et iure aut.', + }, + ], } wrapper = Wrapper() select.trigger('input') diff --git a/webapp/components/SearchInput.vue b/webapp/components/SearchInput.vue index 7ce174a9a..33c938656 100644 --- a/webapp/components/SearchInput.vue +++ b/webapp/components/SearchInput.vue @@ -98,24 +98,24 @@ export default { props: { id: { type: String, - default: 'nav-search' + default: 'nav-search', }, value: { type: String, - default: '' + default: '', }, results: { type: Array, - default: () => [] + default: () => [], }, delay: { type: Number, - default: 300 + default: 300, }, pending: { type: Boolean, - default: false - } + default: false, + }, }, data() { return { @@ -123,7 +123,7 @@ export default { isOpen: false, lastSearchTerm: '', unprocessedSearchInput: '', - searchValue: '' + searchValue: '', } }, computed: { @@ -132,10 +132,8 @@ export default { return !isEmpty(this.lastSearchTerm) }, emptyText() { - return this.isActive && !this.pending - ? this.$t('search.failed') - : this.$t('search.hint') - } + return this.isActive && !this.pending ? this.$t('search.failed') : this.$t('search.hint') + }, }, methods: { async query(value) { @@ -201,8 +199,8 @@ export default { this.unprocessedSearchInput = '' this.lastSearchTerm = '' this.searchValue = '' - } - } + }, + }, } diff --git a/webapp/components/ShoutButton.vue b/webapp/components/ShoutButton.vue index 02d7cb639..4486abf8e 100644 --- a/webapp/components/ShoutButton.vue +++ b/webapp/components/ShoutButton.vue @@ -35,13 +35,13 @@ export default { count: { type: Number, default: 0 }, postId: { type: String, default: null }, isShouted: { type: Boolean, default: false }, - disabled: { type: Boolean, default: false } + disabled: { type: Boolean, default: false }, }, data() { return { loading: false, shoutedCount: this.count, - shouted: false + shouted: false, } }, watch: { @@ -49,8 +49,8 @@ export default { immediate: true, handler: function(shouted) { this.shouted = shouted - } - } + }, + }, }, methods: { toggle() { @@ -60,7 +60,7 @@ export default { const backup = { shoutedCount: this.shoutedCount, - shouted: this.shouted + shouted: this.shouted, } this.shoutedCount = count @@ -74,8 +74,8 @@ export default { } `, variables: { - id: this.postId - } + id: this.postId, + }, }) .then(res => { if (res && res.data) { @@ -89,8 +89,8 @@ export default { .finally(() => { this.loading = false }) - } - } + }, + }, } diff --git a/webapp/components/Tag/index.vue b/webapp/components/Tag/index.vue index 70e1cf2a2..9337c02a6 100644 --- a/webapp/components/Tag/index.vue +++ b/webapp/components/Tag/index.vue @@ -9,7 +9,7 @@ export default { name: 'HcTag', props: { - name: { type: String, required: true } - } + name: { type: String, required: true }, + }, } diff --git a/webapp/components/Tag/spec.js b/webapp/components/Tag/spec.js index fa49d4d95..6a82ce641 100644 --- a/webapp/components/Tag/spec.js +++ b/webapp/components/Tag/spec.js @@ -12,8 +12,8 @@ describe('Tag', () => { return shallowMount(Tag, { localVue, propsData: { - name - } + name, + }, }) } diff --git a/webapp/components/User/index.vue b/webapp/components/User/index.vue index 105a79f8c..82a08c5e1 100644 --- a/webapp/components/User/index.vue +++ b/webapp/components/User/index.vue @@ -151,16 +151,16 @@ export default { HcRelativeDateTime, HcFollowButton, HcBadges, - Dropdown + Dropdown, }, props: { user: { type: Object, default: null }, trunc: { type: Number, default: null }, - dateTime: { type: [Date, String], default: null } + dateTime: { type: [Date, String], default: null }, }, computed: { ...mapGetters({ - isModerator: 'auth/isModerator' + isModerator: 'auth/isModerator', }), itsMe() { return this.user.slug === this.$store.getters['auth/user'].slug @@ -177,8 +177,8 @@ export default { userName() { const { name } = this.user || {} return name || this.$t('profile.userAnonym') - } - } + }, + }, } diff --git a/webapp/components/User/spec.js b/webapp/components/User/spec.js index 4bc286d20..56bdc10f1 100644 --- a/webapp/components/User/spec.js +++ b/webapp/components/User/spec.js @@ -1,6 +1,5 @@ -import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' +import { mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' import User from './index' -import Vue from 'vue' import Vuex from 'vuex' import VTooltip from 'v-tooltip' @@ -16,35 +15,32 @@ localVue.use(Styleguide) localVue.filter('truncate', filter) describe('User', () => { - let wrapper - let Wrapper let propsData let mocks let stubs let getters - let user beforeEach(() => { propsData = {} mocks = { - $t: jest.fn() + $t: jest.fn(), } stubs = { - NuxtLink: RouterLinkStub + NuxtLink: RouterLinkStub, } getters = { 'auth/user': () => { return {} }, - 'auth/isModerator': () => false + 'auth/isModerator': () => false, } }) describe('mount', () => { const Wrapper = () => { const store = new Vuex.Store({ - getters + getters, }) return mount(User, { store, propsData, mocks, stubs, localVue }) } @@ -59,7 +55,7 @@ describe('User', () => { beforeEach(() => { propsData.user = { name: 'Tilda Swinton', - slug: 'tilda-swinton' + slug: 'tilda-swinton', } }) diff --git a/webapp/components/comments/CommentForm/index.vue b/webapp/components/comments/CommentForm/index.vue index fedd8a884..05ab2356e 100644 --- a/webapp/components/comments/CommentForm/index.vue +++ b/webapp/components/comments/CommentForm/index.vue @@ -48,20 +48,20 @@ import HcEditor from '~/components/Editor' export default { components: { - HcEditor + HcEditor, }, props: { post: { type: Object, default: () => {} }, - comments: { type: Array, default: () => [] } + comments: { type: Array, default: () => [] }, }, data() { return { disabled: true, loading: false, form: { - content: '' + content: '', }, - users: [] + users: [], } }, methods: { @@ -92,8 +92,8 @@ export default { `, variables: { postId: this.post.id, - content: this.form.content - } + content: this.form.content, + }, }) .then(res => { this.loading = false @@ -105,7 +105,7 @@ export default { .catch(err => { this.$toast.error(err.message) }) - } + }, }, apollo: { User: { @@ -119,8 +119,8 @@ export default { }, result(result) { this.users = result.data.User - } - } - } + }, + }, + }, } diff --git a/webapp/components/comments/CommentForm/spec.js b/webapp/components/comments/CommentForm/spec.js index 511f76c1d..0259e7101 100644 --- a/webapp/components/comments/CommentForm/spec.js +++ b/webapp/components/comments/CommentForm/spec.js @@ -1,6 +1,5 @@ import { config, mount, createLocalVue, createWrapper } from '@vue/test-utils' import CommentForm from './index.vue' -import Vue from 'vue' import Styleguide from '@human-connection/styleguide' const localVue = createLocalVue() @@ -17,24 +16,24 @@ describe('CommentForm.vue', () => { let cancelMethodSpy beforeEach(() => { - ;(mocks = { + mocks = { $t: jest.fn(), $apollo: { mutate: jest .fn() .mockResolvedValueOnce({ - data: { CreateComment: { contentExcerpt: 'this is a comment' } } + data: { CreateComment: { contentExcerpt: 'this is a comment' } }, }) - .mockRejectedValue({ message: 'Ouch!' }) + .mockRejectedValue({ message: 'Ouch!' }), }, $toast: { error: jest.fn(), - success: jest.fn() - } - }), - (propsData = { - post: { id: 1 } - }) + success: jest.fn(), + }, + } + propsData = { + post: { id: 1 }, + } }) describe('mount', () => { diff --git a/webapp/components/comments/CommentList/CommentList.spec.js b/webapp/components/comments/CommentList/CommentList.spec.js index 6a96f3e19..55a75fbb2 100644 --- a/webapp/components/comments/CommentList/CommentList.spec.js +++ b/webapp/components/comments/CommentList/CommentList.spec.js @@ -1,9 +1,7 @@ import { config, mount, createLocalVue } from '@vue/test-utils' import CommentList from '.' import Empty from '~/components/Empty' -import Vue from 'vue' import Vuex from 'vuex' -import Filters from '~/plugins/vue-filters' import Styleguide from '@human-connection/styleguide' const localVue = createLocalVue() @@ -24,21 +22,21 @@ describe('CommentList.vue', () => { let data propsData = { - post: { id: 1 } + post: { id: 1 }, } store = new Vuex.Store({ getters: { 'auth/user': () => { return {} - } - } + }, + }, }) mocks = { - $t: jest.fn() + $t: jest.fn(), } data = () => { return { - comments: [] + comments: [], } } @@ -50,7 +48,7 @@ describe('CommentList.vue', () => { beforeEach(() => { wrapper = Wrapper() wrapper.setData({ - comments: [{ id: 'c1', contentExcerpt: 'this is a comment' }] + comments: [{ id: 'c1', contentExcerpt: 'this is a comment' }], }) }) diff --git a/webapp/components/comments/CommentList/index.vue b/webapp/components/comments/CommentList/index.vue index 57b720087..3ea4337ba 100644 --- a/webapp/components/comments/CommentList/index.vue +++ b/webapp/components/comments/CommentList/index.vue @@ -38,20 +38,20 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { Comment, - HcEmpty + HcEmpty, }, props: { - post: { type: Object, default: () => {} } + post: { type: Object, default: () => {} }, }, data() { return { - comments: [] + comments: [], } }, watch: { Post(post) { this.comments = post[0].comments || [] - } + }, }, mounted() { this.$root.$on('refetchPostComments', comment => { @@ -61,7 +61,7 @@ export default { methods: { refetchPostComments(comment) { this.$apollo.queries.Post.refetch() - } + }, }, apollo: { Post: { @@ -70,11 +70,11 @@ export default { }, variables() { return { - slug: this.post.slug + slug: this.post.slug, } }, - fetchPolicy: 'cache-and-network' - } - } + fetchPolicy: 'cache-and-network', + }, + }, } diff --git a/webapp/components/notifications/Notification/index.vue b/webapp/components/notifications/Notification/index.vue index cae34a2f1..3e69dc415 100644 --- a/webapp/components/notifications/Notification/index.vue +++ b/webapp/components/notifications/Notification/index.vue @@ -44,13 +44,13 @@ import HcUser from '~/components/User' export default { name: 'Notification', components: { - HcUser + HcUser, }, props: { notification: { type: Object, - required: true - } + required: true, + }, }, computed: { excerpt() { @@ -58,8 +58,8 @@ export default { }, post() { return this.notification.post || {} - } - } + }, + }, } diff --git a/webapp/components/notifications/Notification/spec.js b/webapp/components/notifications/Notification/spec.js index 8c6c846a4..6a380b9de 100644 --- a/webapp/components/notifications/Notification/spec.js +++ b/webapp/components/notifications/Notification/spec.js @@ -11,17 +11,16 @@ localVue.use(Filters) config.stubs['no-ssr'] = '' describe('Notification', () => { - let wrapper let stubs let mocks let propsData beforeEach(() => { propsData = {} mocks = { - $t: jest.fn() + $t: jest.fn(), } stubs = { - NuxtLink: RouterLinkStub + NuxtLink: RouterLinkStub, } }) @@ -30,7 +29,7 @@ describe('Notification', () => { stubs, mocks, propsData, - localVue + localVue, }) } @@ -38,8 +37,8 @@ describe('Notification', () => { beforeEach(() => { propsData.notification = { post: { - title: "It's a title" - } + title: "It's a title", + }, } }) diff --git a/webapp/components/notifications/NotificationList/index.vue b/webapp/components/notifications/NotificationList/index.vue index b8235f853..af1c86732 100644 --- a/webapp/components/notifications/NotificationList/index.vue +++ b/webapp/components/notifications/NotificationList/index.vue @@ -15,18 +15,18 @@ import Notification from '../Notification' export default { name: 'NotificationList', components: { - Notification + Notification, }, props: { notifications: { type: Array, - required: true - } + required: true, + }, }, methods: { markAsRead(notificationId) { this.$emit('markAsRead', notificationId) - } - } + }, + }, } diff --git a/webapp/components/notifications/NotificationList/spec.js b/webapp/components/notifications/NotificationList/spec.js index c433abd80..c4841c95a 100644 --- a/webapp/components/notifications/NotificationList/spec.js +++ b/webapp/components/notifications/NotificationList/spec.js @@ -1,13 +1,6 @@ -import { - config, - shallowMount, - mount, - createLocalVue, - RouterLinkStub -} from '@vue/test-utils' +import { config, shallowMount, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils' import NotificationList from '.' import Notification from '../Notification' -import Vue from 'vue' import Vuex from 'vuex' import Filters from '~/plugins/vue-filters' @@ -25,7 +18,6 @@ config.stubs['v-popover'] = '' describe('NotificationList.vue', () => { let wrapper - let Wrapper let mocks let stubs let store @@ -36,14 +28,14 @@ describe('NotificationList.vue', () => { getters: { 'auth/user': () => { return {} - } - } + }, + }, }) mocks = { - $t: jest.fn() + $t: jest.fn(), } stubs = { - NuxtLink: RouterLinkStub + NuxtLink: RouterLinkStub, } propsData = { notifications: [ @@ -57,9 +49,9 @@ describe('NotificationList.vue', () => { author: { id: 'john-1', slug: 'john-doe', - name: 'John Doe' - } - } + name: 'John Doe', + }, + }, }, { id: 'notification-42', @@ -71,11 +63,11 @@ describe('NotificationList.vue', () => { author: { id: 'john-1', slug: 'john-doe', - name: 'John Doe' - } - } - } - ] + name: 'John Doe', + }, + }, + }, + ], } }) @@ -85,7 +77,7 @@ describe('NotificationList.vue', () => { propsData, mocks, store, - localVue + localVue, }) } @@ -105,7 +97,7 @@ describe('NotificationList.vue', () => { mocks, stubs, store, - localVue + localVue, }) } diff --git a/webapp/components/notifications/NotificationMenu/index.vue b/webapp/components/notifications/NotificationMenu/index.vue index 819858e3b..4bc61dd92 100644 --- a/webapp/components/notifications/NotificationMenu/index.vue +++ b/webapp/components/notifications/NotificationMenu/index.vue @@ -66,12 +66,12 @@ export default { name: 'NotificationMenu', components: { NotificationList, - Dropdown + Dropdown, }, computed: { totalNotifications() { return (this.notifications || []).length - } + }, }, methods: { async markAsRead(notificationId) { @@ -79,24 +79,24 @@ export default { try { await this.$apollo.mutate({ mutation: MARK_AS_READ, - variables + variables, }) } catch (err) { throw new Error(err) } - } + }, }, apollo: { notifications: { query: NOTIFICATIONS, update: data => { const { - currentUser: { notifications } + currentUser: { notifications }, } = data return notifications - } - } - } + }, + }, + }, } diff --git a/webapp/components/notifications/NotificationMenu/spec.js b/webapp/components/notifications/NotificationMenu/spec.js index 4c9dd9d43..673a85944 100644 --- a/webapp/components/notifications/NotificationMenu/spec.js +++ b/webapp/components/notifications/NotificationMenu/spec.js @@ -14,16 +14,15 @@ config.stubs['dropdown'] = '' describe('NotificationMenu.vue', () => { let wrapper - let Wrapper let mocks let data beforeEach(() => { mocks = { - $t: jest.fn() + $t: jest.fn(), } data = () => { return { - notifications: [] + notifications: [], } } }) @@ -33,7 +32,7 @@ describe('NotificationMenu.vue', () => { return shallowMount(NotificationMenu, { data, mocks, - localVue + localVue, }) } @@ -62,9 +61,9 @@ describe('NotificationMenu.vue', () => { author: { id: 'john-1', slug: 'john-doe', - name: 'John Doe' - } - } + name: 'John Doe', + }, + }, }, { id: 'notification-42', @@ -76,11 +75,11 @@ describe('NotificationMenu.vue', () => { author: { id: 'john-1', slug: 'john-doe', - name: 'John Doe' - } - } - } - ] + name: 'John Doe', + }, + }, + }, + ], } } }) diff --git a/webapp/graphql/PostMutations.js b/webapp/graphql/PostMutations.js index d92445744..dbaa4cd78 100644 --- a/webapp/graphql/PostMutations.js +++ b/webapp/graphql/PostMutations.js @@ -23,6 +23,6 @@ export default app => { contentExcerpt } } - `) + `), } } diff --git a/webapp/layouts/blank.vue b/webapp/layouts/blank.vue index 570799a4d..81d25a5ca 100644 --- a/webapp/layouts/blank.vue +++ b/webapp/layouts/blank.vue @@ -13,6 +13,6 @@ import seo from '~/mixins/seo' export default { - mixins: [seo] + mixins: [seo], } diff --git a/webapp/layouts/default.vue b/webapp/layouts/default.vue index f34b02899..34544ae06 100644 --- a/webapp/layouts/default.vue +++ b/webapp/layouts/default.vue @@ -131,13 +131,12 @@ export default { LocaleSwitch, SearchInput, Modal, - LocaleSwitch, - NotificationMenu + NotificationMenu, }, mixins: [seo], data() { return { - mobileSearchVisible: false + mobileSearchVisible: false, } }, computed: { @@ -147,7 +146,7 @@ export default { isModerator: 'auth/isModerator', isAdmin: 'auth/isAdmin', quickSearchResults: 'search/quickResults', - quickSearchPending: 'search/quickPending' + quickSearchPending: 'search/quickPending', }), userName() { const { name } = this.user || {} @@ -161,41 +160,41 @@ export default { { name: this.$t('profile.name'), path: `/profile/${this.user.slug}`, - icon: 'user' + icon: 'user', }, { name: this.$t('settings.name'), path: `/settings`, - icon: 'cogs' - } + icon: 'cogs', + }, ] if (this.isModerator) { routes.push({ name: this.$t('moderation.name'), path: `/moderation`, - icon: 'balance-scale' + icon: 'balance-scale', }) } if (this.isAdmin) { routes.push({ name: this.$t('admin.name'), path: `/admin`, - icon: 'shield' + icon: 'shield', }) } return routes - } + }, }, methods: { ...mapActions({ quickSearchClear: 'search/quickClear', - quickSearch: 'search/quickSearch' + quickSearch: 'search/quickSearch', }), goToPost(item) { this.$nextTick(() => { this.$router.push({ name: 'post-id-slug', - params: { id: item.id, slug: item.slug } + params: { id: item.id, slug: item.slug }, }) }) }, @@ -205,8 +204,8 @@ export default { return this.$route.path === url } return this.$route.path.indexOf(url) === 0 - } - } + }, + }, } diff --git a/webapp/locales/index.js b/webapp/locales/index.js index 35a99b317..b4dbedc6e 100644 --- a/webapp/locales/index.js +++ b/webapp/locales/index.js @@ -3,48 +3,48 @@ module.exports = [ name: 'English', code: 'en', iso: 'en-US', - enabled: true + enabled: true, }, { name: 'Deutsch', code: 'de', iso: 'de-DE', - enabled: true + enabled: true, }, { name: 'Nederlands', code: 'nl', iso: 'nl-NL', - enabled: true + enabled: true, }, { name: 'Français', code: 'fr', iso: 'fr-FR', - enabled: true + enabled: true, }, { name: 'Italiano', code: 'it', iso: 'it-IT', - enabled: true + enabled: true, }, { name: 'Español', code: 'es', iso: 'es-ES', - enabled: true + enabled: true, }, { name: 'Português', code: 'pt', iso: 'pt-PT', - enabled: true + enabled: true, }, { name: 'Polski', code: 'pl', iso: 'pl-PL', - enabled: true - } + enabled: true, + }, ] diff --git a/webapp/mixins/persistentLinks.js b/webapp/mixins/persistentLinks.js index 5cecbbdbd..efc4392e2 100644 --- a/webapp/mixins/persistentLinks.js +++ b/webapp/mixins/persistentLinks.js @@ -6,7 +6,7 @@ export default function(options = {}) { params: { id, slug }, redirect, error, - app: { apolloProvider } + app: { apolloProvider }, } = context const idOrSlug = id || slug @@ -27,6 +27,6 @@ export default function(options = {}) { if (resource) return redirect(`/${path}/${resource.id}/${resource.slug}`) return error({ statusCode: 404, message }) - } + }, } } diff --git a/webapp/mixins/seo.js b/webapp/mixins/seo.js index de641e677..2dd0ecb20 100644 --- a/webapp/mixins/seo.js +++ b/webapp/mixins/seo.js @@ -2,11 +2,11 @@ export default { head() { return { htmlAttrs: { - lang: this.$i18n.locale() + lang: this.$i18n.locale(), }, bodyAttrs: { - class: `page-name-${this.$route.name}` - } + class: `page-name-${this.$route.name}`, + }, } - } + }, } diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index 9d0ae0fc3..a50ac9e2a 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -6,7 +6,7 @@ const styleguidePath = '../Nitro-Styleguide' const styleguideStyles = process.env.STYLEGUIDE_DEV ? [ `${styleguidePath}/src/system/styles/main.scss`, - `${styleguidePath}/src/system/styles/shared.scss` + `${styleguidePath}/src/system/styles/shared.scss`, ] : '@human-connection/styleguide/dist/shared.scss' @@ -20,24 +20,16 @@ module.exports = { transition: { name: 'slide-up', - mode: 'out-in' + mode: 'out-in', }, env: { // pages which do NOT require a login - publicPages: [ - 'login', - 'logout', - 'register', - 'signup', - 'reset', - 'reset-token', - 'pages-slug' - ], + publicPages: ['login', 'logout', 'register', 'signup', 'reset', 'reset-token', 'pages-slug'], // pages to keep alive keepAlivePages: ['index'], // active locales - locales: require('./locales') + locales: require('./locales'), }, /* ** Headers of the page @@ -48,9 +40,9 @@ module.exports = { meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, - { hid: 'description', name: 'description', content: pkg.description } + { hid: 'description', name: 'description', content: pkg.description }, ], - link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }] + link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }], }, /* @@ -59,7 +51,7 @@ module.exports = { loading: { color: '#86b31e', height: '2px', - duration: 20000 + duration: 20000, }, /* @@ -71,7 +63,7 @@ module.exports = { ** Global processed styles */ styleResources: { - scss: styleguideStyles + scss: styleguideStyles, }, /* @@ -80,7 +72,7 @@ module.exports = { plugins: [ { src: `~/plugins/styleguide${process.env.STYLEGUIDE_DEV ? '-dev' : ''}.js`, - ssr: true + ssr: true, }, { src: '~/plugins/i18n.js', ssr: true }, { src: '~/plugins/axios.js', ssr: false }, @@ -88,7 +80,7 @@ module.exports = { { src: '~/plugins/vue-directives.js', ssr: false }, { src: '~/plugins/v-tooltip.js', ssr: false }, { src: '~/plugins/izi-toast.js', ssr: false }, - { src: '~/plugins/vue-filters.js' } + { src: '~/plugins/vue-filters.js' }, ], router: { @@ -97,7 +89,7 @@ module.exports = { linkExactActiveClass: 'router-link-exact-active', scrollBehavior: () => { return { x: 0, y: 0 } - } + }, }, /* @@ -109,7 +101,7 @@ module.exports = { 'cookie-universal-nuxt', '@nuxtjs/apollo', '@nuxtjs/axios', - '@nuxtjs/style-resources' + '@nuxtjs/style-resources', ], /* @@ -118,7 +110,7 @@ module.exports = { axios: { // See https://github.com/nuxt-community/axios-module#options debug: dev, - proxy: true + proxy: true, }, proxy: { '/.well-known/webfinger': { @@ -127,8 +119,8 @@ module.exports = { headers: { Accept: 'application/json', 'X-UI-Request': true, - 'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL' - } + 'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL', + }, }, '/activitypub': { // make this configurable (nuxt-dotenv) @@ -137,8 +129,8 @@ module.exports = { headers: { Accept: 'application/json', 'X-UI-Request': true, - 'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL' - } + 'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL', + }, }, '/api': { // make this configurable (nuxt-dotenv) @@ -148,9 +140,9 @@ module.exports = { headers: { Accept: 'application/json', 'X-UI-Request': true, - 'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL' - } - } + 'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL', + }, + }, }, // Give apollo module options @@ -164,7 +156,7 @@ module.exports = { console.log( '%cError', 'background: red; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;', - error.message + error.message, ) }, @@ -177,15 +169,15 @@ module.exports = { // }, // required clientConfigs: { - default: '~/plugins/apollo-config.js' - } + default: '~/plugins/apollo-config.js', + }, }, manifest: { name: 'Human-Connection.org', description: 'Human-Connection.org', theme_color: '#ffffff', - lang: 'de' + lang: 'de', }, /* @@ -198,15 +190,10 @@ module.exports = { extend(config, ctx) { if (process.env.STYLEGUIDE_DEV) { const path = require('path') - config.resolve.alias['@@'] = path.resolve( - __dirname, - `${styleguidePath}/src/system` - ) + config.resolve.alias['@@'] = path.resolve(__dirname, `${styleguidePath}/src/system`) config.module.rules.push({ resourceQuery: /blockType=docs/, - loader: require.resolve( - `${styleguidePath}/src/loader/docs-trim-loader.js` - ) + loader: require.resolve(`${styleguidePath}/src/loader/docs-trim-loader.js`), }) } @@ -219,15 +206,15 @@ module.exports = { svgo: { plugins: [ { - removeViewBox: false + removeViewBox: false, }, { - removeDimensions: true - } - ] - } - } + removeDimensions: true, + }, + ], + }, + }, }) - } - } + }, + }, } diff --git a/webapp/pages/admin.vue b/webapp/pages/admin.vue index 6cacedef5..631338ef9 100644 --- a/webapp/pages/admin.vue +++ b/webapp/pages/admin.vue @@ -30,7 +30,7 @@ export default { return [ { name: this.$t('admin.dashboard.name'), - path: `/admin` + path: `/admin`, }, // TODO implement /* { @@ -54,19 +54,19 @@ export default { }, */ { name: this.$t('admin.categories.name'), - path: `/admin/categories` + path: `/admin/categories`, }, { name: this.$t('admin.tags.name'), - path: `/admin/tags` - } + path: `/admin/tags`, + }, // TODO implement /* { name: this.$t('admin.settings.name'), path: `/admin/settings` } */ ] - } - } + }, + }, } diff --git a/webapp/pages/admin/categories.vue b/webapp/pages/admin/categories.vue index 20739a661..4620b29ad 100644 --- a/webapp/pages/admin/categories.vue +++ b/webapp/pages/admin/categories.vue @@ -21,7 +21,7 @@ import gql from 'graphql-tag' export default { data() { return { - Category: [] + Category: [], } }, computed: { @@ -31,10 +31,10 @@ export default { name: this.$t('admin.categories.categoryName'), postCount: { label: this.$t('admin.categories.postCount'), - align: 'right' - } + align: 'right', + }, } - } + }, }, apollo: { Category: { @@ -48,8 +48,8 @@ export default { postCount } } - `) - } - } + `), + }, + }, } diff --git a/webapp/pages/admin/index.vue b/webapp/pages/admin/index.vue index 349e372e8..d87cd8cc3 100644 --- a/webapp/pages/admin/index.vue +++ b/webapp/pages/admin/index.vue @@ -168,17 +168,17 @@ import HcCountTo from '~/components/CountTo.vue' export default { components: { - HcCountTo + HcCountTo, }, data() { return { - statistics: {} + statistics: {}, } }, computed: { isClient() { return process.client - } + }, }, mounted() { this.$apollo.queries.statistics.startPolling(5000) @@ -199,8 +199,8 @@ export default { countShouts } } - `) - } - } + `), + }, + }, } diff --git a/webapp/pages/admin/notifications.vue b/webapp/pages/admin/notifications.vue index a51be6863..62be1b3bb 100644 --- a/webapp/pages/admin/notifications.vue +++ b/webapp/pages/admin/notifications.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/admin/organizations.vue b/webapp/pages/admin/organizations.vue index 13c62f267..f1e73b8cd 100644 --- a/webapp/pages/admin/organizations.vue +++ b/webapp/pages/admin/organizations.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/admin/pages.vue b/webapp/pages/admin/pages.vue index fae436782..789d8ad1c 100644 --- a/webapp/pages/admin/pages.vue +++ b/webapp/pages/admin/pages.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/admin/settings.vue b/webapp/pages/admin/settings.vue index fcd0c8397..95d34bc86 100644 --- a/webapp/pages/admin/settings.vue +++ b/webapp/pages/admin/settings.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/admin/tags.vue b/webapp/pages/admin/tags.vue index 03115f091..56fa45d59 100644 --- a/webapp/pages/admin/tags.vue +++ b/webapp/pages/admin/tags.vue @@ -21,7 +21,7 @@ import gql from 'graphql-tag' export default { data() { return { - Tag: [] + Tag: [], } }, computed: { @@ -31,14 +31,14 @@ export default { name: 'Name', taggedCountUnique: { label: this.$t('admin.tags.tagCountUnique'), - align: 'right' + align: 'right', }, taggedCount: { label: this.$t('admin.tags.tagCount'), - align: 'right' - } + align: 'right', + }, } - } + }, }, apollo: { Tag: { @@ -51,8 +51,8 @@ export default { taggedCountUnique } } - `) - } - } + `), + }, + }, } diff --git a/webapp/pages/admin/users.vue b/webapp/pages/admin/users.vue index b06e45b5f..e2958b638 100644 --- a/webapp/pages/admin/users.vue +++ b/webapp/pages/admin/users.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index 26ff6296d..fa3061443 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -40,14 +40,14 @@ import HcLoadMore from '~/components/LoadMore.vue' export default { components: { HcPostCard, - HcLoadMore + HcLoadMore, }, data() { return { // Initialize your apollo data Post: [], page: 1, - pageSize: 10 + pageSize: 10, } }, computed: { @@ -56,7 +56,7 @@ export default { }, offset() { return (this.page - 1) * this.pageSize - } + }, }, methods: { uniq(items, field = 'id') { @@ -65,7 +65,7 @@ export default { href(post) { return this.$router.resolve({ name: 'post-id-slug', - params: { id: post.id, slug: post.slug } + params: { id: post.id, slug: post.slug }, }).href }, showMoreContributions() { @@ -75,7 +75,7 @@ export default { this.$apollo.queries.Post.fetchMore({ variables: { first: this.pageSize, - offset: this.offset + offset: this.offset, }, // Transform the previous result with new data updateQuery: (previousResult, { fetchMoreResult }) => { @@ -83,9 +83,9 @@ export default { output.Post = [...previousResult.Post, ...fetchMoreResult.Post] return output }, - fetchPolicy: 'cache-and-network' + fetchPolicy: 'cache-and-network', }) - } + }, }, apollo: { Post: { @@ -136,12 +136,12 @@ export default { variables() { return { first: this.pageSize, - offset: 0 + offset: 0, } }, - fetchPolicy: 'cache-and-network' - } - } + fetchPolicy: 'cache-and-network', + }, + }, } diff --git a/webapp/pages/login.vue b/webapp/pages/login.vue index 46c6e2d79..9a984298e 100644 --- a/webapp/pages/login.vue +++ b/webapp/pages/login.vue @@ -82,9 +82,7 @@ :href="$t('login.moreInfoURL')" :title="$t('login.moreInfoHint')" target="_blank" - > - {{ $t('login.moreInfo') }} - + >{{ $t('login.moreInfo') }} @@ -97,11 +95,9 @@ diff --git a/webapp/pages/logout.vue b/webapp/pages/logout.vue index 008908360..a7efb0fb8 100644 --- a/webapp/pages/logout.vue +++ b/webapp/pages/logout.vue @@ -41,6 +41,6 @@ export default { async beforeCreate() { await this.$store.dispatch('auth/logout') this.$router.replace('/') - } + }, } diff --git a/webapp/pages/moderation.vue b/webapp/pages/moderation.vue index 6b151b0e4..5205020fa 100644 --- a/webapp/pages/moderation.vue +++ b/webapp/pages/moderation.vue @@ -27,10 +27,10 @@ export default { return [ { name: this.$t('moderation.reports.name'), - path: `/moderation` - } + path: `/moderation`, + }, ] - } - } + }, + }, } diff --git a/webapp/pages/moderation/index.vue b/webapp/pages/moderation/index.vue index fc5d1fbe6..97c1a2af1 100644 --- a/webapp/pages/moderation/index.vue +++ b/webapp/pages/moderation/index.vue @@ -14,9 +14,12 @@ slot-scope="scope" >
- + {{ scope.row.post.title | truncate(50) }} -
+
+
- + {{ scope.row.comment.contentExcerpt | truncate(50) }} -
+
+
- + {{ scope.row.user.name | truncate(50) }}
@@ -45,9 +53,7 @@ slot="type" slot-scope="scope" > - + - + {{ scope.row.submitter.name }} @@ -106,17 +114,16 @@ diff --git a/webapp/pages/post/_id.vue b/webapp/pages/post/_id.vue index d8fc5d4f9..ab6ec0687 100644 --- a/webapp/pages/post/_id.vue +++ b/webapp/pages/post/_id.vue @@ -41,7 +41,7 @@ const options = { } `, path: 'post', - message: 'This post could not be found' + message: 'This post could not be found', } const persistentLinks = PersistentLinks(options) @@ -57,8 +57,8 @@ export default { children: [ { name: this.$t('common.comment', null, 2), - path: `/post/${id}/${slug}#comments` - } + path: `/post/${id}/${slug}#comments`, + }, // TODO implement /* { name: this.$t('common.letsTalk'), @@ -69,20 +69,20 @@ export default { name: this.$t('common.versus'), path: `/post/${id}/${slug}#versus` } */ - ] + ], }, { name: this.$t('common.moreInfo'), - path: `/post/${id}/${slug}/more-info` - } + path: `/post/${id}/${slug}/more-info`, + }, // TODO implement /* { name: this.$t('common.takeAction'), path: `/post/${id}/${slug}/take-action` } */ ] - } - } + }, + }, } diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index ad04f8421..b0718f893 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -94,7 +94,7 @@ import HcCommentList from '~/components/comments/CommentList' export default { transition: { name: 'slide-up', - mode: 'out-in' + mode: 'out-in', }, components: { HcTag, @@ -103,31 +103,31 @@ export default { HcShoutButton, ContentMenu, HcCommentForm, - HcCommentList + HcCommentList, }, head() { return { - title: this.title + title: this.title, } }, data() { return { post: null, ready: false, - title: 'loading' + title: 'loading', } }, watch: { Post(post) { this.post = post[0] || {} this.title = this.post.title - } + }, }, async asyncData(context) { const { params, error, - app: { apolloProvider, $i18n } + app: { apolloProvider, $i18n }, } = context const client = apolloProvider.defaultClient const query = gql(` @@ -206,7 +206,7 @@ export default { `) const variables = { slug: params.slug } const { - data: { Post } + data: { Post }, } = await client.query({ query, variables }) if (Post.length <= 0) { // TODO: custom 404 error page with translations @@ -216,7 +216,7 @@ export default { const [post] = Post return { post, - title: post.title + title: post.title, } }, mounted() { @@ -229,8 +229,8 @@ export default { methods: { isAuthor(id) { return this.$store.getters['auth/user'].id === id - } - } + }, + }, } diff --git a/webapp/pages/post/_id/_slug/more-info.vue b/webapp/pages/post/_id/_slug/more-info.vue index ae03fe658..e18ab8f57 100644 --- a/webapp/pages/post/_id/_slug/more-info.vue +++ b/webapp/pages/post/_id/_slug/more-info.vue @@ -62,16 +62,16 @@ import HcEmpty from '~/components/Empty.vue' export default { transition: { name: 'slide-up', - mode: 'out-in' + mode: 'out-in', }, components: { HcPostCard, - HcEmpty + HcEmpty, }, computed: { post() { return this.Post ? this.Post[0] || {} : {} - } + }, }, apollo: { Post: { @@ -128,11 +128,11 @@ export default { }, variables() { return { - slug: this.$route.params.slug + slug: this.$route.params.slug, } - } - } - } + }, + }, + }, } diff --git a/webapp/pages/post/_id/_slug/take-action.vue b/webapp/pages/post/_id/_slug/take-action.vue index 35cbe30fc..1dfb75208 100644 --- a/webapp/pages/post/_id/_slug/take-action.vue +++ b/webapp/pages/post/_id/_slug/take-action.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/post/create.vue b/webapp/pages/post/create.vue index fd8b493d3..a110965db 100644 --- a/webapp/pages/post/create.vue +++ b/webapp/pages/post/create.vue @@ -13,12 +13,11 @@ diff --git a/webapp/pages/post/edit/_id.vue b/webapp/pages/post/edit/_id.vue index cb61e2b40..2420a85b9 100644 --- a/webapp/pages/post/edit/_id.vue +++ b/webapp/pages/post/edit/_id.vue @@ -18,7 +18,7 @@ import HcContributionForm from '~/components/ContributionForm' export default { components: { - HcContributionForm + HcContributionForm, }, computed: { user() { @@ -29,14 +29,14 @@ export default { }, contribution() { return this.Post ? this.Post[0] : {} - } + }, }, watch: { contribution() { if (this.author.id !== this.user.id) { throw new Error(`You can't edit that!`) } - } + }, }, apollo: { Post: { @@ -71,11 +71,11 @@ export default { }, variables() { return { - id: this.$route.params.id || 'p1' + id: this.$route.params.id || 'p1', } }, - fetchPolicy: 'cache-and-network' - } - } + fetchPolicy: 'cache-and-network', + }, + }, } diff --git a/webapp/pages/profile/_id.vue b/webapp/pages/profile/_id.vue index 4d436146c..992e5efce 100644 --- a/webapp/pages/profile/_id.vue +++ b/webapp/pages/profile/_id.vue @@ -24,11 +24,11 @@ const options = { } `, message: 'This user could not be found', - path: 'profile' + path: 'profile', } const persistentLinks = PersistentLinks(options) export default { - mixins: [persistentLinks] + mixins: [persistentLinks], } diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 266a3f9c6..3dfb2c751 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -337,18 +337,18 @@ export default { HcBadges, HcLoadMore, HcEmpty, - ContentMenu + ContentMenu, }, transition: { name: 'slide-up', - mode: 'out-in' + mode: 'out-in', }, data() { return { User: [], voted: false, page: 1, - pageSize: 6 + pageSize: 6, } }, computed: { @@ -367,8 +367,7 @@ export default { }, hasMore() { return ( - this.user.contributions && - this.user.contributions.length < this.user.contributionsCount + this.user.contributions && this.user.contributions.length < this.user.contributionsCount ) }, activePosts() { @@ -381,9 +380,7 @@ export default { const { socialMedia = [] } = this.user return socialMedia.map(socialMedia => { const { url } = socialMedia - const matches = url.match( - /^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:\/\n?]+)/g - ) + const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g) const [domain] = matches || [] const favicon = domain ? `${domain}/favicon.ico` : null const username = url.split('/').pop() @@ -393,14 +390,14 @@ export default { userName() { const { name } = this.user || {} return name || this.$t('profile.userAnonym') - } + }, }, watch: { User(val) { if (!val || !val.length) { throw new Error('User not found!') } - } + }, }, methods: { uniq(items, field = 'id') { @@ -418,20 +415,20 @@ export default { variables: { slug: this.$route.params.slug, first: this.pageSize, - offset: this.offset + offset: this.offset, }, // Transform the previous result with new data updateQuery: (previousResult, { fetchMoreResult }) => { let output = { User: this.User } output.User[0].contributions = [ ...previousResult.User[0].contributions, - ...fetchMoreResult.User[0].contributions + ...fetchMoreResult.User[0].contributions, ] return output }, - fetchPolicy: 'cache-and-network' + fetchPolicy: 'cache-and-network', }) - } + }, }, apollo: { User: { @@ -442,12 +439,12 @@ export default { return { slug: this.$route.params.slug, first: this.pageSize, - offset: 0 + offset: 0, } }, - fetchPolicy: 'cache-and-network' - } - } + fetchPolicy: 'cache-and-network', + }, + }, } diff --git a/webapp/pages/settings.vue b/webapp/pages/settings.vue index 68b7c6d31..48eab45ff 100644 --- a/webapp/pages/settings.vue +++ b/webapp/pages/settings.vue @@ -29,16 +29,16 @@ export default { return [ { name: this.$t('settings.data.name'), - path: `/settings` + path: `/settings`, }, { name: this.$t('settings.security.name'), - path: `/settings/security` + path: `/settings/security`, }, { name: this.$t('settings.social-media.name'), - path: `/settings/my-social-media` - } + path: `/settings/my-social-media`, + }, // TODO implement /* { name: this.$t('settings.invites.name'), @@ -66,7 +66,7 @@ export default { }, } */ ] - } - } + }, + }, } diff --git a/webapp/pages/settings/data-download.vue b/webapp/pages/settings/data-download.vue index 4bb70de24..5c9e5a24a 100644 --- a/webapp/pages/settings/data-download.vue +++ b/webapp/pages/settings/data-download.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/settings/delete-account.vue b/webapp/pages/settings/delete-account.vue index 77e8b542b..5f488fed1 100644 --- a/webapp/pages/settings/delete-account.vue +++ b/webapp/pages/settings/delete-account.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/settings/index.spec.js b/webapp/pages/settings/index.spec.js index 8ee68172e..f0eff0641 100644 --- a/webapp/pages/settings/index.spec.js +++ b/webapp/pages/settings/index.spec.js @@ -1,6 +1,5 @@ import { mount, createLocalVue } from '@vue/test-utils' import index from './index.vue' -import Vue from 'vue' import Vuex from 'vuex' import Styleguide from '@human-connection/styleguide' @@ -10,7 +9,6 @@ localVue.use(Vuex) localVue.use(Styleguide) describe('index.vue', () => { - let Wrapper let store let mocks let getters @@ -28,27 +26,27 @@ describe('index.vue', () => { id: 'u1', name: 'Peter', locationName: 'Berlin', - about: 'Smth' - } - } - }) + about: 'Smth', + }, + }, + }), }, $toast: { error: jest.fn(), - success: jest.fn() - } + success: jest.fn(), + }, } getters = { 'auth/user': () => { return {} - } + }, } }) describe('mount', () => { const Wrapper = () => { store = new Vuex.Store({ - getters + getters, }) return mount(index, { store, mocks, localVue }) } diff --git a/webapp/pages/settings/index.vue b/webapp/pages/settings/index.vue index a3b2298c3..18e251bbc 100644 --- a/webapp/pages/settings/index.vue +++ b/webapp/pages/settings/index.vue @@ -51,11 +51,11 @@ import gql from 'graphql-tag' import { mapGetters, mapMutations } from 'vuex' import { CancelToken } from 'axios' -import find from 'lodash/find' let timeout const mapboxToken = process.env.MAPBOX_TOKEN +/* const query = gql` query getUser($id: ID) { User(id: $id) { @@ -66,15 +66,11 @@ const query = gql` } } ` +*/ const mutation = gql` mutation($id: ID!, $name: String, $locationName: String, $about: String) { - UpdateUser( - id: $id - name: $name - locationName: $locationName - about: $about - ) { + UpdateUser(id: $id, name: $name, locationName: $locationName, about: $about) { id name locationName @@ -90,12 +86,12 @@ export default { cities: [], loadingData: false, loadingGeo: false, - formData: {} + formData: {}, } }, computed: { ...mapGetters({ - currentUser: 'auth/user' + currentUser: 'auth/user', }), form: { get: function() { @@ -104,12 +100,12 @@ export default { }, set: function(formData) { this.formData = formData - } - } + }, + }, }, methods: { ...mapMutations({ - setCurrentUser: 'auth/SET_USER' + setCurrentUser: 'auth/SET_USER', }), async submit() { this.loadingData = true @@ -117,13 +113,13 @@ export default { let { locationName } = this.formData locationName = locationName && (locationName['label'] || locationName) try { - const { data } = await this.$apollo.mutate({ + await this.$apollo.mutate({ mutation, variables: { id: this.currentUser.id, name, locationName, - about + about, }, update: (store, { data: { UpdateUser } }) => { const { name, locationName, about } = UpdateUser @@ -131,9 +127,9 @@ export default { ...this.currentUser, name, locationName, - about + about, }) - } + }, }) this.$toast.success(this.$t('settings.data.success')) } catch (err) { @@ -147,12 +143,7 @@ export default { timeout = setTimeout(() => this.requestGeoData(value), 500) }, processCityResults(res) { - if ( - !res || - !res.data || - !res.data.features || - !res.data.features.length - ) { + if (!res || !res.data || !res.data.features || !res.data.features.length) { return [] } let output = [] @@ -160,7 +151,7 @@ export default { output.push({ label: item.place_name, value: item.place_name, - id: item.id + id: item.id, }) }) @@ -188,8 +179,8 @@ export default { .get( `https://api.mapbox.com/geocoding/v5/mapbox.places/${place}.json?access_token=${mapboxToken}&types=region,place,country&language=${lang}`, { - cancelToken: this.axiosSource.token - } + cancelToken: this.axiosSource.token, + }, ) .then(res => { this.cities = this.processCityResults(res) @@ -197,7 +188,7 @@ export default { .finally(() => { this.loadingGeo = false }) - } - } + }, + }, } diff --git a/webapp/pages/settings/invites.vue b/webapp/pages/settings/invites.vue index 7ef6f66fc..947d0b333 100644 --- a/webapp/pages/settings/invites.vue +++ b/webapp/pages/settings/invites.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/settings/languages.vue b/webapp/pages/settings/languages.vue index 52367f85b..7879d6425 100644 --- a/webapp/pages/settings/languages.vue +++ b/webapp/pages/settings/languages.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/settings/my-organizations.vue b/webapp/pages/settings/my-organizations.vue index 2b38f71aa..f651cbc61 100644 --- a/webapp/pages/settings/my-organizations.vue +++ b/webapp/pages/settings/my-organizations.vue @@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue' export default { components: { - HcEmpty - } + HcEmpty, + }, } diff --git a/webapp/pages/settings/my-social-media.spec.js b/webapp/pages/settings/my-social-media.spec.js index 559ba87d2..34793e066 100644 --- a/webapp/pages/settings/my-social-media.spec.js +++ b/webapp/pages/settings/my-social-media.spec.js @@ -1,6 +1,5 @@ import { mount, createLocalVue } from '@vue/test-utils' import MySocialMedia from './my-social-media.vue' -import Vue from 'vue' import Vuex from 'vuex' import Styleguide from '@human-connection/styleguide' @@ -11,7 +10,6 @@ localVue.use(Styleguide) describe('my-social-media.vue', () => { let wrapper - let Wrapper let store let mocks let getters @@ -27,25 +25,25 @@ describe('my-social-media.vue', () => { .fn() .mockRejectedValue({ message: 'Ouch!' }) .mockResolvedValueOnce({ - data: { CreateSocialMeda: { id: 's1', url: socialMediaUrl } } - }) + data: { CreateSocialMeda: { id: 's1', url: socialMediaUrl } }, + }), }, $toast: { error: jest.fn(), - success: jest.fn() - } + success: jest.fn(), + }, } getters = { 'auth/user': () => { return {} - } + }, } }) describe('mount', () => { const Wrapper = () => { store = new Vuex.Store({ - getters + getters, }) return mount(MySocialMedia, { store, mocks, localVue }) } @@ -60,9 +58,9 @@ describe('my-social-media.vue', () => { getters = { 'auth/user': () => { return { - socialMedia: [{ id: 's1', url: socialMediaUrl }] + socialMedia: [{ id: 's1', url: socialMediaUrl }], } - } + }, } }) @@ -80,20 +78,20 @@ describe('my-social-media.vue', () => { .fn() .mockRejectedValue({ message: 'Ouch!' }) .mockResolvedValueOnce({ - data: { DeleteSocialMeda: { id: 's1', url: socialMediaUrl } } - }) + data: { DeleteSocialMeda: { id: 's1', url: socialMediaUrl } }, + }), }, $toast: { error: jest.fn(), - success: jest.fn() - } + success: jest.fn(), + }, } getters = { 'auth/user': () => { return { - socialMedia: [{ id: 's1', url: socialMediaUrl }] + socialMedia: [{ id: 's1', url: socialMediaUrl }], } - } + }, } }) diff --git a/webapp/pages/settings/my-social-media.vue b/webapp/pages/settings/my-social-media.vue index 95a61bdd8..745e2f776 100644 --- a/webapp/pages/settings/my-social-media.vue +++ b/webapp/pages/settings/my-social-media.vue @@ -22,7 +22,8 @@ /> {{ link.url }} -    |    +    + |    { const { id, url } = socialMedia - const matches = url.match( - /^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:\/\n?]+)/g - ) + const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g) const [domain] = matches || [] const favicon = domain ? `${domain}/favicon.ico` : null return { id, url, favicon } }) - } + }, }, methods: { ...mapMutations({ - setCurrentUser: 'auth/SET_USER' + setCurrentUser: 'auth/SET_USER', }), handleAddSocialMedia() { this.$apollo @@ -105,22 +104,19 @@ export default { } `, variables: { - url: this.value + url: this.value, }, update: (store, { data }) => { - const socialMedia = [ - ...this.currentUser.socialMedia, - data.CreateSocialMedia - ] + const socialMedia = [...this.currentUser.socialMedia, data.CreateSocialMedia] this.setCurrentUser({ ...this.currentUser, - socialMedia + socialMedia, }) - } + }, }) .then(() => { - this.$toast.success(this.$t('settings.social-media.successAdd')), - (this.value = '') + this.$toast.success(this.$t('settings.social-media.successAdd')) + this.value = '' }) .catch(error => { this.$toast.error(error.message) @@ -138,17 +134,17 @@ export default { } `, variables: { - id: link.id + id: link.id, }, update: (store, { data }) => { const socialMedia = this.currentUser.socialMedia.filter( - element => element.id !== link.id + element => element.id !== link.id, ) this.setCurrentUser({ ...this.currentUser, - socialMedia + socialMedia, }) - } + }, }) .then(() => { this.$toast.success(this.$t('settings.social-media.successDelete')) @@ -156,8 +152,8 @@ export default { .catch(error => { this.$toast.error(error.message) }) - } - } + }, + }, } diff --git a/webapp/pages/settings/security.vue b/webapp/pages/settings/security.vue index ac95ff26e..e1c8ca0e0 100644 --- a/webapp/pages/settings/security.vue +++ b/webapp/pages/settings/security.vue @@ -5,12 +5,11 @@ diff --git a/webapp/plugins/apollo-config.js b/webapp/plugins/apollo-config.js index f65700ab4..83ec452e3 100644 --- a/webapp/plugins/apollo-config.js +++ b/webapp/plugins/apollo-config.js @@ -3,11 +3,11 @@ export default ({ app }) => { return { httpEndpoint: process.server ? backendUrl : '/api', httpLinkOptions: { - credentials: 'same-origin' + credentials: 'same-origin', }, credentials: true, tokenName: 'human-connection-token', persisting: false, - websocketsOnly: false + websocketsOnly: false, } } diff --git a/webapp/plugins/i18n.js b/webapp/plugins/i18n.js index 836ba220f..b568ca39e 100644 --- a/webapp/plugins/i18n.js +++ b/webapp/plugins/i18n.js @@ -1,7 +1,6 @@ import Vue from 'vue' -import Vuex from 'vuex' import vuexI18n from 'vuex-i18n/dist/vuex-i18n.umd.js' -import { debounce, isEmpty, find } from 'lodash' +import { isEmpty, find } from 'lodash' /** * TODO: Refactor and simplify browser detection @@ -48,11 +47,9 @@ export default ({ app, req, cookie, store }) => { onTranslationNotFound: function(locale, key) { if (debug) { /* eslint-disable-next-line no-console */ - console.warn( - `vuex-i18n :: Key '${key}' not found for locale '${locale}'` - ) + console.warn(`vuex-i18n :: Key '${key}' not found for locale '${locale}'`) } - } + }, }) // register the fallback locales @@ -80,9 +77,7 @@ export default ({ app, req, cookie, store }) => { } const availableLocales = process.env.locales.filter(lang => !!lang.enabled) - const locale = find(availableLocales, ['code', userLocale]) - ? userLocale - : 'en' + const locale = find(availableLocales, ['code', userLocale]) ? userLocale : 'en' if (locale !== 'en') { Vue.i18n.add(locale, require(`~/locales/${locale}.json`)) diff --git a/webapp/plugins/izi-toast.js b/webapp/plugins/izi-toast.js index 5900898ac..8bb41c961 100644 --- a/webapp/plugins/izi-toast.js +++ b/webapp/plugins/izi-toast.js @@ -8,6 +8,6 @@ export default ({ app }) => { position: 'bottomRight', transitionIn: 'bounceInLeft', layout: 2, - theme: 'dark' + theme: 'dark', }) } diff --git a/webapp/plugins/keep-alive.js b/webapp/plugins/keep-alive.js index 93a8a1767..91d7ed1f0 100644 --- a/webapp/plugins/keep-alive.js +++ b/webapp/plugins/keep-alive.js @@ -24,7 +24,7 @@ if (!process.server) { if (this.$metaInfo && !keepAlivePages.includes(lastRoute)) { this.$destroy() } - } + }, }) } Vue.use(keepAliveHook) diff --git a/webapp/plugins/v-tooltip.js b/webapp/plugins/v-tooltip.js index a018ec5f3..77d0ac1b8 100644 --- a/webapp/plugins/v-tooltip.js +++ b/webapp/plugins/v-tooltip.js @@ -4,13 +4,13 @@ import VTooltip from 'v-tooltip' Vue.use(VTooltip, { defaultDelay: { show: 500, - hide: 50 + hide: 50, }, defaultOffset: 2, defaultPopperOptions: { - removeOnDestroy: true + removeOnDestroy: true, }, popover: { // defaultArrowClass: 'm-dropdown__arrow' - } + }, }) diff --git a/webapp/plugins/vue-directives.js b/webapp/plugins/vue-directives.js index 618bbd4e2..f54c02167 100644 --- a/webapp/plugins/vue-directives.js +++ b/webapp/plugins/vue-directives.js @@ -10,7 +10,7 @@ export default ({ app }) => { el.focus() } }) - } + }, }) Vue.directive('router-link', { @@ -28,6 +28,6 @@ export default ({ app }) => { if (binding.clickEventListener) { el.removeEventListener('click', binding.clickEventListener) } - } + }, }) } diff --git a/webapp/plugins/vue-filters.js b/webapp/plugins/vue-filters.js index bf59a7dba..aad978d72 100644 --- a/webapp/plugins/vue-filters.js +++ b/webapp/plugins/vue-filters.js @@ -2,7 +2,6 @@ import Vue from 'vue' import { enUS, de, nl, fr, es } from 'date-fns/locale' import format from 'date-fns/format' -import formatRelative from 'date-fns/formatRelative' import addSeconds from 'date-fns/addSeconds' import accounting from 'accounting' @@ -14,7 +13,7 @@ export default ({ app = {} }) => { fr: fr, es: es, pt: es, - pl: de + pl: de, } const getLocalizedFormat = () => { let locale = app.$i18n.locale() @@ -25,22 +24,16 @@ export default ({ app = {} }) => { date: (value, fmt = 'dd. MMM yyyy') => { if (!value) return '' return format(new Date(value), fmt, { - locale: getLocalizedFormat() + locale: getLocalizedFormat(), }) }, dateTime: (value, fmt = 'dd. MMM yyyy HH:mm') => { if (!value) return '' return format(new Date(value), fmt, { - locale: getLocalizedFormat() + locale: getLocalizedFormat(), }) }, - number: ( - value, - precision = 2, - thousands = '.', - decimals = ',', - fallback = null - ) => { + number: (value, precision = 2, thousands = '.', decimals = ',', fallback = null) => { if (isNaN(value) && fallback) { return fallback } @@ -99,7 +92,7 @@ export default ({ app = {} }) => { } return excerpt - } + }, }) // add all methods as filters on each vue component diff --git a/webapp/server/index.js b/webapp/server/index.js index 66738790e..d06bb1f6d 100644 --- a/webapp/server/index.js +++ b/webapp/server/index.js @@ -30,7 +30,7 @@ async function start() { app.listen(port, host) consola.ready({ message: `Server listening on http://${host}:${port}`, - badge: true + badge: true, }) } start() diff --git a/webapp/store/auth.js b/webapp/store/auth.js index ca1b453ba..87de84d9a 100644 --- a/webapp/store/auth.js +++ b/webapp/store/auth.js @@ -1,11 +1,10 @@ import gql from 'graphql-tag' -import jwt from 'jsonwebtoken' export const state = () => { return { user: null, token: null, - pending: false + pending: false, } } @@ -18,7 +17,7 @@ export const mutations = { }, SET_PENDING(state, pending) { state.pending = pending - } + }, } export const getters = { @@ -35,17 +34,14 @@ export const getters = { return !!state.user && state.user.role === 'admin' }, isModerator(state) { - return ( - !!state.user && - (state.user.role === 'admin' || state.user.role === 'moderator') - ) + return !!state.user && (state.user.role === 'admin' || state.user.role === 'moderator') }, user(state) { return state.user || {} }, token(state) { return state.token - } + }, } export const actions = { @@ -71,7 +67,7 @@ export const actions = { async fetchCurrentUser({ commit, dispatch }) { const client = this.app.apolloProvider.defaultClient const { - data: { currentUser } + data: { currentUser }, } = await client.query({ query: gql(`{ currentUser { @@ -105,7 +101,7 @@ export const actions = { } } } - }`) + }`), }) if (!currentUser) return dispatch('logout') commit('SET_USER', currentUser) @@ -117,14 +113,14 @@ export const actions = { try { const client = this.app.apolloProvider.defaultClient const { - data: { login } + data: { login }, } = await client.mutate({ mutation: gql(` mutation($email: String!, $password: String!) { login(email: $email, password: $password) } `), - variables: { email, password } + variables: { email, password }, }) await this.app.$apolloHelpers.onLogin(login) commit('SET_TOKEN', login) @@ -142,12 +138,9 @@ export const actions = { return this.app.$apolloHelpers.onLogout() }, - register( - { dispatch, commit }, - { email, password, inviteCode, invitedByUserId } - ) {}, + register({ dispatch, commit }, { email, password, inviteCode, invitedByUserId }) {}, async patch({ state, commit, dispatch }, data) {}, resendVerifySignup({ state, dispatch }) {}, resetPassword({ state }, data) {}, - setNewPassword({ state }, data) {} + setNewPassword({ state }, data) {}, } diff --git a/webapp/store/auth.test.js b/webapp/store/auth.test.js index 9b6a33195..e45fec693 100644 --- a/webapp/store/auth.test.js +++ b/webapp/store/auth.test.js @@ -1,4 +1,4 @@ -import { getters, mutations, actions } from './auth.js' +import { getters, actions } from './auth.js' let state let commit @@ -12,14 +12,15 @@ const currentUser = { slug: 'jenny-rostock', email: 'user@example.org', avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg', - role: 'user' + role: 'user', } const successfulLoginResponse = { data: { login: token } } const successfulCurrentUserResponse = { data: { currentUser } } +/* const incorrectPasswordResponse = { data: { - login: null + login: null, }, errors: [ { @@ -27,13 +28,14 @@ const incorrectPasswordResponse = { locations: [ { line: 2, - column: 3 - } + column: 3, + }, ], - path: ['login'] - } - ] + path: ['login'], + }, + ], } +*/ beforeEach(() => { commit = jest.fn() @@ -59,9 +61,9 @@ describe('actions', () => { const module = { app: { $apolloHelpers: { - getToken: () => token - } - } + getToken: () => token, + }, + }, } action = actions.init.bind(module) return action({ commit, dispatch }) @@ -91,9 +93,7 @@ describe('actions', () => { it('saves the JWT Bearer token', async () => { await theAction() - expect(commit.mock.calls).toEqual( - expect.arrayContaining([['SET_TOKEN', token]]) - ) + expect(commit.mock.calls).toEqual(expect.arrayContaining([['SET_TOKEN', token]])) }) }) }) @@ -105,12 +105,10 @@ describe('actions', () => { app: { apolloProvider: { defaultClient: { - query: jest.fn(() => - Promise.resolve(successfulCurrentUserResponse) - ) - } - } - } + query: jest.fn(() => Promise.resolve(successfulCurrentUserResponse)), + }, + }, + }, } action = actions.fetchCurrentUser.bind(module) await action({ commit }) @@ -126,12 +124,11 @@ describe('actions', () => { name: 'Jenny Rostock', slug: 'jenny-rostock', email: 'user@example.org', - avatar: - 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg', - role: 'user' - } - ] - ]) + avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/mutu_krish/128.jpg', + role: 'user', + }, + ], + ]), ) }) }) @@ -144,19 +141,16 @@ describe('actions', () => { app: { apolloProvider: { defaultClient: { - mutate: jest.fn(() => Promise.resolve(successfulLoginResponse)) - } + mutate: jest.fn(() => Promise.resolve(successfulLoginResponse)), + }, }, $apolloHelpers: { - onLogin: jest.fn(() => Promise.resolve()) - } - } + onLogin: jest.fn(() => Promise.resolve()), + }, + }, } action = actions.login.bind(module) - await action( - { commit, dispatch }, - { email: 'user@example.org', password: '1234' } - ) + await action({ commit, dispatch }, { email: 'user@example.org', password: '1234' }) }) afterEach(() => { @@ -164,9 +158,7 @@ describe('actions', () => { }) it('saves the JWT Bearer token', () => { - expect(commit.mock.calls).toEqual( - expect.arrayContaining([['SET_TOKEN', token]]) - ) + expect(commit.mock.calls).toEqual(expect.arrayContaining([['SET_TOKEN', token]])) }) it('fetches the user', () => { @@ -175,10 +167,7 @@ describe('actions', () => { it('saves pending flags in order', () => { expect(commit.mock.calls).toEqual( - expect.arrayContaining([ - ['SET_PENDING', true], - ['SET_PENDING', false] - ]) + expect.arrayContaining([['SET_PENDING', true], ['SET_PENDING', false]]), ) }) }) @@ -188,13 +177,13 @@ describe('actions', () => { let mutate beforeEach(() => { - mutate = jest.fn(() => Promise.reject('This error is expected.')) + mutate = jest.fn(() => Promise.reject('This error is expected.')) // eslint-disable-line prefer-promise-reject-errors onLogin = jest.fn(() => Promise.resolve()) const module = { app: { apolloProvider: { defaultClient: { mutate } }, - $apolloHelpers: { onLogin } - } + $apolloHelpers: { onLogin }, + }, } action = actions.login.bind(module) }) @@ -205,7 +194,7 @@ describe('actions', () => { it('populates error messages', async () => { expect( - action({ commit }, { email: 'user@example.org', password: 'wrong' }) + action({ commit }, { email: 'user@example.org', password: 'wrong' }), ).rejects.toThrowError('This error is expected.') expect(mutate).toHaveBeenCalled() expect(onLogin).not.toHaveBeenCalled() @@ -213,16 +202,10 @@ describe('actions', () => { it('saves pending flags in order', async () => { try { - await action( - { commit }, - { email: 'user@example.org', password: 'wrong' } - ) + await action({ commit }, { email: 'user@example.org', password: 'wrong' }) } catch (err) {} // ignore expect(commit.mock.calls).toEqual( - expect.arrayContaining([ - ['SET_PENDING', true], - ['SET_PENDING', false] - ]) + expect.arrayContaining([['SET_PENDING', true], ['SET_PENDING', false]]), ) }) }) diff --git a/webapp/store/index.js b/webapp/store/index.js index 91be021a5..8bc4ed563 100644 --- a/webapp/store/index.js +++ b/webapp/store/index.js @@ -5,5 +5,5 @@ export const mutations = {} export const actions = { async nuxtServerInit({ dispatch }) { await dispatch('auth/init') - } + }, } diff --git a/webapp/store/modal.js b/webapp/store/modal.js index f7bc1ad8e..72617f592 100644 --- a/webapp/store/modal.js +++ b/webapp/store/modal.js @@ -1,7 +1,7 @@ export const state = () => { return { open: null, - data: {} + data: {}, } } @@ -9,7 +9,7 @@ export const mutations = { SET_OPEN(state, ctx) { state.open = ctx.name || null state.data = ctx.data || {} - } + }, } export const getters = { @@ -18,5 +18,5 @@ export const getters = { }, data(state) { return state.data - } + }, } diff --git a/webapp/store/notifications.js b/webapp/store/notifications.js index cfb41e333..8e9b333b4 100644 --- a/webapp/store/notifications.js +++ b/webapp/store/notifications.js @@ -3,7 +3,7 @@ import gql from 'graphql-tag' export const state = () => { return { notifications: null, - pending: false + pending: false, } } @@ -19,13 +19,13 @@ export const mutations = { const toBeUpdated = notifications.find(n => { return n.id === notification.id }) - toBeUpdated = { ...toBeUpdated, ...notification } - } + state.notifications = { ...toBeUpdated, ...notification } + }, } export const getters = { notifications(state) { return !!state.notifications - } + }, } export const actions = { @@ -36,7 +36,7 @@ export const actions = { let notifications try { const { - data: { currentUser } + data: { currentUser }, } = await client.query({ query: gql(`{ currentUser { @@ -59,10 +59,9 @@ export const actions = { } } } - }`) + }`), }) notifications = currentUser.notifications - console.log(notifications) commit('SET_NOTIFICATIONS', notifications) } finally { commit('SET_PENDING', false) @@ -82,8 +81,8 @@ export const actions = { `) const variables = { id: notificationId, read: true } const { - data: { UpdateNotification } + data: { UpdateNotification }, } = await client.mutate({ mutation, variables }) commit('UPDATE_NOTIFICATIONS', UpdateNotification) - } + }, } diff --git a/webapp/store/search.js b/webapp/store/search.js index 0f9c00440..4aeb5030d 100644 --- a/webapp/store/search.js +++ b/webapp/store/search.js @@ -5,7 +5,7 @@ export const state = () => { return { quickResults: [], quickPending: false, - quickValue: '' + quickValue: '', } } @@ -19,7 +19,7 @@ export const mutations = { }, SET_QUICK_VALUE(state, value) { state.quickValue = value - } + }, } export const getters = { @@ -31,7 +31,7 @@ export const getters = { }, quickValue(state) { return state.quickValue - } + }, } export const actions = { @@ -64,8 +64,8 @@ export const actions = { } `), variables: { - filter: value.replace(/\s/g, '~ ') + '~' - } + filter: value.replace(/\s/g, '~ ') + '~', + }, }) .then(res => { commit('SET_QUICK_RESULTS', res.data.findPosts || []) @@ -82,5 +82,5 @@ export const actions = { commit('SET_QUICK_PENDING', false) commit('SET_QUICK_RESULTS', []) commit('SET_QUICK_VALUE', '') - } + }, }