chore: Fix lint w/ new linting rules

This commit is contained in:
mattwr18 2020-03-26 10:14:51 +01:00
parent e1733201e8
commit cb0a3f5cdd
108 changed files with 301 additions and 263 deletions

View File

@ -2,7 +2,7 @@ const svgFileList = require.context('./svgs', true, /\.svg/)
const icons = {}
const iconNames = []
svgFileList.keys().forEach((fileName) => {
svgFileList.keys().forEach(fileName => {
const svgCode = svgFileList(fileName)
const iconName = fileName.replace('./', '').replace('.svg', '')
icons[iconName] = svgCode

View File

@ -21,7 +21,7 @@ describe('AvatarMenu.vue', () => {
return { href: '/profile/u343/matt' }
}),
},
$t: jest.fn((a) => a),
$t: jest.fn(a => a),
}
getters = {
'auth/user': () => {
@ -86,21 +86,21 @@ describe('AvatarMenu.vue', () => {
it('displays a link to user profile', () => {
const profileLink = wrapper
.findAll('.ds-menu-item span')
.at(wrapper.vm.routes.findIndex((route) => route.path === '/profile/u343/matt'))
.at(wrapper.vm.routes.findIndex(route => route.path === '/profile/u343/matt'))
expect(profileLink.exists()).toBe(true)
})
it('displays a link to the notifications page', () => {
const notificationsLink = wrapper
.findAll('.ds-menu-item span')
.at(wrapper.vm.routes.findIndex((route) => route.path === '/notifications'))
.at(wrapper.vm.routes.findIndex(route => route.path === '/notifications'))
expect(notificationsLink.exists()).toBe(true)
})
it('displays a link to the settings page', () => {
const settingsLink = wrapper
.findAll('.ds-menu-item span')
.at(wrapper.vm.routes.findIndex((route) => route.path === '/settings'))
.at(wrapper.vm.routes.findIndex(route => route.path === '/settings'))
expect(settingsLink.exists()).toBe(true)
})
})
@ -121,7 +121,7 @@ describe('AvatarMenu.vue', () => {
it('displays a link to moderation page', () => {
const moderationLink = wrapper
.findAll('.ds-menu-item span')
.at(wrapper.vm.routes.findIndex((route) => route.path === '/moderation'))
.at(wrapper.vm.routes.findIndex(route => route.path === '/moderation'))
expect(moderationLink.exists()).toBe(true)
})
@ -147,7 +147,7 @@ describe('AvatarMenu.vue', () => {
it('displays a link to admin page', () => {
const adminLink = wrapper
.findAll('.ds-menu-item span')
.at(wrapper.vm.routes.findIndex((route) => route.path === '/admin'))
.at(wrapper.vm.routes.findIndex(route => route.path === '/admin'))
expect(adminLink.exists()).toBe(true)
})

View File

@ -29,8 +29,8 @@ describe('CommentCard.vue', () => {
locale: () => 'en',
},
$filters: {
truncate: (a) => a,
removeHtml: (a) => a,
truncate: a => a,
removeHtml: a => a,
},
$route: { hash: '' },
$scrollTo: jest.fn(),

View File

@ -25,7 +25,7 @@ describe('CommentForm.vue', () => {
success: jest.fn(),
},
$filters: {
removeHtml: (a) => a,
removeHtml: a => a,
},
}
})

View File

@ -104,7 +104,7 @@ export default {
this.disabled = true
this.$apollo
.mutate(mutateParams)
.then((res) => {
.then(res => {
this.loading = false
if (!this.update) {
const {
@ -125,7 +125,7 @@ export default {
this.closeEditWindow()
}
})
.catch((err) => {
.catch(err => {
this.$toast.error(err.message)
})
},

View File

@ -6,7 +6,7 @@ import Vue from 'vue'
const localVue = global.localVue
localVue.filter('truncate', (string) => string)
localVue.filter('truncate', string => string)
localVue.directive('scrollTo', jest.fn())
config.stubs['v-popover'] = '<span><slot /></span>'
@ -42,8 +42,8 @@ describe('CommentList.vue', () => {
mocks = {
$t: jest.fn(),
$filters: {
truncate: (a) => a,
removeHtml: (a) => a,
truncate: a => a,
removeHtml: a => a,
},
$scrollTo: jest.fn(),
$route: { hash: '' },

View File

@ -6,7 +6,7 @@ import faker from 'faker'
helpers.init()
const commentMock = (fields) => {
const commentMock = fields => {
return {
id: faker.random.uuid(),
title: faker.lorem.sentence(),

View File

@ -48,7 +48,7 @@ export default {
return anchor === '#comments'
},
updateCommentList(updatedComment) {
this.postComments = this.postComments.map((comment) => {
this.postComments = this.postComments.map(comment => {
return comment.id === updatedComment.id ? updatedComment : comment
})
},

View File

@ -17,7 +17,7 @@ let getters, mutations, mocks, menuToggle, openModalSpy
describe('ContentMenu.vue', () => {
beforeEach(() => {
mocks = {
$t: jest.fn((str) => str),
$t: jest.fn(str => str),
$i18n: {
locale: () => 'en',
},
@ -68,7 +68,7 @@ describe('ContentMenu.vue', () => {
expect(
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'post.menu.edit')
.filter(item => item.text() === 'post.menu.edit')
.at(0)
.find('span.ds-menu-item-link')
.attributes('to'),
@ -78,7 +78,7 @@ describe('ContentMenu.vue', () => {
it('can delete the contribution', () => {
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'post.menu.delete')
.filter(item => item.text() === 'post.menu.delete')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('confirm', 'delete')
@ -98,7 +98,7 @@ describe('ContentMenu.vue', () => {
})
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'post.menu.pin')
.filter(item => item.text() === 'post.menu.pin')
.at(0)
.trigger('click')
expect(wrapper.emitted('pinPost')).toEqual([
@ -122,7 +122,7 @@ describe('ContentMenu.vue', () => {
})
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'post.menu.unpin')
.filter(item => item.text() === 'post.menu.unpin')
.at(0)
.trigger('click')
expect(wrapper.emitted('unpinPost')).toEqual([
@ -151,7 +151,7 @@ describe('ContentMenu.vue', () => {
it('edit the comment', () => {
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'comment.menu.edit')
.filter(item => item.text() === 'comment.menu.edit')
.at(0)
.trigger('click')
expect(wrapper.emitted('editComment')).toBeTruthy()
@ -159,7 +159,7 @@ describe('ContentMenu.vue', () => {
it('delete the comment', () => {
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'comment.menu.delete')
.filter(item => item.text() === 'comment.menu.delete')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('confirm', 'delete')
@ -180,7 +180,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'report.contribution.title')
.filter(item => item.text() === 'report.contribution.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('report')
@ -197,7 +197,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'report.comment.title')
.filter(item => item.text() === 'report.comment.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('report')
@ -214,7 +214,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'report.user.title')
.filter(item => item.text() === 'report.user.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('report')
@ -231,7 +231,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'report.organization.title')
.filter(item => item.text() === 'report.organization.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('report')
@ -253,7 +253,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'disable.contribution.title')
.filter(item => item.text() === 'disable.contribution.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('disable')
@ -271,7 +271,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'disable.comment.title')
.filter(item => item.text() === 'disable.comment.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('disable')
@ -289,7 +289,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'disable.user.title')
.filter(item => item.text() === 'disable.user.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('disable')
@ -307,7 +307,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'disable.organization.title')
.filter(item => item.text() === 'disable.organization.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('disable')
@ -325,7 +325,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'release.contribution.title')
.filter(item => item.text() === 'release.contribution.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('release')
@ -343,7 +343,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'release.comment.title')
.filter(item => item.text() === 'release.comment.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('release')
@ -361,7 +361,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'release.user.title')
.filter(item => item.text() === 'release.user.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('release')
@ -379,7 +379,7 @@ describe('ContentMenu.vue', () => {
openModalSpy = jest.spyOn(wrapper.vm, 'openModal')
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'release.organization.title')
.filter(item => item.text() === 'release.organization.title')
.at(0)
.trigger('click')
expect(openModalSpy).toHaveBeenCalledWith('release')
@ -400,7 +400,7 @@ describe('ContentMenu.vue', () => {
expect(
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'settings.name')
.filter(item => item.text() === 'settings.name')
.at(0)
.find('span.ds-menu-item-link')
.attributes('to'),
@ -418,7 +418,7 @@ describe('ContentMenu.vue', () => {
})
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'settings.muted-users.mute')
.filter(item => item.text() === 'settings.muted-users.mute')
.at(0)
.trigger('click')
expect(wrapper.emitted('mute')).toEqual([
@ -442,7 +442,7 @@ describe('ContentMenu.vue', () => {
})
wrapper
.findAll('.ds-menu-item')
.filter((item) => item.text() === 'settings.muted-users.unmute')
.filter(item => item.text() === 'settings.muted-users.unmute')
.at(0)
.trigger('click')
expect(wrapper.emitted('unmute')).toEqual([

View File

@ -46,7 +46,7 @@ export default {
resourceType: {
type: String,
required: true,
validator: (value) => {
validator: value => {
return value.match(/(contribution|comment|organization|user)/)
},
},

View File

@ -140,9 +140,7 @@ describe('ContributionForm.vue', () => {
postTitleInput = wrapper.find('.ds-input')
postTitleInput.setValue(postTitle)
await wrapper.vm.updateEditorContent(postContent)
englishLanguage = wrapper
.findAll('li')
.filter((language) => language.text() === 'English')
englishLanguage = wrapper.findAll('li').filter(language => language.text() === 'English')
englishLanguage.trigger('click')
dataPrivacyButton = await wrapper
.find(CategoriesSelect)
@ -208,9 +206,7 @@ describe('ContributionForm.vue', () => {
postTitleInput.setValue(postTitle)
await wrapper.vm.updateEditorContent(postContent)
wrapper.find(CategoriesSelect).setData({ categories })
englishLanguage = wrapper
.findAll('li')
.filter((language) => language.text() === 'English')
englishLanguage = wrapper.findAll('li').filter(language => language.text() === 'English')
englishLanguage.trigger('click')
await Vue.nextTick()
dataPrivacyButton = await wrapper
@ -227,9 +223,7 @@ describe('ContributionForm.vue', () => {
it('supports changing the language', async () => {
expectedParams.variables.language = 'de'
deutschLanguage = wrapper
.findAll('li')
.filter((language) => language.text() === 'Deutsch')
deutschLanguage = wrapper.findAll('li').filter(language => language.text() === 'Deutsch')
deutschLanguage.trigger('click')
wrapper.find('form').trigger('submit')
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
@ -294,9 +288,7 @@ describe('ContributionForm.vue', () => {
await wrapper.vm.updateEditorContent(postContent)
categoryIds = ['cat12']
wrapper.find(CategoriesSelect).setData({ categories })
englishLanguage = wrapper
.findAll('li')
.filter((language) => language.text() === 'English')
englishLanguage = wrapper.findAll('li').filter(language => language.text() === 'English')
englishLanguage.trigger('click')
await Vue.nextTick()
dataPrivacyButton = await wrapper

View File

@ -108,7 +108,7 @@ export default {
data() {
const { title, content, image, language, categories } = this.contribution
const languageOptions = orderBy(locales, 'name').map((locale) => {
const languageOptions = orderBy(locales, 'name').map(locale => {
return { label: locale.name, value: locale.code }
})
const { sensitive: imageBlurred = false, aspectRatio: imageAspectRatio = null } = image || {}
@ -120,8 +120,8 @@ export default {
image: image || null,
imageAspectRatio,
imageBlurred,
language: languageOptions.find((option) => option.value === language) || null,
categoryIds: categories ? categories.map((category) => category.id) : [],
language: languageOptions.find(option => option.value === language) || null,
categoryIds: categories ? categories.map(category => category.id) : [],
},
formSchema: {
title: { required: true, min: 3, max: 100 },
@ -190,7 +190,7 @@ export default {
params: { id: result.id, slug: result.slug },
})
})
.catch((err) => {
.catch(err => {
this.$toast.error(err.message)
this.loading = false
})

View File

@ -90,7 +90,7 @@ export default {
this.logout()
this.$router.history.push('/')
})
.catch((error) => {
.catch(error => {
this.$toast.error(error.message)
})
},

View File

@ -12,7 +12,7 @@ describe('DonationInfo.vue', () => {
beforeEach(() => {
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
$i18n: {
locale: () => 'de',
},
@ -22,11 +22,19 @@ describe('DonationInfo.vue', () => {
const Wrapper = () => mount(DonationInfo, { mocks, localVue })
it('includes a link to the Human Connection donations website', () => {
expect(Wrapper().find('a').attributes('href')).toBe('https://human-connection.org/spenden/')
expect(
Wrapper()
.find('a')
.attributes('href'),
).toBe('https://human-connection.org/spenden/')
})
it('displays a call to action button', () => {
expect(Wrapper().find('.base-button').text()).toBe('donations.donate-now')
expect(
Wrapper()
.find('.base-button')
.text(),
).toBe('donations.donate-now')
})
it.skip('creates a title from the current month and a translation string', () => {

View File

@ -48,9 +48,8 @@ export default {
if (isOpen) {
this.$nextTick(() => {
setTimeout(() => {
const paddingRightStyle = `${
window.innerWidth - document.documentElement.clientWidth
}px`
const paddingRightStyle = `${window.innerWidth -
document.documentElement.clientWidth}px`
const navigationElement = document.querySelector('.main-navigation')
document.body.style.paddingRight = paddingRightStyle
document.body.classList.add('dropdown-open')

View File

@ -10,7 +10,7 @@ describe('DropdownFilter.vue', () => {
beforeEach(() => {
propsData = {}
mocks = {
$t: jest.fn((a) => a),
$t: jest.fn(a => a),
}
})
@ -43,7 +43,7 @@ describe('DropdownFilter.vue', () => {
wrapper.find('.dropdown-filter').trigger('click')
allLink = wrapper
.findAll('.dropdown-menu-item')
.at(propsData.filterOptions.findIndex((option) => option.label === 'All'))
.at(propsData.filterOptions.findIndex(option => option.label === 'All'))
})
it('displays a link for All', () => {
@ -53,21 +53,21 @@ describe('DropdownFilter.vue', () => {
it('displays a link for Read', () => {
const readLink = wrapper
.findAll('.dropdown-menu-item')
.at(propsData.filterOptions.findIndex((option) => option.label === 'Read'))
.at(propsData.filterOptions.findIndex(option => option.label === 'Read'))
expect(readLink.text()).toEqual('Read')
})
it('displays a link for Unread', () => {
const unreadLink = wrapper
.findAll('.dropdown-menu-item')
.at(propsData.filterOptions.findIndex((option) => option.label === 'Unread'))
.at(propsData.filterOptions.findIndex(option => option.label === 'Unread'))
expect(unreadLink.text()).toEqual('Unread')
})
it('clicking on menu item emits filter', () => {
allLink.trigger('click')
expect(wrapper.emitted().filter[0]).toEqual(
propsData.filterOptions.filter((option) => option.label === 'All'),
propsData.filterOptions.filter(option => option.label === 'All'),
)
})
})

View File

@ -35,7 +35,7 @@ const users = [
storiesOf('Editor', module)
.addDecorator(withA11y)
.addDecorator((storyFn) => {
.addDecorator(storyFn => {
const ctx = storyFn()
return {
components: { ctx },

View File

@ -80,7 +80,7 @@ export default {
items: () => {
return this.users
},
onEnter: (props) => this.openSuggestionList(props, MENTION),
onEnter: props => this.openSuggestionList(props, MENTION),
onChange: this.updateSuggestionList,
onExit: this.closeSuggestionList,
onKeyDown: this.navigateSuggestionList,
@ -95,7 +95,7 @@ export default {
items: () => {
return this.hashtags
},
onEnter: (props) => this.openSuggestionList(props, HASHTAG),
onEnter: props => this.openSuggestionList(props, HASHTAG),
onChange: this.updateSuggestionList,
onExit: this.closeSuggestionList,
onKeyDown: this.navigateSuggestionList,
@ -129,7 +129,7 @@ export default {
new EventHandler(),
new History(),
],
onUpdate: (e) => {
onUpdate: e => {
clearTimeout(throttleInputEvent)
throttleInputEvent = setTimeout(() => this.onUpdate(e), 300)
},
@ -197,7 +197,7 @@ export default {
return items.slice(0, 15)
}
const filteredList = items.filter((item) => {
const filteredList = items.filter(item => {
const itemString = item.slug || item.id
return itemString.toLowerCase().includes(query.toLowerCase())
})

View File

@ -14,7 +14,7 @@
<menu-bar-button
ref="linkButton"
:isActive="isActive.link()"
:onClick="(event) => toggleLinkInput(getMarkAttrs('link'), event.currentTarget)"
:onClick="event => toggleLinkInput(getMarkAttrs('link'), event.currentTarget)"
icon="link"
/>

View File

@ -11,7 +11,7 @@
</li>
<template v-if="isHashtag">
<li v-if="!query" class="suggestion-list__item hint">{{ $t('editor.hashtag.addLetter') }}</li>
<template v-else-if="!filteredItems.find((el) => el.id === query)">
<template v-else-if="!filteredItems.find(el => el.id === query)">
<li class="suggestion-list__item hint">{{ $t('editor.hashtag.addHashtag') }}</li>
<li class="suggestion-list__item" @click="selectItem({ id: query })">
#{{ query | truncate(50) }}

View File

@ -2,10 +2,10 @@ import { Plugin } from 'prosemirror-state'
import { Slice, Fragment } from 'prosemirror-model'
export default function(regexp, type, getAttrs) {
const handler = (fragment) => {
const handler = fragment => {
const nodes = []
fragment.forEach((child) => {
fragment.forEach(child => {
if (child.isText) {
const { text } = child
let pos = 0
@ -43,7 +43,7 @@ export default function (regexp, type, getAttrs) {
return new Plugin({
props: {
transformPasted: (slice) => new Slice(handler(slice.content), slice.openStart, slice.openEnd),
transformPasted: slice => new Slice(handler(slice.content), slice.openStart, slice.openEnd),
},
})
}

View File

@ -26,7 +26,7 @@ export default class Embed extends Node {
// source: https://stackoverflow.com/a/3809435
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g,
type,
(url) => ({ dataEmbedUrl: url }),
url => ({ dataEmbedUrl: url }),
),
]
}
@ -43,12 +43,12 @@ export default class Embed extends Node {
parseDOM: [
{
tag: 'a[href].embed',
getAttrs: (dom) => ({
getAttrs: dom => ({
dataEmbedUrl: dom.getAttribute('href'),
}),
},
],
toDOM: (node) => [
toDOM: node => [
'a',
{
href: node.attrs.dataEmbedUrl,

View File

@ -20,7 +20,7 @@ export default class Hashtag extends TipTapMention {
get schema() {
return {
...super.schema,
toDOM: (node) => {
toDOM: node => {
// use a dummy domain because URL cannot handle relative urls
const url = new URL('/', 'https://human-connection.org')
url.searchParams.append('hashtag', node.attrs.id)
@ -39,7 +39,7 @@ export default class Hashtag extends TipTapMention {
parseDOM: [
{
tag: 'a[data-hashtag-id]',
getAttrs: (dom) => {
getAttrs: dom => {
const id = dom.getAttribute('data-hashtag-id')
const label = dom.innerText.split(this.options.matcher.char).join('')
return { id, label }

View File

@ -26,7 +26,7 @@ export default class Embed extends Node {
// source: https://stackoverflow.com/a/3809435
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g,
type,
(url) => ({ dataEmbedUrl: url }),
url => ({ dataEmbedUrl: url }),
),
]
}
@ -43,12 +43,12 @@ export default class Embed extends Node {
parseDOM: [
{
tag: 'a[href].embed',
getAttrs: (dom) => ({
getAttrs: dom => ({
dataEmbedUrl: dom.getAttribute('href'),
}),
},
],
toDOM: (node) => [
toDOM: node => [
'a',
{
href: node.attrs.dataEmbedUrl,

View File

@ -17,12 +17,12 @@ export default class Link extends TipTapLink {
{
// if this is an embed link or a hashtag, ignore
tag: 'a[href]:not(.embed):not([data-hashtag-id])',
getAttrs: (dom) => ({
getAttrs: dom => ({
href: dom.getAttribute('href'),
}),
},
],
toDOM: (node) => [
toDOM: node => [
'a',
{
...node.attrs,

View File

@ -8,7 +8,7 @@ export default class Mention extends TipTapMention {
get schema() {
return {
...super.schema,
toDOM: (node) => {
toDOM: node => {
return [
'a',
{

View File

@ -17,7 +17,7 @@ describe('EmbedComponent.vue', () => {
beforeEach(() => {
mocks = {
$t: (a) => a,
$t: a => a,
$apollo: {
mutate: jest
.fn()

View File

@ -37,7 +37,7 @@ export default {
}),
},
created() {
Object.keys(this.PostsEmotionsCountByEmotion).map((emotion) => {
Object.keys(this.PostsEmotionsCountByEmotion).map(emotion => {
this.emotionsCount(emotion)
})
},

View File

@ -27,7 +27,7 @@ export default {
icon: {
type: String,
default: 'alert',
validator: (value) => {
validator: value => {
return value.match(/(messages|events|alert|tasks|docs|file)/)
},
},

View File

@ -12,7 +12,7 @@ describe('ImageUploader.vue', () => {
$toast: {
error: jest.fn(),
},
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
})
describe('mount', () => {

View File

@ -93,7 +93,7 @@ export default {
if (this.file.type === 'image/jpeg') {
const canvas = this.cropper.getCroppedCanvas()
canvas.toBlob((blob) => {
canvas.toBlob(blob => {
const imageAspectRatio = canvas.width / canvas.height
const croppedImageFile = new File([blob], this.file.name, { type: this.file.type })
onCropComplete(imageAspectRatio, croppedImageFile)

View File

@ -14,12 +14,12 @@ describe('LocaleSwitch.vue', () => {
mocks = {
$i18n: {
locale: () => 'en',
set: jest.fn((locale) => locale),
set: jest.fn(locale => locale),
},
$t: jest.fn(),
$toast: {
success: jest.fn((a) => a),
error: jest.fn((a) => a),
success: jest.fn(a => a),
error: jest.fn(a => a),
},
setPlaceholderText: jest.fn(),
$apollo: {

View File

@ -52,7 +52,7 @@ export default {
return find(this.locales, { code: this.$i18n.locale() })
},
routes() {
const routes = this.locales.map((locale) => {
const routes = this.locales.map(locale => {
return {
name: locale.name,
path: locale.code,

View File

@ -8,7 +8,7 @@
const landscapeRatio = 1.3
const squareRatio = 1
const portraitRatio = 0.7
const getRowSpan = (aspectRatio) => {
const getRowSpan = aspectRatio => {
if (aspectRatio >= landscapeRatio) return 13
else if (aspectRatio >= squareRatio) return 15
else if (aspectRatio >= portraitRatio) return 18

View File

@ -15,7 +15,7 @@ describe('Modal.vue', () => {
let state
let mocks
const createWrapper = (mountMethod) => {
const createWrapper = mountMethod => {
return () => {
store = new Vuex.Store({
state,
@ -38,7 +38,7 @@ describe('Modal.vue', () => {
beforeEach(() => {
mocks = {
$filters: {
truncate: (a) => a,
truncate: a => a,
},
$toast: {
success: () => {},

View File

@ -26,7 +26,7 @@ describe('ConfirmModal.vue', () => {
mocks = {
$t: jest.fn(),
$filters: {
truncate: (a) => a,
truncate: a => a,
},
}
})

View File

@ -16,7 +16,7 @@ describe('DisableModal.vue', () => {
}
mocks = {
$filters: {
truncate: (a) => a,
truncate: a => a,
},
$toast: {
success: jest.fn(),
@ -24,7 +24,10 @@ describe('DisableModal.vue', () => {
},
$t: jest.fn(),
$apollo: {
mutate: jest.fn().mockResolvedValueOnce().mockRejectedValue({
mutate: jest
.fn()
.mockResolvedValueOnce()
.mockRejectedValue({
message: 'Not Authorised!',
}),
},

View File

@ -17,9 +17,9 @@ describe('ReportModal.vue', () => {
id: 'c43',
}
mocks = {
$t: jest.fn((a) => a),
$t: jest.fn(a => a),
$filters: {
truncate: (a) => a,
truncate: a => a,
},
$toast: {
success: () => {},

View File

@ -77,7 +77,7 @@ export default {
}
},
created() {
this.form.reasonCategoryOptions = valuesReasonCategoryOptions.map((reasonCategory) => {
this.form.reasonCategoryOptions = valuesReasonCategoryOptions.map(reasonCategory => {
return {
label: this.$t('report.reason.category.options.' + reasonCategory),
value: reasonCategory,
@ -134,7 +134,7 @@ export default {
}, 1500)
this.loading = false
})
.catch((err) => {
.catch(err => {
this.$emit('close')
this.success = false
switch (err.message) {

View File

@ -16,7 +16,7 @@ describe('Notification', () => {
beforeEach(() => {
propsData = {}
mocks = {
$t: (key) => key,
$t: key => key,
}
stubs = {
NuxtLink: RouterLinkStub,

View File

@ -7,7 +7,7 @@ import { notifications } from '~/components/utils/Notifications'
const localVue = global.localVue
localVue.filter('truncate', (string) => string)
localVue.filter('truncate', string => string)
config.stubs['client-only'] = '<span><slot /></span>'
config.stubs['v-popover'] = '<span><slot /></span>'

View File

@ -3,7 +3,7 @@ import NotificationMenu from './NotificationMenu'
const localVue = global.localVue
localVue.filter('truncate', (string) => string)
localVue.filter('truncate', string => string)
config.stubs.dropdown = '<span class="dropdown"><slot :toggleMenu="() => null" /></span>'

View File

@ -98,7 +98,7 @@ export default {
notifications: unionBy(
[newNotification],
previousResult.notifications,
(notification) => notification.id,
notification => notification.id,
).sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt)),
}
},

View File

@ -6,7 +6,7 @@ import NotificationsTable from './NotificationsTable'
import { notifications } from '~/components/utils/Notifications'
const localVue = global.localVue
localVue.filter('truncate', (string) => string)
localVue.filter('truncate', string => string)
config.stubs['client-only'] = '<span><slot /></span>'
@ -17,7 +17,7 @@ describe('NotificationsTable.vue', () => {
beforeEach(() => {
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
stubs = {
NuxtLink: RouterLinkStub,
@ -96,7 +96,7 @@ describe('NotificationsTable.vue', () => {
it('renders the reason for the notification', () => {
const dsTexts = firstRowNotification.findAll('.ds-text')
const reason = dsTexts.filter(
(element) => element.text() === 'notifications.reason.mentioned_in_post',
element => element.text() === 'notifications.reason.mentioned_in_post',
)
expect(reason.exists()).toBe(true)
})
@ -109,7 +109,7 @@ describe('NotificationsTable.vue', () => {
it("renders the Post's content", () => {
const boldTags = firstRowNotification.findAll('b')
const content = boldTags.filter(
(element) => element.text() === postNotification.from.contentExcerpt,
element => element.text() === postNotification.from.contentExcerpt,
)
expect(content.exists()).toBe(true)
})
@ -129,7 +129,7 @@ describe('NotificationsTable.vue', () => {
it('renders the reason for the notification', () => {
const dsTexts = secondRowNotification.findAll('.ds-text')
const reason = dsTexts.filter(
(element) => element.text() === 'notifications.reason.mentioned_in_comment',
element => element.text() === 'notifications.reason.mentioned_in_comment',
)
expect(reason.exists()).toBe(true)
})
@ -142,7 +142,7 @@ describe('NotificationsTable.vue', () => {
it("renders the Post's content", () => {
const boldTags = secondRowNotification.findAll('b')
const content = boldTags.filter(
(element) => element.text() === commentNotification.from.contentExcerpt,
element => element.text() === commentNotification.from.contentExcerpt,
)
expect(content.exists()).toBe(true)
})

View File

@ -90,7 +90,7 @@ describe('ChangePassword.vue', () => {
})
describe('submit form', () => {
beforeEach(async (done) => {
beforeEach(async done => {
await wrapper.find('form').trigger('submit')
done()
})

View File

@ -16,7 +16,7 @@ describe('Request', () => {
success: jest.fn(),
error: jest.fn(),
},
$t: jest.fn((t) => t),
$t: jest.fn(t => t),
$apollo: {
loading: false,
mutate: jest.fn().mockResolvedValue({ data: { reqestPasswordReset: true } }),

View File

@ -15,11 +15,19 @@ describe('ProgessBar.vue', () => {
describe('given only goal and progress', () => {
it('renders no title', () => {
expect(Wrapper().find('.progress-bar__title').exists()).toBe(false)
expect(
Wrapper()
.find('.progress-bar__title')
.exists(),
).toBe(false)
})
it('renders no label', () => {
expect(Wrapper().find('.progress-bar__label').exists()).toBe(false)
expect(
Wrapper()
.find('.progress-bar__label')
.exists(),
).toBe(false)
})
it('calculates the progress bar width as a percentage of the goal', () => {
@ -33,7 +41,11 @@ describe('ProgessBar.vue', () => {
})
it('renders the title', () => {
expect(Wrapper().find('.progress-bar__title').text()).toBe('This is progress')
expect(
Wrapper()
.find('.progress-bar__title')
.text(),
).toBe('This is progress')
})
})
@ -43,7 +55,11 @@ describe('ProgessBar.vue', () => {
})
it('renders the label', () => {
expect(Wrapper().find('.progress-bar__label').text()).toBe('Going well')
expect(
Wrapper()
.find('.progress-bar__label')
.text(),
).toBe('Going well')
})
})
})

View File

@ -17,7 +17,7 @@ describe('ReleaseModal.vue', () => {
}
mocks = {
$filters: {
truncate: (a) => a,
truncate: a => a,
},
$toast: {
success: jest.fn(),
@ -25,7 +25,10 @@ describe('ReleaseModal.vue', () => {
},
$t: jest.fn(),
$apollo: {
mutate: jest.fn().mockResolvedValueOnce().mockRejectedValue({ message: 'Not Authorised!' }),
mutate: jest
.fn()
.mockResolvedValueOnce()
.mockRejectedValue({ message: 'Not Authorised!' }),
},
location: {
reload: jest.fn(),

View File

@ -66,7 +66,7 @@ export default {
id: this.postId,
},
})
.then((res) => {
.then(res => {
if (res && res.data) {
this.$emit('update', shout)
}

View File

@ -79,7 +79,7 @@ export default {
.then(() => {
this.$toast.success(this.$t('user.avatar.submitted'))
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
verror(file, message) {
if (file.status === 'error') {

View File

@ -3,7 +3,7 @@ import UserTeaser from './UserTeaser.vue'
import Vuex from 'vuex'
const localVue = global.localVue
const filter = jest.fn((str) => str)
const filter = jest.fn(str => str)
localVue.filter('truncate', filter)

View File

@ -3,7 +3,7 @@
:class="buttonClass"
:disabled="loading"
:type="type"
@click.capture="(event) => $emit('click', event)"
@click.capture="event => $emit('click', event)"
>
<base-icon v-if="icon" :name="icon" />
<loading-spinner v-if="loading" />

View File

@ -18,7 +18,7 @@ export default {
size: {
type: String,
required: false,
validator: (value) => {
validator: value => {
return value.match(/(small|large)/)
},
},
@ -34,7 +34,11 @@ export default {
userInitials() {
if (this.isAnonymous) return ''
return this.user.name.match(/\b\w/g).join('').substring(0, 3).toUpperCase()
return this.user.name
.match(/\b\w/g)
.join('')
.substring(0, 3)
.toUpperCase()
},
},
}

View File

@ -5,7 +5,7 @@ import { reports } from '~/components/features/ReportList/ReportList.story.js'
const localVue = global.localVue
localVue.filter('truncate', (string) => string)
localVue.filter('truncate', string => string)
config.stubs['client-only'] = '<span><slot /></span>'
@ -14,7 +14,7 @@ describe('FiledReportsTable.vue', () => {
beforeEach(() => {
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
stubs = {
NuxtLink: RouterLinkStub,
@ -47,7 +47,7 @@ describe('FiledReportsTable.vue', () => {
describe('given reports', () => {
beforeEach(() => {
filed = reports.map((report) => report.filed)
filed = reports.map(report => report.filed)
propsData.filed = filed[0]
wrapper = Wrapper()
})
@ -74,7 +74,7 @@ describe('FiledReportsTable.vue', () => {
it('renders the category text', () => {
const columns = wrapper.findAll('.ds-table-col')
const reasonCategory = columns.filter(
(category) =>
category =>
category.text() === 'report.reason.category.options.pornographic_content_links',
)
expect(reasonCategory.exists()).toBe(true)
@ -83,7 +83,7 @@ describe('FiledReportsTable.vue', () => {
it("renders the Post's content", () => {
const columns = wrapper.findAll('.ds-table-col')
const reasonDescription = columns.filter(
(column) => column.text() === 'This comment is porno!!!',
column => column.text() === 'This comment is porno!!!',
)
expect(reasonDescription.exists()).toBe(true)
})

View File

@ -25,7 +25,7 @@ describe('ReportList', () => {
},
$t: jest.fn(),
$toast: {
error: jest.fn((message) => message),
error: jest.fn(message => message),
},
}
mutations = {

View File

@ -158,9 +158,9 @@ export const reports = [
],
},
]
const unreviewedReports = reports.filter((report) => !report.reviewed)
const reviewedReports = reports.filter((report) => report.reviewed)
const closedReports = reports.filter((report) => report.closed)
const unreviewedReports = reports.filter(report => !report.reviewed)
const reviewedReports = reports.filter(report => report.reviewed)
const closedReports = reports.filter(report => report.closed)
const filterOptions = [
{ label: 'All', value: reports },
{ label: 'Unreviewed', value: unreviewedReports },

View File

@ -131,7 +131,7 @@ export default {
this.$toast.success(this.$t('moderation.reports.DecisionSuccess'))
this.$apollo.queries.reportsList.refetch()
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
openModal(report) {
this.commitModalData(this.modalData(report))

View File

@ -14,7 +14,7 @@ describe('ReportRow', () => {
beforeEach(() => {
propsData = {}
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
stubs = {
NuxtLink: RouterLinkStub,
@ -62,7 +62,7 @@ describe('ReportRow', () => {
it('renders a decided text', () => {
const decidedTitle = wrapper
.findAll('.title')
.filter((title) => title.text() === 'moderation.reports.decided')
.filter(title => title.text() === 'moderation.reports.decided')
expect(decidedTitle.exists()).toBe(true)
})
})
@ -85,7 +85,12 @@ describe('ReportRow', () => {
wrapper = Wrapper()
})
it('renders the disabled icon', () => {
expect(wrapper.find('.status-line').find(BaseIcon).props().name).toEqual('eye-slash')
expect(
wrapper
.find('.status-line')
.find(BaseIcon)
.props().name,
).toEqual('eye-slash')
})
it('renders its current status', () => {
@ -99,7 +104,12 @@ describe('ReportRow', () => {
wrapper = Wrapper()
})
it('renders the enabled icon', () => {
expect(wrapper.find('.status-line').find(BaseIcon).props().name).toEqual('eye')
expect(
wrapper
.find('.status-line')
.find(BaseIcon)
.props().name,
).toEqual('eye')
})
it('renders its current status', () => {

View File

@ -14,7 +14,7 @@ describe('ReportsTable', () => {
beforeEach(() => {
propsData = {}
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
getters = {
'auth/user': () => {

View File

@ -16,7 +16,7 @@ describe('SearchField.vue', () => {
$apollo: {
query: jest.fn(),
},
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
getters = { 'auth/isModerator': () => false }
wrapper = Wrapper()

View File

@ -7,7 +7,7 @@ describe('SearchHeading.vue', () => {
let mocks, wrapper, propsData
beforeEach(() => {
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
propsData = {
resourceType: 'Post',

View File

@ -2,13 +2,13 @@ import { shallowMount } from '@vue/test-utils'
import SearchPost from './SearchPost.vue'
const localVue = global.localVue
localVue.filter('dateTime', (d) => d)
localVue.filter('dateTime', d => d)
describe('SearchPost.vue', () => {
let mocks, wrapper, propsData
beforeEach(() => {
mocks = {
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
propsData = {
option: {
@ -38,7 +38,7 @@ describe('SearchPost.vue', () => {
wrapper
.find('.search-post-meta')
.findAll('span')
.filter((item) => item.text() === '3')
.filter(item => item.text() === '3')
.exists(),
).toBe(true)
})
@ -48,7 +48,7 @@ describe('SearchPost.vue', () => {
wrapper
.find('.search-post-meta')
.findAll('span')
.filter((item) => item.text() === '6')
.filter(item => item.text() === '6')
.exists(),
).toBe(true)
})

View File

@ -19,7 +19,7 @@ describe('SearchableInput.vue', () => {
$router: {
push: jest.fn(),
},
$t: jest.fn((string) => string),
$t: jest.fn(string => string),
}
getters = { 'auth/isModerator': () => false }
wrapper = Wrapper()
@ -98,7 +98,7 @@ describe('SearchableInput.vue', () => {
select.element.value = 'Bob'
select.trigger('input')
const users = wrapper.findAll('.slug')
const bob = users.filter((item) => item.text().match(/@bob-der-baumeister/))
const bob = users.filter(item => item.text().match(/@bob-der-baumeister/))
bob.trigger('click')
await Vue.nextTick()
expect(mocks.$router.push).toHaveBeenCalledWith({
@ -111,7 +111,7 @@ describe('SearchableInput.vue', () => {
select.element.value = 'Hash'
select.trigger('input')
const tags = wrapper.findAll('.hc-hashtag')
const tag = tags.filter((item) => item.text().match(/#Hashtag/))
const tag = tags.filter(item => item.text().match(/#Hashtag/))
tag.trigger('click')
await Vue.nextTick()
expect(mocks.$router.push).toHaveBeenCalledWith('?hashtag=Hashtag')

View File

@ -9,7 +9,7 @@
:icon-right="null"
:options="options"
:loading="loading"
:filter="(item) => item"
:filter="item => item"
:no-options-available="emptyText"
:auto-reset-search="!searchValue"
:placeholder="$t('search.placeholder')"
@ -88,8 +88,8 @@ export default {
methods: {
isFirstOfType(option) {
return (
this.options.findIndex((o) => o === option) ===
this.options.findIndex((o) => o.__typename === option.__typename)
this.options.findIndex(o => o === option) ===
this.options.findIndex(o => o.__typename === option.__typename)
)
},
onFocus(event) {

View File

@ -1,6 +1,6 @@
import { normalizeEmail } from 'validator'
export default (email) =>
export default email =>
normalizeEmail(email, {
// gmail_remove_dots: false, default
gmail_remove_subaddress: false,

View File

@ -8,7 +8,7 @@ beforeEach(() => {
})
describe('validReport', () => {
const validate = (object) => {
const validate = object => {
const { formSchema } = validReport({ translate })
const validator = new Schema(formSchema)
return validator.validate(object, { suppressWarning: true }).catch(({ errors }) => {

View File

@ -15,7 +15,7 @@ export default function UniqueSlugForm({ translate, apollo, currentUser }) {
asyncValidator(rule, value, callback) {
debounce(() => {
const variables = { slug: value }
apollo.query({ query: checkSlugAvailableQuery, variables }).then((response) => {
apollo.query({ query: checkSlugAvailableQuery, variables }).then(response => {
const {
data: { User },
} = response

View File

@ -14,7 +14,7 @@ beforeEach(() => {
})
describe('UniqueSlugForm', () => {
const validate = (object) => {
const validate = object => {
const { formSchema } = UniqueSlugForm({ translate, apollo, currentUser })
const validator = new Schema(formSchema)
return validator.validate(object, { suppressWarning: true }).catch(({ errors }) => {

View File

@ -10,7 +10,7 @@ export default function UpdateQuery(component, { $state, pageKey }) {
$state.complete()
}
const result = {}
result[pageKey] = unionBy(oldData, newData, (item) => item.id)
result[pageKey] = unionBy(oldData, newData, item => item.id)
$state.loaded()
return result
}

View File

@ -1,6 +1,6 @@
import gql from 'graphql-tag'
export default (i18n) => {
export default i18n => {
const lang = i18n.locale().toUpperCase()
return {
CreateComment: gql`

View File

@ -1,6 +1,6 @@
import gql from 'graphql-tag'
export default (app) => {
export default app => {
const lang = app.$i18n.locale().toUpperCase()
return gql`
query Comment($postId: ID) {

View File

@ -12,7 +12,7 @@ export const userFragment = gql`
deleted
}
`
export const locationAndBadgesFragment = (lang) => gql`
export const locationAndBadgesFragment = lang => gql`
fragment locationAndBadges on User {
location {
name: name${lang}

View File

@ -9,7 +9,7 @@ import {
tagsCategoriesAndPinnedFragment,
} from './Fragments'
export default (i18n) => {
export default i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment}
@ -44,7 +44,7 @@ export default (i18n) => {
`
}
export const filterPosts = (i18n) => {
export const filterPosts = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment}
@ -69,7 +69,7 @@ export const filterPosts = (i18n) => {
`
}
export const profilePagePosts = (i18n) => {
export const profilePagePosts = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment}
@ -107,7 +107,7 @@ export const PostsEmotionsByCurrentUser = () => {
`
}
export const relatedContributions = (i18n) => {
export const relatedContributions = i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment}

View File

@ -7,7 +7,7 @@ import {
commentFragment,
} from './Fragments'
export default (i18n) => {
export default i18n => {
const lang = i18n.locale().toUpperCase()
return gql`
${userFragment}
@ -61,7 +61,7 @@ export const minimisedUserQuery = () => {
`
}
export const notificationQuery = (i18n) => {
export const notificationQuery = i18n => {
return gql`
${userFragment}
${commentFragment}
@ -100,7 +100,7 @@ export const notificationQuery = (i18n) => {
`
}
export const markAsReadMutation = (i18n) => {
export const markAsReadMutation = i18n => {
return gql`
${userFragment}
${commentFragment}
@ -174,7 +174,7 @@ export const notificationAdded = () => {
}
`
}
export const followUserMutation = (i18n) => {
export const followUserMutation = i18n => {
return gql`
${userFragment}
${userCountsFragment}
@ -194,7 +194,7 @@ export const followUserMutation = (i18n) => {
`
}
export const unfollowUserMutation = (i18n) => {
export const unfollowUserMutation = i18n => {
return gql`
${userFragment}
${userCountsFragment}

View File

@ -10,7 +10,7 @@ describe('error.vue', () => {
beforeEach(() => {
mocks = {
$t: jest.fn((key) => key),
$t: jest.fn(key => key),
}
})

View File

@ -1,7 +1,7 @@
export default function(options = {}) {
const { queryId, querySlug, path, message = 'Page not found.' } = options
return {
asyncData: async (context) => {
asyncData: async context => {
const {
params: { id, slug },
redirect,

View File

@ -261,7 +261,7 @@ export default {
})
}
const svgRule = config.module.rules.find((rule) => rule.test.test('.svg'))
const svgRule = config.module.rules.find(rule => rule.test.test('.svg'))
svgRule.test = /\.(png|jpe?g|gif|webp)$/
config.module.rules.push({
test: /\.svg$/,
@ -291,10 +291,10 @@ export default {
preTransformNode(abstractSyntaxTreeElement) {
if (!ctx.isDev) {
const { attrsMap, attrsList } = abstractSyntaxTreeElement
tagAttributesForTesting.forEach((attribute) => {
tagAttributesForTesting.forEach(attribute => {
if (attrsMap[attribute]) {
delete attrsMap[attribute]
const index = attrsList.findIndex((attr) => attr.name === attribute)
const index = attrsList.findIndex(attr => attr.name === attribute)
attrsList.splice(index, 1)
}
})

View File

@ -42,7 +42,7 @@ export default {
.then(() => {
this.$toast.success(this.$t('admin.donations.successfulUpdate'))
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
},
apollo: {

View File

@ -48,9 +48,9 @@ describe('PostIndex', () => {
mutations,
})
mocks = {
$t: (key) => key,
$t: key => key,
$filters: {
truncate: (a) => a,
truncate: a => a,
removeLinks: jest.fn(),
},
$i18n: {
@ -120,7 +120,10 @@ describe('PostIndex', () => {
})
it('calls store when using order by menu', () => {
wrapper.findAll('li').at(0).trigger('click')
wrapper
.findAll('li')
.at(0)
.trigger('click')
expect(mutations['posts/SELECT_ORDER']).toHaveBeenCalledWith({}, 'createdAt_asc')
})
})

View File

@ -161,7 +161,7 @@ export default {
})
},
deletePost(deletedPost) {
this.posts = this.posts.filter((post) => {
this.posts = this.posts.filter(post => {
return post.id !== deletedPost.id
})
},
@ -181,7 +181,7 @@ export default {
this.resetPostList()
this.$apollo.queries.Post.refetch()
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
unpinPost(post) {
this.$apollo
@ -194,7 +194,7 @@ export default {
this.resetPostList()
this.$apollo.queries.Post.refetch()
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
},
apollo: {

View File

@ -15,9 +15,9 @@ describe('PostIndex', () => {
beforeEach(() => {
propsData = {}
mocks = {
$t: (string) => string,
$t: string => string,
$toast: {
error: jest.fn((string) => string),
error: jest.fn(string => string),
},
$i18n: {
locale: () => 'en',

View File

@ -48,8 +48,8 @@ describe('PostSlug', () => {
mocks = {
$t: jest.fn(),
$filters: {
truncate: (a) => a,
removeHtml: (a) => a,
truncate: a => a,
removeHtml: a => a,
},
$route: {
hash: '',

View File

@ -205,7 +205,7 @@ export default {
.then(() => {
this.$toast.success(this.$t('post.menu.pinnedSuccessfully'))
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
unpinPost(post) {
this.$apollo
@ -216,7 +216,7 @@ export default {
.then(() => {
this.$toast.success(this.$t('post.menu.unpinnedSuccessfully'))
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
toggleNewCommentForm(showNewCommentForm) {
this.showNewCommentForm = showNewCommentForm

View File

@ -65,7 +65,7 @@ export default {
},
methods: {
removePostFromList(deletedPost) {
this.post.relatedContributions = this.post.relatedContributions.filter((contribution) => {
this.post.relatedContributions = this.post.relatedContributions.filter(contribution => {
return contribution.id !== deletedPost.id
})
},

View File

@ -3,7 +3,7 @@ import ProfileSlug from './_slug.vue'
const localVue = global.localVue
localVue.filter('date', (d) => d)
localVue.filter('date', d => d)
config.stubs['client-only'] = '<span><slot /></span>'
config.stubs['v-popover'] = '<span><slot /></span>'
@ -56,8 +56,8 @@ describe('ProfileSlug', () => {
describe('given an authenticated user', () => {
beforeEach(() => {
mocks.$filters = {
removeLinks: (c) => c,
truncate: (a) => a,
removeLinks: c => c,
truncate: a => a,
}
mocks.$store = {
getters: {

View File

@ -337,7 +337,7 @@ export default {
},
socialMediaLinks() {
const { socialMedia = [] } = this.user
return socialMedia.map((socialMedia) => {
return socialMedia.map(socialMedia => {
const { url } = socialMedia
const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
const [domain] = matches || []
@ -364,7 +364,7 @@ export default {
},
methods: {
removePostFromList(deletedPost) {
this.posts = this.posts.filter((post) => {
this.posts = this.posts.filter(post => {
return post.id !== deletedPost.id
})
},
@ -447,7 +447,7 @@ export default {
this.resetPostList()
this.$apollo.queries.profilePagePosts.refetch()
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
unpinPost(post) {
this.$apollo
@ -460,7 +460,7 @@ export default {
this.resetPostList()
this.$apollo.queries.profilePagePosts.refetch()
})
.catch((error) => this.$toast.error(error.message))
.catch(error => this.$toast.error(error.message))
},
optimisticFollow({ followedByCurrentUser }) {
/*
@ -473,7 +473,7 @@ export default {
this.user.followedBy = [currentUser, ...this.user.followedBy]
} else {
this.user.followedByCount--
this.user.followedBy = this.user.followedBy.filter((user) => user.id !== currentUser.id)
this.user.followedBy = this.user.followedBy.filter(user => user.id !== currentUser.id)
}
this.user.followedByCurrentUser = followedByCurrentUser
},

View File

@ -58,7 +58,7 @@ export default {
}
},
mounted() {
axios.get('/api/providers.json').then((response) => {
axios.get('/api/providers.json').then(response => {
this.providers = response.data
})
if (this.currentUser.allowEmbedIframes) this.disabled = this.currentUser.allowEmbedIframes

View File

@ -128,7 +128,7 @@ export default {
return []
}
const output = []
res.data.features.forEach((item) => {
res.data.features.forEach(item => {
output.push({
label: item.place_name,
value: item.place_name,
@ -162,7 +162,7 @@ export default {
cancelToken: this.axiosSource.token,
},
)
.then((res) => {
.then(res => {
this.cities = this.processCityResults(res)
})
.finally(() => {

View File

@ -10,7 +10,7 @@ describe('EnterNoncePage', () => {
beforeEach(() => {
wrapper = null
mocks = {
$t: jest.fn((t) => t),
$t: jest.fn(t => t),
$route: {
query: {},
},

View File

@ -21,7 +21,7 @@ describe('EmailSettingsIndexPage', () => {
},
})
mocks = {
$t: jest.fn((t) => t),
$t: jest.fn(t => t),
$toast: {
success: jest.fn(),
error: jest.fn(),

View File

@ -27,7 +27,7 @@ describe('EmailVerifyPage', () => {
},
})
mocks = {
$t: jest.fn((t) => t),
$t: jest.fn(t => t),
$toast: {
success: jest.fn(),
error: jest.fn(),

View File

@ -141,7 +141,7 @@ export default {
},
update: (store, { data }) => {
const socialMedia = this.currentUser.socialMedia.filter(
(element) => element.id !== link.id,
element => element.id !== link.id,
)
this.setCurrentUser({
...this.currentUser,
@ -159,7 +159,7 @@ export default {
const isEditing = !!this.editingLink.id
const url = this.formData.socialMediaUrl
const duplicateUrl = this.socialMediaLinks.find((link) => link.url === url)
const duplicateUrl = this.socialMediaLinks.find(link => link.url === url)
if (duplicateUrl && duplicateUrl.id !== this.editingLink.id) {
return this.$toast.error(this.$t('settings.social-media.requireUnique'))
}

View File

@ -1,5 +1,5 @@
export default ({ $axios, app }) => {
$axios.onRequest((config) => {
$axios.onRequest(config => {
/* eslint-disable-next-line no-console */
console.log(Object.keys(app))
// add current ui language

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
const componentFiles = require.context('../components/_new/generic', true, /Base[a-zA-Z]+\.vue/)
componentFiles.keys().forEach((fileName) => {
componentFiles.keys().forEach(fileName => {
const component = componentFiles(fileName)
const componentConfig = component.default || component
const componentName = component.name || fileName.replace(/^.+\//, '').replace('.vue', '')

View File

@ -11,7 +11,7 @@ export default ({ app, req, cookie, store }) => {
const debug = app.$env && app.$env.NODE_ENV !== 'production'
const key = 'locale'
const changeHandler = async (mutation) => {
const changeHandler = async mutation => {
if (process.server) return
const newLocale = mutation.payload.locale
@ -24,7 +24,7 @@ export default ({ app, req, cookie, store }) => {
app.$cookies.set(key, newLocale)
if (!app.$i18n.localeExists(newLocale)) {
import(`~/locales/${newLocale}.json`).then((res) => {
import(`~/locales/${newLocale}.json`).then(res => {
app.$i18n.add(newLocale, res.default)
})
}
@ -77,7 +77,7 @@ export default ({ app, req, cookie, store }) => {
}
}
const availableLocales = locales.filter((lang) => !!lang.enabled)
const availableLocales = locales.filter(lang => !!lang.enabled)
const locale = find(availableLocales, ['code', userLocale]) ? userLocale : 'en'
if (locale !== 'en') {
@ -89,7 +89,7 @@ export default ({ app, req, cookie, store }) => {
Vue.i18n.fallback('en')
if (process.browser) {
store.subscribe((mutation) => {
store.subscribe(mutation => {
if (mutation.type === 'i18n/SET_LOCALE') {
changeHandler(mutation)
}

View File

@ -4,7 +4,7 @@ let lastRoute
const keepAliveHook = {}
if (!process.server) {
keepAliveHook.install = (Vue) => {
keepAliveHook.install = Vue => {
const keepAlivePages = process.env.keepAlivePages || []
Vue.mixin({

View File

@ -15,7 +15,7 @@ export default ({ app }) => {
Vue.directive('router-link', {
bind: (el, binding) => {
binding.clickEventListener = (e) => {
binding.clickEventListener = e => {
if (!e.metaKey && !e.ctrlKey) {
e.preventDefault()
app.router.push(el.getAttribute('href'))

View File

@ -38,7 +38,7 @@ export default ({ app = {} }) => {
return ''
}
if (truncate > 0) {
value = value.map((item) => {
value = value.map(item => {
return app.$filters.truncate(item, truncate)
})
}
@ -46,7 +46,7 @@ export default ({ app = {} }) => {
},
listByKey: (values, key, glue, truncate) => {
return app.$filters.list(
values.map((item) => item[key]),
values.map(item => item[key]),
glue,
truncate,
)
@ -58,7 +58,7 @@ export default ({ app = {} }) => {
})
.replace(/\s+/g, '')
},
removeLinks: (content) => {
removeLinks: content => {
if (!content) return ''
// remove all links from excerpt to prevent issues with the surrounding link
let excerpt = content.replace(/<a.*>(.+)<\/a>/gim, '$1')
@ -81,7 +81,7 @@ export default ({ app = {} }) => {
return contentExcerpt
},
proxyApiUrl: (input) => {
proxyApiUrl: input => {
const url = input && (input.url || input)
if (!url) return url
return url.startsWith('/') ? url.replace('/', '/api/') : url
@ -89,7 +89,7 @@ export default ({ app = {} }) => {
})
// add all methods as filters on each vue component
Object.keys(app.$filters).forEach((key) => {
Object.keys(app.$filters).forEach(key => {
Vue.filter(key, app.$filters[key])
})

View File

@ -60,19 +60,19 @@ export const mutations = {
},
TOGGLE_CATEGORY(state, categoryId) {
const filter = clone(state.filter)
update(filter, 'categories_some.id_in', (categoryIds) => xor(categoryIds, [categoryId]))
update(filter, 'categories_some.id_in', categoryIds => xor(categoryIds, [categoryId]))
if (isEmpty(get(filter, 'categories_some.id_in'))) delete filter.categories_some
state.filter = filter
},
TOGGLE_LANGUAGE(state, languageCode) {
const filter = clone(state.filter)
update(filter, 'language_in', (languageCodes) => xor(languageCodes, [languageCode]))
update(filter, 'language_in', languageCodes => xor(languageCodes, [languageCode]))
if (isEmpty(get(filter, 'language_in'))) delete filter.language_in
state.filter = filter
},
TOGGLE_EMOTION(state, emotion) {
const filter = clone(state.filter)
update(filter, 'emotions_some.emotion_in', (emotions) => xor(emotions, [emotion]))
update(filter, 'emotions_some.emotion_in', emotions => xor(emotions, [emotion]))
if (isEmpty(get(filter, 'emotions_some.emotion_in'))) delete filter.emotions_some
state.filter = filter
},
@ -100,14 +100,14 @@ export const getters = {
filteredByEmotions(state) {
return get(state.filter, 'emotions_some.emotion_in') || []
},
orderOptions: (state) => ({ $t }) =>
Object.values(orderOptions).map((option) => {
orderOptions: state => ({ $t }) =>
Object.values(orderOptions).map(option => {
return {
...option,
label: $t(option.key),
}
}),
selectedOrder: (state) => ({ $t }) => {
selectedOrder: state => ({ $t }) => {
return {
...state.order,
label: $t(state.order.key),

View File

@ -82,7 +82,7 @@ describe('getters', () => {
describe('orderByOptions', () => {
it('returns all options regardless of current state', () => {
const $t = jest.fn((t) => t)
const $t = jest.fn(t => t)
expect(getters.orderOptions()({ $t })).toEqual([
{
key: 'store.posts.orderBy.oldest.label',
@ -131,7 +131,7 @@ describe('mutations', () => {
describe('RESET_CATEGORIES', () => {
beforeEach(() => {
testMutation = (categoryId) => {
testMutation = categoryId => {
mutations.RESET_CATEGORIES(state, categoryId)
return getters.filter(state)
}
@ -149,7 +149,7 @@ describe('mutations', () => {
describe('TOGGLE_LANGUAGE', () => {
beforeEach(() => {
testMutation = (languageCode) => {
testMutation = languageCode => {
mutations.TOGGLE_LANGUAGE(state, languageCode)
return getters.filter(state)
}
@ -188,7 +188,7 @@ describe('mutations', () => {
describe('TOGGLE_CATEGORY', () => {
beforeEach(() => {
testMutation = (categoryId) => {
testMutation = categoryId => {
mutations.TOGGLE_CATEGORY(state, categoryId)
return getters.filter(state)
}
@ -228,7 +228,7 @@ describe('mutations', () => {
describe('TOGGLE_FILTER_BY_FOLLOWED', () => {
beforeEach(() => {
testMutation = (userId) => {
testMutation = userId => {
mutations.TOGGLE_FILTER_BY_FOLLOWED(state, userId)
return getters.filter(state)
}
@ -257,7 +257,7 @@ describe('mutations', () => {
describe('SELECT_ORDER', () => {
beforeEach(() => {
testMutation = (key) => {
testMutation = key => {
mutations.SELECT_ORDER(state, key)
return getters.orderBy(state)
}

Some files were not shown because too many files have changed in this diff Show More