diff options
author | dartcafe <github@dartcafe.de> | 2021-10-15 00:48:31 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2021-10-15 00:48:31 +0300 |
commit | 4b84b06e109182afae3980e3cb4961f0c2238cc2 (patch) | |
tree | 7f8fbcbf669aec48e5a1c08a5d1023841315152b | |
parent | 465c912accd6b4847d7cdd92d6744b40dccc5b97 (diff) |
eslint no-else-return {allowElseif: false}
Signed-off-by: dartcafe <github@dartcafe.de>
-rw-r--r-- | .eslintrc.js | 2 | ||||
-rw-r--r-- | src/js/components/Base/ButtonDiv.vue | 5 | ||||
-rw-r--r-- | src/js/components/Calendar/CalendarInfo.vue | 10 | ||||
-rw-r--r-- | src/js/components/Options/OptionItem.vue | 26 | ||||
-rw-r--r-- | src/js/components/Poll/PublicEmail.vue | 6 | ||||
-rw-r--r-- | src/js/components/Poll/PublicRegisterModal.vue | 12 | ||||
-rw-r--r-- | src/js/components/PollList/PollItem.vue | 24 | ||||
-rw-r--r-- | src/js/components/User/UserItem.vue | 23 | ||||
-rw-r--r-- | src/js/components/User/UserMenu.vue | 6 | ||||
-rw-r--r-- | src/js/helpers/detectColorScheme.js | 4 | ||||
-rw-r--r-- | src/js/store/modules/poll.js | 4 | ||||
-rw-r--r-- | src/js/store/modules/polls.js | 29 | ||||
-rw-r--r-- | src/js/views/Vote.vue | 4 |
13 files changed, 109 insertions, 46 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index e71ee5de..de081f70 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,7 @@ module.exports = { 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], 'no-array-constructor': 'error', 'no-continue': 'error', - 'no-else-return': 'error', + 'no-else-return': ['error', { allowElseIf: false }], 'no-lonely-if': 'error', 'no-negated-condition': 'error', 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], diff --git a/src/js/components/Base/ButtonDiv.vue b/src/js/components/Base/ButtonDiv.vue index 4094c9d9..a71e600b 100644 --- a/src/js/components/Base/ButtonDiv.vue +++ b/src/js/components/Base/ButtonDiv.vue @@ -60,9 +60,12 @@ export default { buttonStyle() { if (this.submit) { return 'submit' - } else if (this.simple) { + } + + if (this.simple) { return 'simple' } + return 'button' }, diff --git a/src/js/components/Calendar/CalendarInfo.vue b/src/js/components/Calendar/CalendarInfo.vue index 58482acd..fb98b016 100644 --- a/src/js/components/Calendar/CalendarInfo.vue +++ b/src/js/components/Calendar/CalendarInfo.vue @@ -86,13 +86,17 @@ export default { conflictLevel() { if (this.event.calendarKey === 0) { return 'conflict-ignore' - } else if (this.event.start > this.option.timestamp + 3599) { + } + + if (this.event.start > this.option.timestamp + 3599) { return 'conflict-no' - } else if (this.event.end - 1 < this.option.timestamp) { + } + + if (this.event.end - 1 < this.option.timestamp) { return 'conflict-no' } - return 'conflict-yes' + return 'conflict-yes' }, }, diff --git a/src/js/components/Options/OptionItem.vue b/src/js/components/Options/OptionItem.vue index 6bb5f83b..7c2d9ef7 100644 --- a/src/js/components/Options/OptionItem.vue +++ b/src/js/components/Options/OptionItem.vue @@ -147,49 +147,57 @@ export default { dateLocalFormat() { if (this.poll.type !== 'datePoll') { return {} - } else if (this.option.duration === 0) { + } + + if (this.option.duration === 0) { return this.event.from.dateTime - } else if (this.event.dayLong && this.event.to.sameDay) { + } + + if (this.event.dayLong && this.event.to.sameDay) { return this.event.from.date - } else if (this.event.dayLong && !this.event.to.sameDay) { + } + + if (this.event.dayLong && !this.event.to.sameDay) { return `${this.event.from.date} - ${this.event.to.date}` - } else if (this.event.to.sameDay) { + } + + if (this.event.to.sameDay) { return `${this.event.from.dateTime} - ${this.event.to.time}` } - 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` } - return `${this.event.from.utc} UTC` + return `${this.event.from.utc} UTC` }, optionTooltip() { if (this.poll.type === 'datePoll') { return this.dateLocalFormatUTC } - return this.option.pollOptionText + return this.option.pollOptionText }, optionText() { if (this.poll.type === 'datePoll') { return this.dateLocalFormat } - return this.option.pollOptionText + return this.option.pollOptionText }, show() { if (this.poll.type === 'datePoll' && this.display === 'dateBox') { return 'dateBox' } - return 'textBox' + return 'textBox' }, }, } diff --git a/src/js/components/Poll/PublicEmail.vue b/src/js/components/Poll/PublicEmail.vue index 1e53ddc3..10b12ba5 100644 --- a/src/js/components/Poll/PublicEmail.vue +++ b/src/js/components/Poll/PublicEmail.vue @@ -70,17 +70,19 @@ export default { result: t('polls', 'Checking email address …'), status: 'checking', } - } else if (this.emailAddressUnchanged) { + } + + if (this.emailAddressUnchanged) { return { result: '', status: '', } } + return { result: this.checkResult, status: this.checkStatus, } - }, }, diff --git a/src/js/components/Poll/PublicRegisterModal.vue b/src/js/components/Poll/PublicRegisterModal.vue index 15f0f241..32c572ae 100644 --- a/src/js/components/Poll/PublicRegisterModal.vue +++ b/src/js/components/Poll/PublicRegisterModal.vue @@ -144,17 +144,19 @@ export default { result: t('polls', 'Enter a name to participate.'), status: 'empty', } - } else if (!this.isValidName) { + } + + if (!this.isValidName) { return { result: t('polls', 'Invalid name'), status: 'error', } } + return { result: t('polls', '{username} is valid.', { username: this.userName }), status: 'success', } - }, emailCheck() { @@ -169,17 +171,19 @@ export default { result: '', status: '', } - } else if (!this.isValidEmailAddress) { + } + + 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 1962db15..b77ebb57 100644 --- a/src/js/components/PollList/PollItem.vue +++ b/src/js/components/PollList/PollItem.vue @@ -138,29 +138,33 @@ export default { accessType() { if (this.poll.deleted) { return t('polls', 'Archived') - } else if (this.poll.access === 'public') { + } + + if (this.poll.access === 'public') { return t('polls', 'All users') } - return t('polls', 'Only invited users') + return t('polls', 'Only invited users') }, accessIcon() { if (this.poll.deleted) { return 'icon-category-app-bundles' - } else if (this.poll.access === 'public') { + } + + if (this.poll.access === 'public') { return 'icon-polls-public-poll' } - return 'icon-polls-hidden-poll' + return 'icon-polls-hidden-poll' }, pollType() { if (this.poll.type === 'textPoll') { return t('polls', 'Text poll') } - return t('polls', 'Date poll') + return t('polls', 'Date poll') }, timeExpirationRelative() { @@ -174,13 +178,17 @@ export default { expiryClass() { if (this.closed) { return 'error' - } else if (this.poll.expire && this.closeToClosing) { + } + + if (this.poll.expire && this.closeToClosing) { return 'warning' - } else if (this.poll.expire && !this.closed) { + } + + if (this.poll.expire && !this.closed) { return 'success' } - return 'success' + return 'success' }, timeCreatedRelative() { diff --git a/src/js/components/User/UserItem.vue b/src/js/components/User/UserItem.vue index 2eba6673..ee0035b3 100644 --- a/src/js/components/User/UserItem.vue +++ b/src/js/components/User/UserItem.vue @@ -146,21 +146,32 @@ export default { if (this.icon) { if (this.type === 'contact') { return 'icon-mail' - } else if (this.type === 'email') { + } + + if (this.type === 'email') { return 'icon-mail' - } else if (this.type === 'external') { + } + + if (this.type === 'external') { return 'icon-share' - } else if (this.type === 'contactGroup') { + } + + if (this.type === 'contactGroup') { return 'icon-group' - } else if (this.type === 'circle') { + } + + if (this.type === 'circle') { return 'icon-circles' - } else if (this.type === 'admin') { + } + + if (this.type === 'admin') { return 'icon-user-admin' } + return `icon-${this.type}` } - return '' + return '' }, }, diff --git a/src/js/components/User/UserMenu.vue b/src/js/components/User/UserMenu.vue index 533e0a4e..d3279462 100644 --- a/src/js/components/User/UserMenu.vue +++ b/src/js/components/User/UserMenu.vue @@ -109,17 +109,19 @@ export default { result: t('polls', 'Checking email address …'), status: 'checking', } - } else if (this.emailAddressUnchanged) { + } + + if (this.emailAddressUnchanged) { return { result: '', status: '', } } + return { result: this.checkResult, status: this.checkStatus, } - }, personalLink() { diff --git a/src/js/helpers/detectColorScheme.js b/src/js/helpers/detectColorScheme.js index 84f50c7e..8e336fc5 100644 --- a/src/js/helpers/detectColorScheme.js +++ b/src/js/helpers/detectColorScheme.js @@ -24,7 +24,9 @@ const detectColorScheme = function() { if (!window.matchMedia) { return true - } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { + } + + if (window.matchMedia('(prefers-color-scheme: dark)').matches) { document.body.classList.add('dark-theme') return true } diff --git a/src/js/store/modules/poll.js b/src/js/store/modules/poll.js index db54da15..ad46387a 100644 --- a/src/js/store/modules/poll.js +++ b/src/js/store/modules/poll.js @@ -83,7 +83,9 @@ const getters = { viewMode: (state, getters, rootState, rootGetters) => { if (state.type === 'textPoll') { return rootGetters['settings/viewTextPoll'] - } else if (state.type === 'datePoll') { + } + + if (state.type === 'datePoll') { return rootGetters['settings/viewDatePoll'] } return 'table-view' diff --git a/src/js/store/modules/polls.js b/src/js/store/modules/polls.js index 61b3012a..ee6e58f7 100644 --- a/src/js/store/modules/polls.js +++ b/src/js/store/modules/polls.js @@ -132,6 +132,7 @@ const getters = { hiddenPolls: (state, getters) => getters.activePolls.filter((poll) => (poll.access === 'hidden')), participatedPolls: (state, getters) => getters.activePolls.filter((poll) => (poll.userHasVoted)), closedPolls: (state, getters) => getters.activePolls.filter((poll) => (poll.expire > 0 && moment.unix(poll.expire).diff() < 0)), + relevantPolls: (state, getters) => getters.activePolls.filter((poll) => (( poll.important || poll.userHasVoted || poll.isOwner || (poll.allowView && poll.access !== 'public') ) && !(poll.expire > 0 && moment.unix(poll.expire).diff(moment(), 'days') < -4))), @@ -139,19 +140,33 @@ const getters = { filtered: (state, getters) => (filterId) => { if (filterId === 'all') { return getters.activePolls - } else if (filterId === 'relevant') { + } + + if (filterId === 'relevant') { return getters.relevantPolls - } else if (filterId === 'my') { + } + + if (filterId === 'my') { return getters.myPolls - } else if (filterId === 'public') { + } + + if (filterId === 'public') { return getters.publicPolls - } else if (filterId === 'hidden') { + } + + if (filterId === 'hidden') { return getters.hiddenPolls - } else if (filterId === 'participated') { + } + + if (filterId === 'participated') { return getters.participatedPolls - } else if (filterId === 'closed') { + } + + if (filterId === 'closed') { return getters.closedPolls - } else if (filterId === 'archived') { + } + + if (filterId === 'archived') { return getters.archivedPolls } }, diff --git a/src/js/views/Vote.vue b/src/js/views/Vote.vue index 3516a5cb..070b9071 100644 --- a/src/js/views/Vote.vue +++ b/src/js/views/Vote.vue @@ -141,7 +141,9 @@ export default { // TODO: remove, when completely supported by core if (!window.matchMedia) { return true - } else if (this.$route.name === 'publicVote' && window.matchMedia('(prefers-color-scheme: dark)').matches) { + } + + if (this.$route.name === 'publicVote' && window.matchMedia('(prefers-color-scheme: dark)').matches) { document.body.classList.add('theme--dark') } |