diff options
author | dartcafe <github@dartcafe.de> | 2021-04-18 23:39:25 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2021-04-18 23:39:25 +0300 |
commit | 2488d3a0e557161e73caa7557bf2f9bce3f74242 (patch) | |
tree | 4e2c057ef50aa9aa9723a32f13a6abf4bed27c8c | |
parent | cbeba6e6fcf83dd655a4b9a24afc6ebcf1569bdc (diff) |
no-else-return
Signed-off-by: dartcafe <github@dartcafe.de>
29 files changed, 167 insertions, 172 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index be5ac7f5..599eff01 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -42,6 +42,7 @@ module.exports = { groups: ['props'], deepData: false, }], + 'no-else-return': 'error', 'comma-dangle': ['error', 'always-multiline'], // space before function () 'space-before-function-paren': ['error', 'never'], diff --git a/src/js/components/Actions/ActionChangeView.vue b/src/js/components/Actions/ActionChangeView.vue index 43c6c195..b955b407 100644 --- a/src/js/components/Actions/ActionChangeView.vue +++ b/src/js/components/Actions/ActionChangeView.vue @@ -69,17 +69,17 @@ export default { caption() { if (this.viewMode === 'table-view') { return t('polls', 'Switch to list view') - } else { - return t('polls', 'Switch to table view') } + return t('polls', 'Switch to table view') + }, icon() { if (this.viewMode === 'table-view') { return 'icon-list-view' - } else { - return 'icon-table-view' } + return 'icon-table-view' + }, }, diff --git a/src/js/components/Actions/ActionSortOptions.vue b/src/js/components/Actions/ActionSortOptions.vue index ef36fd16..248b8331 100644 --- a/src/js/components/Actions/ActionSortOptions.vue +++ b/src/js/components/Actions/ActionSortOptions.vue @@ -65,24 +65,24 @@ export default { if (this.isRanked) { if (this.pollType === 'datePoll') { return t('polls', 'Date order') - } else { - return t('polls', 'Original order') } - } else { - return t('polls', 'Ranked order') + return t('polls', 'Original order') + } + return t('polls', 'Ranked order') + }, icon() { if (this.isRanked) { if (this.pollType === 'datePoll') { return 'icon-calendar-000' - } else { - return 'icon-toggle-filelist' } - } else { - return 'icon-quota' + return 'icon-toggle-filelist' + } + return 'icon-quota' + }, }, diff --git a/src/js/components/Actions/ActionSubscribe.vue b/src/js/components/Actions/ActionSubscribe.vue index 63cc96ad..a1d2258d 100644 --- a/src/js/components/Actions/ActionSubscribe.vue +++ b/src/js/components/Actions/ActionSubscribe.vue @@ -64,17 +64,17 @@ export default { caption() { if (this.subscribed) { return t('polls', 'Unsubscribe') - } else { - return t('polls', 'Subscribe') } + return t('polls', 'Subscribe') + }, icon() { if (this.subscribed) { return 'icon-polls-confirmed' - } else { - return 'icon-polls-unconfirmed' } + return 'icon-polls-unconfirmed' + }, }, diff --git a/src/js/components/Base/ButtonDiv.vue b/src/js/components/Base/ButtonDiv.vue index a915402b..3a23b4c3 100644 --- a/src/js/components/Base/ButtonDiv.vue +++ b/src/js/components/Base/ButtonDiv.vue @@ -60,9 +60,9 @@ export default { iconClass() { if (this.submit) { return 'icon-confirm' - } else { - return this.icon } + return this.icon + }, withIcon() { @@ -74,9 +74,9 @@ export default { return 'submit' } else if (this.simple) { return 'simple' - } else { - return 'button' } + return 'button' + }, }, } diff --git a/src/js/components/Calendar/CalendarInfo.vue b/src/js/components/Calendar/CalendarInfo.vue index ca1e51d1..e9c0ed90 100644 --- a/src/js/components/Calendar/CalendarInfo.vue +++ b/src/js/components/Calendar/CalendarInfo.vue @@ -90,9 +90,9 @@ export default { return 'conflict-no' } else if (this.event.end - 1 < this.option.timestamp) { return 'conflict-no' - } else { - return 'conflict-yes' } + return 'conflict-yes' + }, }, diff --git a/src/js/components/Comments/Comments.vue b/src/js/components/Comments/Comments.vue index fa8f6880..9f1530ea 100644 --- a/src/js/components/Comments/Comments.vue +++ b/src/js/components/Comments/Comments.vue @@ -53,9 +53,9 @@ export default { sortedList() { if (this.reverse) { return sortBy(this.comments, this.sort).reverse() - } else { - return sortBy(this.comments, this.sort) } + return sortBy(this.comments, this.sort) + }, }, diff --git a/src/js/components/Navigation/PollNavigationItems.vue b/src/js/components/Navigation/PollNavigationItems.vue index 451a66a4..7496987c 100644 --- a/src/js/components/Navigation/PollNavigationItems.vue +++ b/src/js/components/Navigation/PollNavigationItems.vue @@ -70,9 +70,9 @@ export default { pollIcon() { if (this.poll.type === 'datePoll') { return 'icon-calendar-000' - } else { - return 'icon-toggle-filelist' } + return 'icon-toggle-filelist' + }, closed() { return (this.poll.expire > 0 && moment.unix(this.poll.expire).diff() < 0) diff --git a/src/js/components/Options/Confirmation.vue b/src/js/components/Options/Confirmation.vue index 30091335..5ad27f87 100644 --- a/src/js/components/Options/Confirmation.vue +++ b/src/js/components/Options/Confirmation.vue @@ -59,9 +59,9 @@ export default { confirmations() { if (this.isConfirmed) { return t('polls', 'Confirmed') - } else { - return ' ' } + return ' ' + }, }, } diff --git a/src/js/components/Options/OptionItem.vue b/src/js/components/Options/OptionItem.vue index da080a3d..60c9552c 100644 --- a/src/js/components/Options/OptionItem.vue +++ b/src/js/components/Options/OptionItem.vue @@ -122,30 +122,30 @@ export default { if (this.poll.type !== 'datePoll') { return {} - } else { - return { - from: { - month: from.format('MMM [ \']YY'), - day: from.format('Do'), - dow: from.format('ddd'), - time: from.format('LT'), - date: from.format('ll'), - dateTime: from.format('llll'), - utc: moment(from).utc().format('llll'), - }, - to: { - month: toModified.format('MMM'), - day: toModified.format('D'), - dow: toModified.format('ddd'), - time: to.format('LT'), - date: toModified.format('ll'), - dateTime: to.format('llll'), - utc: moment(to).utc().format('llll'), - sameDay: from.format('L') === toModified.format('L'), - }, - dayLong: dayLongEvent, - } } + return { + from: { + month: from.format('MMM [ \']YY'), + day: from.format('Do'), + dow: from.format('ddd'), + time: from.format('LT'), + date: from.format('ll'), + dateTime: from.format('llll'), + utc: moment(from).utc().format('llll'), + }, + to: { + month: toModified.format('MMM'), + day: toModified.format('D'), + dow: toModified.format('ddd'), + time: to.format('LT'), + date: toModified.format('ll'), + dateTime: to.format('llll'), + utc: moment(to).utc().format('llll'), + sameDay: from.format('L') === toModified.format('L'), + }, + dayLong: dayLongEvent, + } + }, dateLocalFormat() { @@ -159,41 +159,41 @@ export default { return this.event.from.date + ' - ' + this.event.to.date } else if (this.event.to.sameDay) { return this.event.from.dateTime + ' - ' + this.event.to.time - } else { - return this.event.from.dateTime + ' - ' + this.event.to.dateTime } + return this.event.from.dateTime + ' - ' + this.event.to.dateTime + }, dateLocalFormatUTC() { if (this.option.duration) { return this.event.from.utc + ' - ' + this.event.to.utc + ' UTC' - } else { - return this.event.from.utc + ' UTC' } + return this.event.from.utc + ' UTC' + }, optionTooltip() { if (this.poll.type === 'datePoll') { return this.dateLocalFormatUTC - } else { - return this.option.pollOptionText } + return this.option.pollOptionText + }, optionText() { if (this.poll.type === 'datePoll') { return this.dateLocalFormat - } else { - return this.option.pollOptionText } + return this.option.pollOptionText + }, show() { if (this.poll.type === 'datePoll' && this.display === 'dateBox') { return 'dateBox' - } else { - return 'textBox' } + return 'textBox' + }, }, } diff --git a/src/js/components/Options/OptionsDateAdd.vue b/src/js/components/Options/OptionsDateAdd.vue index 7a7161b9..861af176 100644 --- a/src/js/components/Options/OptionsDateAdd.vue +++ b/src/js/components/Options/OptionsDateAdd.vue @@ -161,9 +161,9 @@ export default { tempFormat() { if (this.useTime) { return moment.localeData().longDateFormat('L LT') - } else { - return moment.localeData().longDateFormat('L') } + return moment.localeData().longDateFormat('L') + }, pickerOptions() { diff --git a/src/js/components/Options/OptionsDateShift.vue b/src/js/components/Options/OptionsDateShift.vue index 4ef6819b..e5093858 100644 --- a/src/js/components/Options/OptionsDateShift.vue +++ b/src/js/components/Options/OptionsDateShift.vue @@ -86,9 +86,9 @@ export default { // vue2-datepicker needs 7 for sunday if (moment.localeData()._week.dow === 0) { return 7 - } else { - return moment.localeData()._week.dow } + return moment.localeData()._week.dow + }, }, diff --git a/src/js/components/Poll/MarkUpDescription.vue b/src/js/components/Poll/MarkUpDescription.vue index 924df7f0..c07bdd83 100644 --- a/src/js/components/Poll/MarkUpDescription.vue +++ b/src/js/components/Poll/MarkUpDescription.vue @@ -43,9 +43,9 @@ export default { markedDescription() { if (this.description) { return DOMPurify.sanitize(marked(this.description)) - } else { - return t('polls', 'No description provided') } + return t('polls', 'No description provided') + }, }, } diff --git a/src/js/components/Poll/PollTitle.vue b/src/js/components/Poll/PollTitle.vue index 1d699945..9c9c93a8 100644 --- a/src/js/components/Poll/PollTitle.vue +++ b/src/js/components/Poll/PollTitle.vue @@ -96,9 +96,9 @@ export default { timeExpirationRelative() { if (this.expire) { return moment.unix(this.expire).fromNow() - } else { - return t('polls', 'never') } + return t('polls', 'never') + }, }, } diff --git a/src/js/components/Poll/PublicEmail.vue b/src/js/components/Poll/PublicEmail.vue index 7b1f3d64..4bf1f8a4 100644 --- a/src/js/components/Poll/PublicEmail.vue +++ b/src/js/components/Poll/PublicEmail.vue @@ -75,12 +75,12 @@ export default { result: '', status: '', } - } else { - return { - result: this.checkResult, - status: this.checkStatus, - } } + return { + result: this.checkResult, + status: this.checkStatus, + } + }, }, diff --git a/src/js/components/Poll/PublicRegisterModal.vue b/src/js/components/Poll/PublicRegisterModal.vue index ad65cd8e..97a0fb0f 100644 --- a/src/js/components/Poll/PublicRegisterModal.vue +++ b/src/js/components/Poll/PublicRegisterModal.vue @@ -129,29 +129,28 @@ export default { result: t('polls', 'Checking username …'), status: 'checking', } - } else { - if (this.userName.length === 0) { - return { - result: t('polls', 'Enter a username to participate.'), - status: 'empty', - } - } else if (this.userName.length < 3) { - return { - result: t('polls', 'Please use at least 3 characters.'), - status: 'error', - } - } else if (!this.isValidName) { - return { - result: t('polls', 'Invalid name'), - status: 'error', - } - } else { - return { - result: t('polls', '{username} is valid.', { username: this.userName }), - status: 'success', - } + } + if (this.userName.length === 0) { + return { + result: t('polls', 'Enter a username to participate.'), + status: 'empty', + } + } else if (this.userName.length < 3) { + return { + result: t('polls', 'Please use at least 3 characters.'), + status: 'error', } + } else if (!this.isValidName) { + return { + result: t('polls', 'Invalid name'), + status: 'error', + } + } + return { + result: t('polls', '{username} is valid.', { username: this.userName }), + status: 'success', } + }, emailCheck() { @@ -160,24 +159,23 @@ export default { result: t('polls', 'Checking email address …'), status: 'checking', } - } else { - if (this.emailAddress.length < 1) { - return { - result: '', - status: '', - } - } else if (!this.isValidEmailAddress) { - return { - result: t('polls', 'Invalid email address.'), - status: 'error', - } - } else { - return { - result: t('polls', 'valid email address.'), - status: 'success', - } + } + if (this.emailAddress.length < 1) { + return { + result: '', + status: '', + } + } else if (!this.isValidEmailAddress) { + return { + result: t('polls', 'Invalid email address.'), + status: 'error', } } + return { + result: t('polls', 'valid email address.'), + status: 'success', + } + }, }, diff --git a/src/js/components/PollList/PollItem.vue b/src/js/components/PollList/PollItem.vue index 9c098dbc..002803a4 100644 --- a/src/js/components/PollList/PollItem.vue +++ b/src/js/components/PollList/PollItem.vue @@ -134,9 +134,9 @@ export default { return t('polls', 'Deleted') } else if (this.poll.access === 'public') { return t('polls', 'All users') - } else { - return t('polls', 'Only invited users') } + return t('polls', 'Only invited users') + }, accessIcon() { @@ -144,25 +144,25 @@ export default { return 'icon-delete' } else if (this.poll.access === 'public') { return 'icon-polls-public-poll' - } else { - return 'icon-polls-hidden-poll' } + return 'icon-polls-hidden-poll' + }, pollType() { if (this.poll.type === 'textPoll') { return t('polls', 'Text poll') - } else { - return t('polls', 'Date poll') } + return t('polls', 'Date poll') + }, timeExpirationRelative() { if (this.poll.expire) { return moment.unix(this.poll.expire).fromNow() - } else { - return t('polls', 'never') } + return t('polls', 'never') + }, expiryClass() { @@ -172,9 +172,9 @@ export default { return 'warning' } else if (this.poll.expire && !this.closed) { return 'success' - } else { - return 'success' } + return 'success' + }, timeCreatedRelative() { diff --git a/src/js/components/PollList/PollItemAdmin.vue b/src/js/components/PollList/PollItemAdmin.vue index a1a5f8c3..f61b2c21 100644 --- a/src/js/components/PollList/PollItemAdmin.vue +++ b/src/js/components/PollList/PollItemAdmin.vue @@ -117,25 +117,25 @@ export default { accessType() { if (this.poll.access === 'public') { return t('polls', 'All users') - } else { - return t('polls', 'Only invited users') } + return t('polls', 'Only invited users') + }, pollType() { if (this.poll.type === 'textPoll') { return t('polls', 'Text poll') - } else { - return t('polls', 'Date poll') } + return t('polls', 'Date poll') + }, timeExpirationRelative() { if (this.poll.expire) { return moment.unix(this.poll.expire).fromNow() - } else { - return t('polls', 'never') } + return t('polls', 'never') + }, timeCreatedRelative() { return moment.unix(this.poll.created).fromNow() diff --git a/src/js/components/Subscription/ActionSubscription.vue b/src/js/components/Subscription/ActionSubscription.vue index 6c5ce2cc..02329b38 100644 --- a/src/js/components/Subscription/ActionSubscription.vue +++ b/src/js/components/Subscription/ActionSubscription.vue @@ -45,9 +45,9 @@ export default { label() { if (this.emailAddress) { return t('polls', 'Receive notification email on activity to {emailAddress}', { emailAddress: this.emailAddress }) - } else { - return t('polls', 'Receive notification email on activity') } + return t('polls', 'Receive notification email on activity') + }, subscribe: { diff --git a/src/js/components/Subscription/Subscription.vue b/src/js/components/Subscription/Subscription.vue index 86c1205f..3025f518 100644 --- a/src/js/components/Subscription/Subscription.vue +++ b/src/js/components/Subscription/Subscription.vue @@ -45,9 +45,9 @@ export default { label() { if (this.emailAddress) { return t('polls', 'Receive notification email on activity to {emailAddress}', { emailAddress: this.emailAddress }) - } else { - return t('polls', 'Receive notification email on activity') } + return t('polls', 'Receive notification email on activity') + }, subscribe: { diff --git a/src/js/components/User/UserItem.vue b/src/js/components/User/UserItem.vue index 164c2857..7504ec8e 100644 --- a/src/js/components/User/UserItem.vue +++ b/src/js/components/User/UserItem.vue @@ -104,9 +104,9 @@ export default { name() { if (this.displayName) { return this.displayName - } else { - return this.userId } + return this.userId + }, showUserStatus() { @@ -127,9 +127,9 @@ export default { return 'icon-circles' } return 'icon-' + this.type - } else { - return '' } + return '' + }, }, diff --git a/src/js/components/User/UserMenu.vue b/src/js/components/User/UserMenu.vue index 4429e93b..dcd3e9e1 100644 --- a/src/js/components/User/UserMenu.vue +++ b/src/js/components/User/UserMenu.vue @@ -106,12 +106,12 @@ export default { result: '', status: '', } - } else { - return { - result: this.checkResult, - status: this.checkStatus, - } } + return { + result: this.checkResult, + status: this.checkStatus, + } + }, personalLink() { diff --git a/src/js/components/VoteTable/VoteItem.vue b/src/js/components/VoteTable/VoteItem.vue index 0c15fdad..9e3af83c 100644 --- a/src/js/components/VoteTable/VoteItem.vue +++ b/src/js/components/VoteTable/VoteItem.vue @@ -93,9 +93,9 @@ export default { nextAnswer() { if (this.answerSequence.indexOf(this.answer) < 0) { return this.answerSequence[1] - } else { - return this.answerSequence[(this.answerSequence.indexOf(this.answer) + 1) % this.answerSequence.length] } + return this.answerSequence[(this.answerSequence.indexOf(this.answer) + 1) % this.answerSequence.length] + }, isValidUser() { diff --git a/src/js/components/VoteTable/VoteTableHeaderItem.vue b/src/js/components/VoteTable/VoteTableHeaderItem.vue index c59ae986..fa5a56bd 100644 --- a/src/js/components/VoteTable/VoteTableHeaderItem.vue +++ b/src/js/components/VoteTable/VoteTableHeaderItem.vue @@ -63,16 +63,16 @@ export default { optionStyle() { if (this.viewMode === 'table-view') { return 'dateBox' - } else { - return 'textBox' } + return 'textBox' + }, counterStyle() { if (this.viewMode === 'table-view') { return 'iconStyle' - } else { - return 'barStyle' } + return 'barStyle' + }, showNo() { return (this.viewMode === 'list-view') diff --git a/src/js/store/modules/poll.js b/src/js/store/modules/poll.js index ce5f5bc7..87da57ba 100644 --- a/src/js/store/modules/poll.js +++ b/src/js/store/modules/poll.js @@ -82,17 +82,17 @@ const getters = { typeIcon: (state) => { if (state.type === 'textPoll') { return 'icon-toggle-filelist' - } else { - return 'icon-calendar-000' } + return 'icon-calendar-000' + }, answerSequence: (state) => { if (state.allowMaybe) { return ['no', 'yes', 'maybe'] - } else { - return ['no', 'yes'] } + return ['no', 'yes'] + }, proposalsAllowed: (state) => { diff --git a/src/js/store/modules/settings.js b/src/js/store/modules/settings.js index f71802ab..999acfaa 100644 --- a/src/js/store/modules/settings.js +++ b/src/js/store/modules/settings.js @@ -96,33 +96,31 @@ const getters = { viewTextPoll(state) { if (state.session.manualViewTextPoll) { return state.session.manualViewTextPoll - } else { - if (window.innerWidth > 480) { - return state.user.defaultViewTextPoll - } else { - return 'list-view' - } } + if (window.innerWidth > 480) { + return state.user.defaultViewTextPoll + } + return 'list-view' + }, getNextViewMode(state, getters) { if (state.viewModes.indexOf(getters.viewMode) < 0) { return state.viewModes[1] - } else { - return state.viewModes[(state.viewModes.indexOf(getters.viewMode) + 1) % state.viewModes.length] } + return state.viewModes[(state.viewModes.indexOf(getters.viewMode) + 1) % state.viewModes.length] + }, viewDatePoll(state) { if (state.session.manualViewDatePoll) { return state.session.manualViewDatePoll - } else { - if (window.innerWidth > 480) { - return state.user.defaultViewDatePoll - } else { - return 'list-view' - } } + if (window.innerWidth > 480) { + return state.user.defaultViewDatePoll + } + return 'list-view' + }, viewMode(state, getters, rootState) { @@ -130,9 +128,9 @@ const getters = { return getters.viewTextPoll } else if (rootState.poll.type === 'datePoll') { return getters.viewDatePoll - } else { - return 'table-view' } + return 'table-view' + }, } diff --git a/src/js/store/modules/votes.js b/src/js/store/modules/votes.js index 6a76be9a..52c35bed 100644 --- a/src/js/store/modules/votes.js +++ b/src/js/store/modules/votes.js @@ -84,9 +84,9 @@ const getters = { voteOptionText: payload.option.pollOptionText, userId: payload.userId, } - } else { - return found } + return found + }, } diff --git a/src/js/views/Administration.vue b/src/js/views/Administration.vue index 8efebc8d..daa83fac 100644 --- a/src/js/views/Administration.vue +++ b/src/js/views/Administration.vue @@ -154,9 +154,8 @@ export default { sortedList() { if (this.reverse) { return sortBy(this.filteredPolls(this.$route.params.type), this.sort).reverse() - } else { - return sortBy(this.filteredPolls(this.$route.params.type), this.sort) } + return sortBy(this.filteredPolls(this.$route.params.type), this.sort) }, noPolls() { diff --git a/src/js/views/PollList.vue b/src/js/views/PollList.vue index bff3b640..0dd41d74 100644 --- a/src/js/views/PollList.vue +++ b/src/js/views/PollList.vue @@ -144,9 +144,8 @@ export default { sortedList() { if (this.reverse) { return sortBy(this.filteredPolls(this.$route.params.type), this.sort).reverse() - } else { - return sortBy(this.filteredPolls(this.$route.params.type), this.sort) } + return sortBy(this.filteredPolls(this.$route.params.type), this.sort) }, noPolls() { |