Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Enforce braces for `if`-`else` and `switch`-`case` (#3474)

bhavik001005af7ea56e3
diff --git a/automations/js/src/project_thread_updates.js b/automations/js/src/project_thread_updates.js
index 1ad54e9db..5ffc944d2 100644
--- a/automations/js/src/project_thread_updates.js
+++ b/automations/js/src/project_thread_updates.js
@@ -86,12 +86,15 @@ module.exports = async ({ github, core }) => {
issue.__typename !== 'Issue' ||
issue.state !== 'OPEN' ||
new Date(issue.createdAt) > requiredUpdatedByDate
- )
+ ) {
continue
+ }
// Check the status of the card to make sure the project is in active development
const status = node.fieldValueByName.name
- if (!activeDevelopmentStatuses.includes(status)) continue
+ if (!activeDevelopmentStatuses.includes(status)) {
+ continue
+ }
const comments = issue.comments.nodes
diff --git a/frontend/src/components/VAudioTrack/VAudioControl.vue b/frontend/src/components/VAudioTrack/VAudioControl.vue
index e74d01b6f..1decd3f6b 100644
--- a/frontend/src/components/VAudioTrack/VAudioControl.vue
+++ b/frontend/src/components/VAudioTrack/VAudioControl.vue
@@ -148,7 +148,10 @@ export default defineComponent({
const iSize = computed(() => sizes[props.size].icon)
const handleMouseDown = (event: MouseEvent) => {
- if (!props.isTabbable) event.preventDefault() // to prevent focus
+ if (!props.isTabbable) {
+ // to prevent focus
+ event.preventDefault()
+ }
}
const handleClick = () => {
emit("toggle", isPlaying.value || isLoading.value ? "paused" : "playing")
diff --git a/frontend/src/components/VAudioTrack/VAudioTrack.vue b/frontend/src/components/VAudioTrack/VAudioTrack.vue
index 146632560..340d5ac9c 100644
--- a/frontend/src/components/VAudioTrack/VAudioTrack.vue
+++ b/frontend/src/components/VAudioTrack/VAudioTrack.vue
@@ -166,7 +166,9 @@ export default defineComponent({
const initLocalAudio = () => {
// Preserve existing local audio if we plucked it from the global active audio
- if (!localAudio) localAudio = new Audio(props.audio.url)
+ if (!localAudio) {
+ localAudio = new Audio(props.audio.url)
+ }
Object.entries(eventMap).forEach(([name, fn]) =>
/**
@@ -279,12 +281,15 @@ export default defineComponent({
if (localAudio) {
return localAudio.duration
}
- if (typeof props.audio?.duration === "number")
+ if (typeof props.audio?.duration === "number") {
return props.audio.duration / 1e3
+ }
return 0
})
const setDuration = () => {
- if (localAudio) duration.value = localAudio.duration
+ if (localAudio) {
+ duration.value = localAudio.duration
+ }
}
const eventMap = {
@@ -309,10 +314,14 @@ export default defineComponent({
* `localAudio` variable. This is the earliest in
* `setup` that this can be called.
*/
- if (localAudio) initLocalAudio()
+ if (localAudio) {
+ initLocalAudio()
+ }
onUnmounted(() => {
- if (!localAudio) return
+ if (!localAudio) {
+ return
+ }
Object.entries(eventMap).forEach(([name, fn]) =>
localAudio?.removeEventListener(name, fn)
@@ -351,7 +360,9 @@ export default defineComponent({
const play = () => {
// Delay initializing the local audio element until playback is requested
- if (!localAudio) initLocalAudio()
+ if (!localAudio) {
+ initLocalAudio()
+ }
const playPromise = localAudio?.play()
// Check if the audio can be played successfully
@@ -359,18 +370,22 @@ export default defineComponent({
playPromise.catch((err) => {
let message: string
switch (err.name) {
- case "NotAllowedError":
+ case "NotAllowedError": {
message = "err_unallowed"
break
- case "NotSupportedError":
+ }
+ case "NotSupportedError": {
message = "err_unsupported"
break
- case "AbortError":
+ }
+ case "AbortError": {
message = "err_aborted"
break
- default:
+ }
+ default: {
message = "err_unknown"
$sentry.captureException(err)
+ }
}
activeMediaStore.setMessage({ message })
localAudio?.pause()
@@ -410,31 +425,37 @@ export default defineComponent({
let event: AudioInteraction | undefined = undefined
if (!state) {
switch (status.value) {
- case "playing":
+ case "playing": {
state = "paused"
break
+ }
case "paused":
- case "played":
+ case "played": {
state = "playing"
break
+ }
}
}
switch (state) {
- case "playing":
+ case "playing": {
play()
event = "play"
break
- case "paused":
+ }
+ case "paused": {
pause()
event = "pause"
break
+ }
}
emitInteracted(event)
}
const emitInteracted = (event?: AudioInteraction) => {
- if (!event) return
+ if (!event) {
+ return
+ }
snackbar.dismiss()
emit("interacted", {
event,
@@ -446,7 +467,9 @@ export default defineComponent({
/* Interface with VWaveform */
const handleSeeked = (frac: number) => {
- if (!localAudio) initLocalAudio()
+ if (!localAudio) {
+ initLocalAudio()
+ }
/**
* Calling initLocalAudio will guarantee localAudio
* to be an HTMLAudioElement, but we can't prove that
diff --git a/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue b/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue
index fb9321524..12ea0fdc6 100644
--- a/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue
+++ b/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue
@@ -82,8 +82,9 @@ export default defineComponent({
const status = ref<AudioStatus>("paused")
const currentTime = ref(0)
const duration = defaultRef(() => {
- if (typeof props.audio?.duration === "number")
+ if (typeof props.audio?.duration === "number") {
return props.audio.duration / 1e3
+ }
return 0
})
@@ -108,7 +109,9 @@ export default defineComponent({
}
}
const setDuration = () => {
- if (activeAudio.obj.value) duration.value = activeAudio.obj.value.duration
+ if (activeAudio.obj.value) {
+ duration.value = activeAudio.obj.value.duration
+ }
}
const updateTimeLoop = () => {
@@ -145,7 +148,9 @@ export default defineComponent({
watch(
activeAudio.obj,
(audio, _, onInvalidate) => {
- if (!audio) return
+ if (!audio) {
+ return
+ }
Object.entries(eventMap).forEach(([name, fn]) =>
audio.addEventListener(name, fn)
@@ -211,25 +216,29 @@ export default defineComponent({
) => {
if (!state) {
switch (status.value) {
- case "playing":
+ case "playing": {
state = "paused"
break
+ }
case "paused":
- case "played":
+ case "played": {
state = "playing"
break
+ }
}
}
let event: AudioInteraction | undefined = undefined
switch (state) {
- case "playing":
+ case "playing": {
play()
event = "play"
break
- case "paused":
+ }
+ case "paused": {
pause()
event = "pause"
break
+ }
}
if (event) {
sendAudioInteractionEvent(event)
diff --git a/frontend/src/components/VAudioTrack/VWaveform.vue b/frontend/src/components/VAudioTrack/VWaveform.vue
index fcd7bcafb..c37e4777b 100644
--- a/frontend/src/components/VAudioTrack/VWaveform.vue
+++ b/frontend/src/components/VAudioTrack/VWaveform.vue
@@ -368,7 +368,9 @@ export default defineComponent({
isDragging.value ? seekTimestamp.value : props.currentTime
)
const isProgressTimestampCutoff = computed(() => {
- if (!progressTimestampEl.value) return false
+ if (!progressTimestampEl.value) {
+ return false
+ }
const barWidth = progressBarWidth.value
const timestampWidth = progressTimestampEl.value.offsetWidth
return barWidth < timestampWidth + 2
@@ -399,7 +401,9 @@ export default defineComponent({
seekFrac.value ? seekFrac.value * props.duration : props.duration
)
const isSeekTimestampCutoff = computed(() => {
- if (!seekTimestampEl.value) return false
+ if (!seekTimestampEl.value) {
+ return false
+ }
const barWidth = seekBarWidth.value
const timestampWidth = seekTimestampEl.value.offsetWidth
return barWidth < timestampWidth + 2
@@ -443,7 +447,10 @@ export default defineComponent({
let startPos: null | number = null
const isDragging = ref(false)
const handleMouseDown = (event: MouseEvent) => {
- if (!props.isTabbable) event.preventDefault() // to prevent focus
+ if (!props.isTabbable) {
+ // to prevent focus
+ event.preventDefault()
+ }
isDragging.value = false
startPos = getPosition(event)
setSeekProgress(event)
diff --git a/frontend/src/components/VCollectionHeader/VCollectionHeader.vue b/frontend/src/components/VCollectionHeader/VCollectionHeader.vue
index 1edca9bd3..8ae307d21 100644
--- a/frontend/src/components/VCollectionHeader/VCollectionHeader.vue
+++ b/frontend/src/components/VCollectionHeader/VCollectionHeader.vue
@@ -139,7 +139,9 @@ export default defineComponent({
const { sendCustomEvent } = useAnalytics()
const sendAnalyticsEvent = () => {
- if (props.collectionParams.collection === "tag") return
+ if (props.collectionParams.collection === "tag") {
+ return
+ }
const eventName =
props.collectionParams.collection === "creator"
diff --git a/frontend/src/components/VCollectionPage.vue b/frontend/src/components/VCollectionPage.vue
index 3fff6d953..3bca3fa79 100644
--- a/frontend/src/components/VCollectionPage.vue
+++ b/frontend/src/components/VCollectionPage.vue
@@ -70,27 +70,31 @@ export default defineComponent({
const collectionLabel = computed(() => {
const collection = collectionParams.value?.collection
switch (collection) {
- case "tag":
+ case "tag": {
return i18n
.t(`collection.ariaLabel.tag.${props.mediaType}`, {
tag: collectionParams.value?.tag,
})
.toString()
- case "source":
+ }
+ case "source": {
return i18n
.t(`collection.ariaLabel.source.${props.mediaType}`, {
source: collectionParams.value?.source,
})
.toString()
- case "creator":
+ }
+ case "creator": {
return i18n
.t(`collection.ariaLabel.creator.${props.mediaType}`, {
creator: collectionParams.value?.creator,
source: collectionParams.value?.source,
})
.toString()
- default:
+ }
+ default: {
return ""
+ }
}
})
diff --git a/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue b/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
index 8a8e0bc5f..b55edf5c7 100644
--- a/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
+++ b/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
@@ -77,23 +77,30 @@ export default defineComponent({
return
}
const error = event.target.error
- if (!error) return
+ if (!error) {
+ return
+ }
let errorMsg
switch (error.code) {
- case error.MEDIA_ERR_ABORTED:
+ case error.MEDIA_ERR_ABORTED: {
errorMsg = "err_aborted"
break
- case error.MEDIA_ERR_NETWORK:
+ }
+ case error.MEDIA_ERR_NETWORK: {
errorMsg = "err_network"
break
- case error.MEDIA_ERR_DECODE:
+ }
+ case error.MEDIA_ERR_DECODE: {
errorMsg = "err_decode"
break
- case error.MEDIA_ERR_SRC_NOT_SUPPORTED:
+ }
+ case error.MEDIA_ERR_SRC_NOT_SUPPORTED: {
errorMsg = "err_unsupported"
break
- default:
+ }
+ default: {
errorMsg = "err_unknown"
+ }
}
activeMediaStore.setMessage({ message: errorMsg })
}
@@ -101,7 +108,9 @@ export default defineComponent({
watch(
activeAudio.obj,
(audio, _, onInvalidate) => {
- if (!audio) return
+ if (!audio) {
+ return
+ }
audio.addEventListener("error", handleError)
onInvalidate(() => {
diff --git a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
index 06bade0a8..7d09ff887 100644
--- a/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
+++ b/frontend/src/components/VHeader/VHeaderMobile/VHeaderMobile.vue
@@ -182,7 +182,9 @@ export default defineComponent({
* Without `nextTick`, the search bar is not focused on click in Firefox
*/
nextTick(() => {
- if (searchInputRef.value) ensureFocus(searchInputRef.value)
+ if (searchInputRef.value) {
+ ensureFocus(searchInputRef.value)
+ }
})
} else {
isRecentSearchesModalOpen.value = false
@@ -220,7 +222,9 @@ export default defineComponent({
const { key, altKey } = event
// Show the recent searches.
isRecentSearchesModalOpen.value = true
- if (altKey) return
+ if (altKey) {
+ return
+ }
// Shift selection (if Alt was not pressed with arrow keys)
let defaultValue: number
let offset: number
@@ -240,12 +244,14 @@ export default defineComponent({
}
const handleOtherKeys = (event: KeyboardEvent) => {
const { key } = event
- if (key === keycodes.Enter && selectedIdx.value)
+ if (key === keycodes.Enter && selectedIdx.value) {
// If a recent search is selected, populate its value into the input.
searchTerm.value = entries.value[selectedIdx.value]
- if (([keycodes.Escape] as string[]).includes(key))
+ }
+ if (([keycodes.Escape] as string[]).includes(key)) {
// Hide the recent searches.
isRecentSearchesModalOpen.value = false
+ }
selectedIdx.value = undefined // Lose visual focus from entries.
}
const handleKeydown = (event: KeyboardEvent) => {
diff --git a/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue b/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue
index 02b562e5a..54fcba7dc 100644
--- a/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue
+++ b/frontend/src/components/VHeader/VSearchBar/VSearchBar.vue
@@ -147,7 +147,9 @@ export default defineComponent({
* Hide recent searches on blur and click outside.
*/
const handleSearchBlur = () => {
- if (!entries.value.length) hideRecentSearches()
+ if (!entries.value.length) {
+ hideRecentSearches()
+ }
}
onClickOutside(searchBarEl, hideRecentSearches)
@@ -164,7 +166,9 @@ export default defineComponent({
const { key, altKey } = event
showRecentSearches()
- if (altKey) return
+ if (altKey) {
+ return
+ }
// Shift selection (if Alt was not pressed with arrow keys)
let defaultValue: number
@@ -187,9 +191,10 @@ export default defineComponent({
const handleOtherKeys = (event: KeyboardEvent) => {
const { key } = event
- if (key === keycodes.Enter && selectedIdx.value)
+ if (key === keycodes.Enter && selectedIdx.value) {
// If a recent search is selected, populate its value into the input.
modelMedium.value = entries.value[selectedIdx.value]
+ }
// Hide the recent searches popover when the user presses Enter, Escape or Shift+Tab on the input.
if (
diff --git a/frontend/src/components/VImageCell/VImageCell.vue b/frontend/src/components/VImageCell/VImageCell.vue
index 899712302..a25f33792 100644
--- a/frontend/src/components/VImageCell/VImageCell.vue
+++ b/frontend/src/components/VImageCell/VImageCell.vue
@@ -166,7 +166,9 @@ export default defineComponent({
* @param event - the load event.
*/
const getImgDimension = (event: Event) => {
- if (props.aspectRatio === "square") return
+ if (props.aspectRatio === "square") {
+ return
+ }
const element = event.target as HTMLImageElement
imgHeight.value = element.naturalHeight
imgWidth.value = element.naturalWidth
diff --git a/frontend/src/components/VItemGroup/VItem.vue b/frontend/src/components/VItemGroup/VItem.vue
index 74b05230e..7124d77cb 100644
--- a/frontend/src/components/VItemGroup/VItem.vue
+++ b/frontend/src/components/VItemGroup/VItem.vue
@@ -139,18 +139,25 @@ export default defineComponent({
const tabIndex = computed(() => {
// If outside a radiogroup then everything can be tabbable in order
- if (contextProps.type !== "radiogroup") return 0
+ if (contextProps.type !== "radiogroup") {
+ return 0
+ }
// If no items are selected then all can be tabbable to ensure it is possible to enter into the group
if (
focusContext.selectedCount.value === 0 &&
props.isFirst &&
!focusContext.isGroupFocused.value
- )
+ ) {
return 0
+ }
// If this one is focused then it should be the tabbable item
- if (isFocused.value) return 0
+ if (isFocused.value) {
+ return 0
+ }
// If the group is not focused but this is the selected item, then this should be the focusable item when focusing into the group
- if (!focusContext.isGroupFocused.value && props.selected) return 0
+ if (!focusContext.isGroupFocused.value && props.selected) {
+ return 0
+ }
// Otherwise, the item should not be tabbable. The logic above guarantees that at least one other item in the group will be tabbable.
return -1
diff --git a/frontend/src/components/VItemGroup/VItemGroup.vue b/frontend/src/components/VItemGroup/VItemGroup.vue
index 613993c10..015023d5a 100644
--- a/frontend/src/components/VItemGroup/VItemGroup.vue
+++ b/frontend/src/components/VItemGroup/VItemGroup.vue
@@ -134,7 +134,9 @@ export default defineComponent({
}
const onItemKeyPress = (event: KeyboardEvent): undefined | number => {
- if (!(arrows as string[]).includes(event.key) || !nodeRef.value) return
+ if (!(arrows as string[]).includes(event.key) || !nodeRef.value) {
+ return
+ }
event.preventDefault()
@@ -149,19 +151,22 @@ export default defineComponent({
switch (event.key) {
case keycodes.ArrowUp:
- case resolveArrow(keycodes.ArrowLeft, keycodes.ArrowRight):
+ case resolveArrow(keycodes.ArrowLeft, keycodes.ArrowRight): {
if (targetIndex === 0) {
return ensureFocus(items[items.length - 1])
}
return ensureFocus(items[targetIndex - 1])
+ }
case keycodes.ArrowDown:
- case resolveArrow(keycodes.ArrowRight, keycodes.ArrowLeft):
+ case resolveArrow(keycodes.ArrowRight, keycodes.ArrowLeft): {
if (targetIndex === items.length - 1) {
return ensureFocus(items[0])
}
return ensureFocus(items[targetIndex + 1])
- default:
+ }
+ default: {
return
+ }
}
}
@@ -172,8 +177,12 @@ export default defineComponent({
* @param previousSelected
*/
const setSelected = (selected: boolean, previousSelected: boolean) => {
- if (previousSelected && !selected) selectedCount.value -= 1
- if (!previousSelected && selected) selectedCount.value += 1
+ if (previousSelected && !selected) {
+ selectedCount.value -= 1
+ }
+ if (!previousSelected && selected) {
+ selectedCount.value += 1
+ }
}
const focusContext = {
diff --git a/frontend/src/components/VLink.vue b/frontend/src/components/VLink.vue
index 2fbd6e559..0c811ea84 100644
--- a/frontend/src/components/VLink.vue
+++ b/frontend/src/components/VLink.vue
@@ -138,7 +138,9 @@ export default defineComponent({
const { sendCustomEvent } = useAnalytics()
const handleExternalClick = () => {
- if (!checkHref(props) || !props.sendExternalLinkClickEvent) return
+ if (!checkHref(props) || !props.sendExternalLinkClickEvent) {
+ return
+ }
sendCustomEvent("EXTERNAL_LINK_CLICK", {
url: props.href,
})
diff --git a/frontend/src/components/VLoadMore.vue b/frontend/src/components/VLoadMore.vue
index da9cadce4..2d1751213 100644
--- a/frontend/src/components/VLoadMore.vue
+++ b/frontend/src/components/VLoadMore.vue
@@ -75,7 +75,9 @@ export default defineComponent({
*
*/
const onLoadMore = async () => {
- if (fetchState.value.isFetching) return
+ if (fetchState.value.isFetching) {
+ return
+ }
reachResultEndEventSent.value = false
diff --git a/frontend/src/components/VMediaInfo/VByLine/VByLine.vue b/frontend/src/components/VMediaInfo/VByLine/VByLine.vue
index cb5c7709f..46e920959 100644
--- a/frontend/src/components/VMediaInfo/VByLine/VByLine.vue
+++ b/frontend/src/components/VMediaInfo/VByLine/VByLine.vue
@@ -147,7 +147,9 @@ export default defineComponent({
)
onMounted(() => {
- if (!buttonsRef.value || !containerRef.value) return
+ if (!buttonsRef.value || !containerRef.value) {
+ return
+ }
if (buttonsRef.value?.scrollWidth > containerRef.value.scrollWidth) {
setScrollable()
}
@@ -173,7 +175,9 @@ export default defineComponent({
}
const scroll = (to: "start" | "end") => {
- if (!buttonsRef.value) return
+ if (!buttonsRef.value) {
+ return
+ }
const buttons = buttonsRef.value
showScrollButton[to === "start" ? "end" : "start"] = true
@@ -203,7 +207,9 @@ export default defineComponent({
watchDebounced(
x,
(xValue) => {
- if (!buttonsRef.value) return
+ if (!buttonsRef.value) {
+ return
+ }
// This is necessary for handling both RTL and LTR.
const distFromStart = Math.abs(xValue)
const distFromEnd =
@@ -219,7 +225,9 @@ export default defineComponent({
const searchStore = useSearchStore()
const creatorHref = computed(() => {
- if (!props.creator) return undefined
+ if (!props.creator) {
+ return undefined
+ }
return searchStore.getCollectionPath({
type: props.mediaType,
collectionParams: {
diff --git a/frontend/src/components/VMediaInfo/VCopyLicense.vue b/frontend/src/components/VMediaInfo/VCopyLicense.vue
index a6244acaf..7c7acd59a 100644
--- a/frontend/src/components/VMediaInfo/VCopyLicense.vue
+++ b/frontend/src/components/VMediaInfo/VCopyLicense.vue
@@ -76,7 +76,9 @@ export default defineComponent({
const { sendCustomEvent } = useAnalytics()
const sendAnalyticsEvent = (event: MouseEvent) => {
- if (!event.currentTarget) return
+ if (!event.currentTarget) {
+ return
+ }
const url = (event.currentTarget as HTMLAnchorElement).href
sendCustomEvent("EXTERNAL_LINK_CLICK", { url })
diff --git a/frontend/src/components/VMediaInfo/VMediaDetails.vue b/frontend/src/components/VMediaInfo/VMediaDetails.vue
index c4a319e3f..e75de6ce4 100644
--- a/frontend/src/components/VMediaInfo/VMediaDetails.vue
+++ b/frontend/src/components/VMediaInfo/VMediaDetails.vue
@@ -55,7 +55,9 @@ export default defineComponent({
const i18n = useI18n()
const metadata = computed<null | Metadata[]>(() => {
- if (!props.media) return null
+ if (!props.media) {
+ return null
+ }
return getMediaMetadata(props.media, i18n, {
width: props.imageWidth,
height: props.imageHeight,
diff --git a/frontend/src/components/VMediaInfo/VMetadata.vue b/frontend/src/components/VMediaInfo/VMetadata.vue
index f072b0fcc..191642c00 100644
--- a/frontend/src/components/VMediaInfo/VMetadata.vue
+++ b/frontend/src/components/VMediaInfo/VMetadata.vue
@@ -52,7 +52,9 @@ export default defineComponent({
const { sendCustomEvent } = useAnalytics()
const sendVisitSourceLinkEvent = (source?: string) => {
- if (!source) return
+ if (!source) {
+ return
+ }
sendCustomEvent("VISIT_SOURCE_LINK", {
id: route.value.params.id,
source,
diff --git a/frontend/src/components/VSearchResultsGrid/VAudioResult.vue b/frontend/src/components/VSearchResultsGrid/VAudioResult.vue
index a3413afbb..2c7361639 100644
--- a/frontend/src/components/VSearchResultsGrid/VAudioResult.vue
+++ b/frontend/src/components/VSearchResultsGrid/VAudioResult.vue
@@ -66,7 +66,9 @@ export default defineComponent({
) => {
// Only send the event when the click navigates to the single result page.
// If the click is in waveform or audio-control button, it controls the audio player.
- if (inWaveform) return
+ if (inWaveform) {
+ return
+ }
useAudioSnackbar().hide()
sendCustomEvent("SELECT_SEARCH_RESULT", {
id: audio.id,
diff --git a/frontend/src/components/VSkeleton/VGridSkeleton.vue b/frontend/src/components/VSkeleton/VGridSkeleton.vue
index 578a798f2..58c4bd3b1 100644
--- a/frontend/src/components/VSkeleton/VGridSkeleton.vue
+++ b/frontend/src/components/VSkeleton/VGridSkeleton.vue
@@ -53,9 +53,15 @@ export default defineComponent({
const elementCount = computed(() => {
// Calculate the default element count based on isForTab
- if (props.numElems) return props.numElems
- if (props.isForTab === "all") return 20
- if (props.isForTab === "image") return 30
+ if (props.numElems) {
+ return props.numElems
+ }
+ if (props.isForTab === "all") {
+ return 20
+ }
+ if (props.isForTab === "image") {
+ return 30
+ }
return 8
})
diff --git a/frontend/src/components/VSourcesTable.vue b/frontend/src/components/VSourcesTable.vue
index 719488bf3..9b2274b75 100644
--- a/frontend/src/components/VSourcesTable.vue
+++ b/frontend/src/components/VSourcesTable.vue
@@ -120,8 +120,12 @@ export default defineComponent({
field1 = cleanSourceUrlForPresentation(field1 as string)
field2 = cleanSourceUrlForPresentation(field2 as string)
}
- if (field1 > field2) return 1
- if (field1 < field2) return -1
+ if (field1 > field2) {
+ return 1
+ }
+ if (field1 < field2) {
+ return -1
+ }
return 0
}
diff --git a/frontend/src/components/VTabs/VTab.vue b/frontend/src/components/VTabs/VTab.vue
index ece0a5da0..9b80969d9 100644
--- a/frontend/src/components/VTabs/VTab.vue
+++ b/frontend/src/components/VTabs/VTab.vue
@@ -78,7 +78,9 @@ export default defineComponent({
const isSelected = computed(() => tabContext.selectedId.value === props.id)
const handleFocus = () => {
- if (props.disabled) return
+ if (props.disabled) {
+ return
+ }
if (tabContext.activation.value === "auto") {
tabContext.setSelectedId(props.id)
}
@@ -86,7 +88,9 @@ export default defineComponent({
}
const handleSelection = () => {
- if (props.disabled) return
+ if (props.disabled) {
+ return
+ }
getDomElement(internalTabRef)?.focus()
tabContext.setSelectedId(props.id)
}
@@ -141,33 +145,38 @@ export default defineComponent({
switch (event.key) {
case keycodes.Spacebar:
- case keycodes.Enter:
+ case keycodes.Enter: {
tabContext.setSelectedId(props.id)
break
+ }
case keycodes.Home:
- case keycodes.PageUp:
+ case keycodes.PageUp: {
focusIn(list, Focus.First)
break
+ }
case keycodes.End:
- case keycodes.PageDown:
+ case keycodes.PageDown: {
focusIn(list, Focus.Last)
break
- case keycodes.ArrowLeft:
+ }
+ case keycodes.ArrowLeft: {
focusIn(
list,
getFocusDirection(keycodes.ArrowLeft, document.dir) |
Focus.WrapAround
)
break
+ }
- case keycodes.ArrowRight:
+ case keycodes.ArrowRight: {
focusIn(
list,
getFocusDirection(keycodes.ArrowRight, document.dir) |
Focus.WrapAround
)
break
+ }
}
}
diff --git a/frontend/src/components/VTabs/VTabs.vue b/frontend/src/components/VTabs/VTabs.vue
index d40ced2f9..6e8ab1a13 100644
--- a/frontend/src/components/VTabs/VTabs.vue
+++ b/frontend/src/components/VTabs/VTabs.vue
@@ -97,23 +97,33 @@ export default defineComponent({
tabs,
panels,
setSelectedId(id: string) {
- if (selectedId.value === id) return
+ if (selectedId.value === id) {
+ return
+ }
selectedId.value = id
emit("change", id)
},
registerTab(tab: (typeof tabs)["value"][number]) {
- if (!tabs.value.includes(tab)) tabs.value.push(tab)
+ if (!tabs.value.includes(tab)) {
+ tabs.value.push(tab)
+ }
},
unregisterTab(tab: (typeof tabs)["value"][number]) {
let idx = tabs.value.indexOf(tab)
- if (idx !== -1) tabs.value.splice(idx, 1)
+ if (idx !== -1) {
+ tabs.value.splice(idx, 1)
+ }
},
registerPanel(panel: (typeof panels)["value"][number]) {
- if (!panels.value.includes(panel)) panels.value.push(panel)
+ if (!panels.value.includes(panel)) {
+ panels.value.push(panel)
+ }
},
unregisterPanel(panel: (typeof panels)["value"][number]) {
let idx = panels.value.indexOf(panel)
- if (idx !== -1) panels.value.splice(idx, 1)
+ if (idx !== -1) {
+ panels.value.splice(idx, 1)
+ }
},
}
provide(tabsContextKey, tabGroupContext)
diff --git a/frontend/src/composables/default-ref.ts b/frontend/src/composables/default-ref.ts
index d4a97e680..707c0c387 100644
--- a/frontend/src/composables/default-ref.ts
+++ b/frontend/src/composables/default-ref.ts
@@ -12,7 +12,9 @@ export const defaultRef = <T>(getDefault: () => T) => {
const explicitlySet = ref<T | typeof NotSet>(NotSet)
return computed<T>({
get() {
- if (explicitlySet.value === NotSet) return getDefault()
+ if (explicitlySet.value === NotSet) {
+ return getDefault()
+ }
return explicitlySet.value as T
},
set(v) {
diff --git a/frontend/src/composables/use-body-scroll-lock.ts b/frontend/src/composables/use-body-scroll-lock.ts
index 0429eedb5..94a558c84 100644
--- a/frontend/src/composables/use-body-scroll-lock.ts
+++ b/frontend/src/composables/use-body-scroll-lock.ts
@@ -18,7 +18,9 @@ export function useBodyScrollLock({
watch(
nodeRef,
(node) => {
- if (node && locked.value) lock()
+ if (node && locked.value) {
+ lock()
+ }
},
{
immediate: true,
diff --git a/frontend/src/composables/use-dialog-content.ts b/frontend/src/composables/use-dialog-content.ts
index 1b5e75027..355f1592e 100644
--- a/frontend/src/composables/use-dialog-content.ts
+++ b/frontend/src/composables/use-dialog-content.ts
@@ -78,9 +78,15 @@ export function useDialogContent({
const onKeyDown = (event: KeyboardEvent) => {
emit("keydown", event)
- if (event.defaultPrevented) return
- if (event.key !== "Escape") return
- if (!hideOnEscRef.value) return
+ if (event.defaultPrevented) {
+ return
+ }
+ if (event.key !== "Escape") {
+ return
+ }
+ if (!hideOnEscRef.value) {
+ return
+ }
event.stopPropagation()
hideRef.value()
diff --git a/frontend/src/composables/use-dialog-control.ts b/frontend/src/composables/use-dialog-control.ts
index ec74ffd8a..a880605c4 100644
--- a/frontend/src/composables/use-dialog-control.ts
+++ b/frontend/src/composables/use-dialog-control.ts
@@ -62,7 +62,9 @@ export function useDialogControl({
const shouldLockBodyScroll = computed(() => unref(lockBodyScroll) ?? false)
watch(shouldLockBodyScroll, (shouldLock) => {
if (shouldLock) {
- if (internalVisibleRef.value) lock()
+ if (internalVisibleRef.value) {
+ lock()
+ }
} else {
unlock()
}
@@ -72,7 +74,9 @@ export function useDialogControl({
const close = () => {
const fn = toValue(deactivateFocusTrap)
- if (fn) fn()
+ if (fn) {
+ fn()
+ }
internalVisibleRef.value = false
}
diff --git a/frontend/src/composables/use-event-listener-outside.ts b/frontend/src/composables/use-event-listener-outside.ts
index a1a1f36e6..dcdaf13a1 100644
--- a/frontend/src/composables/use-event-listener-outside.ts
+++ b/frontend/src/composables/use-event-listener-outside.ts
@@ -43,21 +43,30 @@ export const useEventListenerOutside = ({
document.removeEventListener(eventType, boundEventRef.value)
}
- if (!shouldListen) return
+ if (!shouldListen) {
+ return
+ }
boundEventRef.value = (event: Event) => {
- if (!listener || !container || !(event.target instanceof Element))
+ if (!listener || !container || !(event.target instanceof Element)) {
return
+ }
const target = event.target
// When an element is unmounted right after it receives focus, the focus
// event is triggered after that, when the element isn't part of the
// current document anymore. So we ignore it.
- if (!isInDocument(target)) return
+ if (!isInDocument(target)) {
+ return
+ }
// Event inside the container
- if (contains(container, target)) return
+ if (contains(container, target)) {
+ return
+ }
// Event on the trigger
- if (trigger && contains(trigger, target)) return
+ if (trigger && contains(trigger, target)) {
+ return
+ }
listener(event)
}
diff --git a/frontend/src/composables/use-floating-ui.ts b/frontend/src/composables/use-floating-ui.ts
index f04b25bdc..3c4c58113 100644
--- a/frontend/src/composables/use-floating-ui.ts
+++ b/frontend/src/composables/use-floating-ui.ts
@@ -74,7 +74,9 @@ export function useFloatingUi({ floatingElRef, floatingPropsRefs }: Props) {
cleanup.value?.()
return
}
- if (!visible) return
+ if (!visible) {
+ return
+ }
cleanup.value = buildAutoUpdate(triggerElement, floatingElement)
@@ -92,7 +94,9 @@ export function useFloatingUi({ floatingElRef, floatingPropsRefs }: Props) {
const detectMaxHeight = {
name: "detectMaxHeight",
async fn(state: MiddlewareState) {
- if (!floatingPropsRefs.clippable.value) return {}
+ if (!floatingPropsRefs.clippable.value) {
+ return {}
+ }
const overflow = await detectOverflow(state, { padding: FloatingOffset })
const verticalOverflow = Math.max(overflow.top, overflow.bottom)
diff --git a/frontend/src/composables/use-focus-on-blur.ts b/frontend/src/composables/use-focus-on-blur.ts
index ab16ed700..d3766206f 100644
--- a/frontend/src/composables/use-focus-on-blur.ts
+++ b/frontend/src/composables/use-focus-on-blur.ts
@@ -10,7 +10,9 @@ type Props = {
function isActualElement(
element: EventTarget | Element | null
): element is Element {
- if (!element) return false
+ if (!element) {
+ return false
+ }
const elementAsElement = element as Element
return !!(
elementAsElement.tagName &&
@@ -31,15 +33,21 @@ export function useFocusOnBlur({ dialogRef, visibleRef }: Props) {
const [blurredRef, scheduleFocus] = useBlurTracker()
watch([blurredRef], ([blurred]) => {
- if (!visibleRef.value) return
- if (!blurred) return
+ if (!visibleRef.value) {
+ return
+ }
+ if (!blurred) {
+ return
+ }
if (!isActualElement(getActiveElement(dialogRef.value))) {
dialogRef.value?.focus()
}
})
return (event: FocusEvent) => {
- if (visibleRef.value) return
+ if (visibleRef.value) {
+ return
+ }
const nextActiveElement = event.relatedTarget
if (!isActualElement(nextActiveElement as Element)) {
scheduleFocus()
diff --git a/frontend/src/composables/use-focus-on-hide.ts b/frontend/src/composables/use-focus-on-hide.ts
index 6e44fb28f..a0cdd5df2 100644
--- a/frontend/src/composables/use-focus-on-hide.ts
+++ b/frontend/src/composables/use-focus-on-hide.ts
@@ -11,13 +11,21 @@ type Props = {
}
function hidByFocusingAnotherElement(popover: HTMLElement) {
- if (!popover) return false
+ if (!popover) {
+ return false
+ }
const activeElement = getActiveElement(popover)
- if (!activeElement) return false
- if (contains(popover, activeElement)) return false
- if (isTabbable(activeElement)) return true
+ if (!activeElement) {
+ return false
+ }
+ if (contains(popover, activeElement)) {
+ return false
+ }
+ if (isTabbable(activeElement)) {
+ return true
+ }
return activeElement.getAttribute("data-popover") === "true"
}
@@ -38,11 +46,17 @@ export const useFocusOnHide = ({
const shouldFocus =
autoFocusOnHide && !visible && visible !== previousVisible
- if (!shouldFocus) return
+ if (!shouldFocus) {
+ return
+ }
- if (!dialog || hidByFocusingAnotherElement(dialog)) return
+ if (!dialog || hidByFocusingAnotherElement(dialog)) {
+ return
+ }
- if (triggerElement) ensureFocus(triggerElement)
+ if (triggerElement) {
+ ensureFocus(triggerElement)
+ }
}
)
}
diff --git a/frontend/src/composables/use-focus-on-show.ts b/frontend/src/composables/use-focus-on-show.ts
index c7e13f4d1..41efabb26 100644
--- a/frontend/src/composables/use-focus-on-show.ts
+++ b/frontend/src/composables/use-focus-on-show.ts
@@ -72,10 +72,14 @@ export const useFocusOnShow = ({
] as const,
([dialog, visible, autoFocusOnShow, initialFocusElement], _, onCleanup) => {
if (!dialog || !visible) {
- if (trap?.hasFocus) deactivateFocusTrap()
+ if (trap?.hasFocus) {
+ deactivateFocusTrap()
+ }
+ return
+ }
+ if (!autoFocusOnShow) {
return
}
- if (!autoFocusOnShow) return
nextTick(() => {
const isActive = () => hasFocusWithin(dialog)
diff --git a/frontend/src/composables/use-focus-trap.ts b/frontend/src/composables/use-focus-trap.ts
index d6ba2db1d..16659a219 100644
--- a/frontend/src/composables/use-focus-trap.ts
+++ b/frontend/src/composables/use-focus-trap.ts
@@ -101,7 +101,9 @@ export function useFocusTrap(
const stopWatcher = watch(
() => unrefElement(target),
(el) => {
- if (!el) return
+ if (!el) {
+ return
+ }
trap = createFocusTrap(el, {
...focusTrapOptions,
@@ -109,18 +111,24 @@ export function useFocusTrap(
hasFocus.value = true
// Apply if user provided onActivate option
- if (options.onActivate) options.onActivate()
+ if (options.onActivate) {
+ options.onActivate()
+ }
},
onDeactivate() {
hasFocus.value = false
// Apply if user provided onDeactivate option
- if (options.onDeactivate) options.onDeactivate()
+ if (options.onDeactivate) {
+ options.onDeactivate()
+ }
},
})
// Focus if immediate is set to true
- if (immediate) activate()
+ if (immediate) {
+ activate()
+ }
},
{ flush: "post" }
)
diff --git a/frontend/src/composables/use-hide-on-click-outside.ts b/frontend/src/composables/use-hide-on-click-outside.ts
index 6aeb1d99a..dfd67f405 100644
--- a/frontend/src/composables/use-hide-on-click-outside.ts
+++ b/frontend/src/composables/use-hide-on-click-outside.ts
@@ -25,7 +25,9 @@ function useMouseDownTargetRef({
watch(
[visibleRef, hideOnClickOutsideRef, dialogRef] as const,
([visible, hideOnClickOutside, popover], _, onInvalidate) => {
- if (!(visible && hideOnClickOutside)) return
+ if (!(visible && hideOnClickOutside)) {
+ return
+ }
const document = getDocument(popover)
const onMouseDown = (event: MouseEvent) =>
diff --git a/frontend/src/composables/use-i18n-sync.ts b/frontend/src/composables/use-i18n-sync.ts
index 0da61ab0a..0b7cce642 100644
--- a/frontend/src/composables/use-i18n-sync.ts
+++ b/frontend/src/composables/use-i18n-sync.ts
@@ -14,7 +14,9 @@ export function useI18nSync() {
})
const needsTranslationBanner = computed(() => {
- if (!currentLocale.value || currentLocale.value.code === "en") return false
+ if (!currentLocale.value || currentLocale.value.code === "en") {
+ return false
+ }
return (currentLocale.value?.translated ?? 100) <= 90
})
diff --git a/frontend/src/composables/use-image-cell-size.ts b/frontend/src/composables/use-image-cell-size.ts
index 2e16a4c78..8ee996e21 100644
--- a/frontend/src/composables/use-image-cell-size.ts
+++ b/frontend/src/composables/use-image-cell-size.ts
@@ -11,8 +11,12 @@ const squareSize = 250
const defaultImgSize = 100
const getImgAspectRatio = (aspect: number) => {
- if (aspect > maxAspect) return maxAspect
- if (aspect < minAspect) return minAspect
+ if (aspect > maxAspect) {
+ return maxAspect
+ }
+ if (aspect < minAspect) {
+ return minAspect
+ }
return aspect
}
diff --git a/frontend/src/composables/use-match-routes.ts b/frontend/src/composables/use-match-routes.ts
index 6539f3d0d..3a40af858 100644
--- a/frontend/src/composables/use-match-routes.ts
+++ b/frontend/src/composables/use-match-routes.ts
@@ -23,7 +23,9 @@ export const useMatchRoute = (
* @param route - the localized route name (e.g. `search__en`)
*/
const routeNameMatches = (route: string | null | undefined) => {
- if (!route) return false
+ if (!route) {
+ return false
+ }
return routes.includes(route.split("__")[0])
}
diff --git a/frontend/src/composables/use-search-type.ts b/frontend/src/composables/use-search-type.ts
index ff9ad26e7..970b888a0 100644
--- a/frontend/src/composables/use-search-type.ts
+++ b/frontend/src/composables/use-search-type.ts
@@ -56,7 +56,9 @@ export default function useSearchType() {
const searchTypes = [...supportedSearchTypes]
const setActiveType = (searchType: SearchType) => {
- if (previousSearchType.value === searchType) return
+ if (previousSearchType.value === searchType) {
+ return
+ }
analytics.sendCustomEvent("CHANGE_CONTENT_TYPE", {
previous: previousSearchType.value,
diff --git a/frontend/src/composables/use-search.ts b/frontend/src/composables/use-search.ts
index 3e3617d44..2c8c27aa4 100644
--- a/frontend/src/composables/use-search.ts
+++ b/frontend/src/composables/use-search.ts
@@ -57,8 +57,12 @@ export const useSearch = (
* to run and fetch new media.
*/
const updateSearchState = () => {
- if (searchTerm.value === "") return
- if (!searchTermChanged.value && isSearchRoute.value) return
+ if (searchTerm.value === "") {
+ return
+ }
+ if (!searchTermChanged.value && isSearchRoute.value) {
+ return
+ }
sendCustomEvent("SUBMIT_SEARCH", {
searchType: searchStore.searchType,
@@ -80,8 +84,12 @@ export const useSearch = (
* Shows the loading state or result count.
*/
const searchStatus = computed(() => {
- if (searchStore.searchTerm === "") return ""
- if (isFetching.value) return getLoading()
+ if (searchStore.searchTerm === "") {
+ return ""
+ }
+ if (isFetching.value) {
+ return getLoading()
+ }
return getI18nCount(resultsCount.value)
})
diff --git a/frontend/src/composables/use-seekable.ts b/frontend/src/composables/use-seekable.ts
index 307629f9b..b42e83cd7 100644
--- a/frontend/src/composables/use-seekable.ts
+++ b/frontend/src/composables/use-seekable.ts
@@ -78,16 +78,23 @@ export const useSeekable = ({
}
const handleKeys = (event: KeyboardEvent) => {
- if (!willBeHandled(event)) return
+ if (!willBeHandled(event)) {
+ return
+ }
event.preventDefault()
isSeeking.value = (seekingKeys as string[]).includes(event.key)
- if ((arrowKeys as string[]).includes(event.key))
+ if ((arrowKeys as string[]).includes(event.key)) {
return handleArrowKeys(event)
- if (event.key === keycodes.Home) return onSeek(0)
- if (event.key === keycodes.End) return onSeek(1)
+ }
+ if (event.key === keycodes.Home) {
+ return onSeek(0)
+ }
+ if (event.key === keycodes.End) {
+ return onSeek(1)
+ }
if (event.key === keycodes.Spacebar) {
return onTogglePlayback()
}
diff --git a/frontend/src/composables/use-sensitive-media.ts b/frontend/src/composables/use-sensitive-media.ts
index 9d4290078..97d4fa2eb 100644
--- a/frontend/src/composables/use-sensitive-media.ts
+++ b/frontend/src/composables/use-sensitive-media.ts
@@ -55,7 +55,9 @@ export function useSensitiveMedia(
function hide() {
const media = unref(rawMedia)
- if (!media) return
+ if (!media) {
+ return
+ }
const index = uiStore.revealedSensitiveResults.indexOf(media.id)
if (index > -1) {
uiStore.revealedSensitiveResults.splice(index, 1)
diff --git a/frontend/src/composables/use-single-result-page-meta.ts b/frontend/src/composables/use-single-result-page-meta.ts
index b80191020..3503539ec 100644
--- a/frontend/src/composables/use-single-result-page-meta.ts
+++ b/frontend/src/composables/use-single-result-page-meta.ts
@@ -15,7 +15,9 @@ export const useSingleResultPageMeta = (
const i18n = useI18n()
const titles = () => {
- if (!media.value) return { genericTitle: "", sensitiveTitle: "" }
+ if (!media.value) {
+ return { genericTitle: "", sensitiveTitle: "" }
+ }
return {
genericTitle: `${i18n.t(
`mediaDetails.reuse.${media.value.frontendMediaType}`
@@ -30,7 +32,9 @@ export const useSingleResultPageMeta = (
// Do not show sensitive content title in the social preview cards.
const getMediaTitle = () => {
- if (!media.value) return ""
+ if (!media.value) {
+ return ""
+ }
return isSensitive.value
? titles().sensitiveTitle
: media.value.title ?? titles().genericTitle
diff --git a/frontend/src/locales/scripts/json-helpers.js b/frontend/src/locales/scripts/json-helpers.js
index 8ebec335c..7f8ba2703 100644
--- a/frontend/src/locales/scripts/json-helpers.js
+++ b/frontend/src/locales/scripts/json-helpers.js
@@ -35,7 +35,9 @@ function readPaths(obj, path = "") {
result.push(fullPath)
continue
}
- if (value === obj) continue
+ if (value === obj) {
+ continue
+ }
stack.push([fullPath, value])
}
return [result, stack]
diff --git a/frontend/src/locales/scripts/json-pot-helpers.js b/frontend/src/locales/scripts/json-pot-helpers.js
index fc0f9517a..9ad28899d 100644
--- a/frontend/src/locales/scripts/json-pot-helpers.js
+++ b/frontend/src/locales/scripts/json-pot-helpers.js
@@ -37,7 +37,9 @@ const checkStringForVars = (str) =>
* @return {string} the translation string with all placeholders marked
*/
const replaceVarsPlaceholders = (str) => {
- if (!containsCurlyWord(str)) return str
+ if (!containsCurlyWord(str)) {
+ return str
+ }
const variable = /\{(?<variable>[a-zA-Z-]*)}/g
return str.replace(variable, `###$<variable>###`)
@@ -93,15 +95,21 @@ const getComment = (entry) => {
const comment = []
// comments given by the programmer, directed at the translator (#.)
- if (entry.doc) comment.push(`#. ${entry.doc}`)
+ if (entry.doc) {
+ comment.push(`#. ${entry.doc}`)
+ }
// comments given by the programmer, directed at the translator (#.)
let vars = checkStringForVars(entry.value)
- if (vars) comment.push(vars)
+ if (vars) {
+ comment.push(vars)
+ }
// comments containing references to the program’s source code (#:)
let refComments = getRefComments(entry.lineage)
- if (refComments.length) comment.push(...refComments)
+ if (refComments.length) {
+ comment.push(...refComments)
+ }
return comment.map((item) => `${item}`).join("\n")
}
@@ -122,7 +130,9 @@ const toPot = (entry) => {
// string-string type mapping
let poEntry = []
let comment = getComment(entry)
- if (comment) poEntry.push(comment)
+ if (comment) {
+ poEntry.push(comment)
+ }
poEntry.push(`msgctxt "${entry.lineage}"`)
if (entry.value.includes("|") && /(count|time)/i.test(entry.value)) {
const pluralizedValues = entry.value.split("|")
diff --git a/frontend/src/locales/scripts/read-i18n.js b/frontend/src/locales/scripts/read-i18n.js
index d688b4c5b..f453deac2 100644
--- a/frontend/src/locales/scripts/read-i18n.js
+++ b/frontend/src/locales/scripts/read-i18n.js
@@ -79,13 +79,18 @@ class Entry {
*/
toJSON() {
// This is a string-string entry, will be handled by parent.
- if (this.value) return {}
+ if (this.value) {
+ return {}
+ }
/** @type {SimJson} */
const pojo = {}
for (const child of this.children) {
- if (child.value) pojo[child.key] = child.value
- else pojo[child.key] = child.toJSON()
+ if (child.value) {
+ pojo[child.key] = child.value
+ } else {
+ pojo[child.key] = child.toJSON()
+ }
}
return pojo
}
@@ -99,12 +104,16 @@ class Entry {
* @return {string} the text content of the key
*/
const parseKey = (keyNode) => {
- if (keyNode === undefined) return ""
+ if (keyNode === undefined) {
+ return ""
+ }
switch (keyNode.type) {
- case "StringLiteral":
+ case "StringLiteral": {
return keyNode.value
- case "Identifier":
+ }
+ case "Identifier": {
return keyNode.name
+ }
}
}
@@ -117,13 +126,15 @@ const parseKey = (keyNode) => {
*/
const parseComment = (commentNode) => {
switch (commentNode.type) {
- case "CommentLine":
+ case "CommentLine": {
return commentNode.value.trim()
- case "CommentBlock":
+ }
+ case "CommentBlock": {
return commentNode.value
.replace(/\n|\*+/g, "")
.replace(/\s+/, " ")
.trim()
+ }
}
}
@@ -136,14 +147,16 @@ const parseComment = (commentNode) => {
*/
const parseValue = (entry, valueNode) => {
switch (valueNode.type) {
- case "StringLiteral":
+ case "StringLiteral": {
entry.value = valueNode.value
break
- case "ObjectExpression":
+ }
+ case "ObjectExpression": {
valueNode.properties.map(parseObjProperty).forEach((child) => {
entry.addChild(child)
})
break
+ }
}
}
diff --git a/frontend/src/locales/scripts/utils.js b/frontend/src/locales/scripts/utils.js
index 94bbafdd6..6fd237037 100644
--- a/frontend/src/locales/scripts/utils.js
+++ b/frontend/src/locales/scripts/utils.js
@@ -6,7 +6,9 @@ const os = require("os")
*/
function kebabToCamel(input) {
const split = input.split("-")
- if (split.length === 1) return input
+ if (split.length === 1) {
+ return input
+ }
for (let i = 1; i < split.length; i++) {
split[i] = split[i][0].toUpperCase() + split[i].slice(1)
@@ -30,7 +32,9 @@ exports.setToValue = function setValue(obj, path, value) {
var o = obj
while (a.length - 1) {
var n = a.shift()
- if (!(n in o)) o[n] = {}
+ if (!(n in o)) {
+ o[n] = {}
+ }
o = o[n]
}
o[a[0]] = value
diff --git a/frontend/src/middleware/search.ts b/frontend/src/middleware/search.ts
index 93a19c545..ba337051e 100644
--- a/frontend/src/middleware/search.ts
+++ b/frontend/src/middleware/search.ts
@@ -28,7 +28,9 @@ export const searchMiddleware: Middleware = async ({
* `prepare-search-query-params`.
* Note that the search by creator is not displayed in the UI.
*/
- if (!q) return redirect("/")
+ if (!q) {
+ return redirect("/")
+ }
const searchStore = useSearchStore($pinia)
diff --git a/frontend/src/pages/image/_id/index.vue b/frontend/src/pages/image/_id/index.vue
index 06efb5673..d8713cd82 100644
--- a/frontend/src/pages/image/_id/index.vue
+++ b/frontend/src/pages/image/_id/index.vue
@@ -227,7 +227,9 @@ export default defineComponent({
* @param event - the image load event.
*/
const onImageLoaded = (event: Event) => {
- if (!(event.target instanceof HTMLImageElement) || !image.value) return
+ if (!(event.target instanceof HTMLImageElement) || !image.value) {
+ return
+ }
isLoadingThumbnail.value = false
diff --git a/frontend/src/pages/search.vue b/frontend/src/pages/search.vue
index 403e97bf7..b95cb25f8 100644
--- a/frontend/src/pages/search.vue
+++ b/frontend/src/pages/search.vue
@@ -136,7 +136,9 @@ export default defineComponent({
mediaStore.fetchState.hasStarted &&
fetchingError.value !== null &&
!isRetriable(fetchingError.value)
- if (shouldNotRefetch) return
+ if (shouldNotRefetch) {
+ return
+ }
await mediaStore.fetchMedia(payload)
diff --git a/frontend/src/stores/feature-flag.ts b/frontend/src/stores/feature-flag.ts
index cf2fad22e..1e266c9db 100644
--- a/frontend/src/stores/feature-flag.ts
+++ b/frontend/src/stores/feature-flag.ts
@@ -43,11 +43,14 @@ const FEATURE_FLAG = "feature_flag"
*/
export const getFlagStatus = (flag: FeatureFlag): FlagStatus => {
const deployEnv = (process.env.DEPLOYMENT_ENV ?? LOCAL) as DeployEnv
- if (typeof flag.status === "string") return flag.status
- else {
+ if (typeof flag.status === "string") {
+ return flag.status
+ } else {
const envIndex = DEPLOY_ENVS.indexOf(deployEnv)
for (let i = envIndex; i < DEPLOY_ENVS.length; i += 1) {
- if (DEPLOY_ENVS[i] in flag.status) return flag.status[DEPLOY_ENVS[i]]
+ if (DEPLOY_ENVS[i] in flag.status) {
+ return flag.status[DEPLOY_ENVS[i]]
+ }
}
}
return DISABLED
@@ -61,9 +64,12 @@ export const getFlagStatus = (flag: FeatureFlag): FlagStatus => {
*/
const getFeatureState = (flag: FeatureFlag): FeatureState => {
const status = getFlagStatus(flag)
- if (status === SWITCHABLE)
+ if (status === SWITCHABLE) {
return flag.preferredState ?? flag.defaultState ?? OFF
- if (status === ENABLED) return ON
+ }
+ if (status === ENABLED) {
+ return ON
+ }
return OFF
}
@@ -81,8 +87,9 @@ export const useFeatureFlagStore = defineStore(FEATURE_FLAG, {
featureState:
(state: FeatureFlagState) =>
(name: FlagName): FeatureState => {
- if (name in state.flags) return getFeatureState(state.flags[name])
- else {
+ if (name in state.flags) {
+ return getFeatureState(state.flags[name])
+ } else {
warn(`Invalid feature flag accessed: ${name}`)
return ON
}
@@ -105,8 +112,9 @@ export const useFeatureFlagStore = defineStore(FEATURE_FLAG, {
(dest: string): Record<string, FeatureState> => {
const featureMap: Record<string, FeatureState> = {}
Object.entries(state.flags).forEach(([name, flag]) => {
- if (getFlagStatus(flag) === SWITCHABLE && flag.storage === dest)
+ if (getFlagStatus(flag) === SWITCHABLE && flag.storage === dest) {
featureMap[name] = getFeatureState(flag)
+ }
})
return featureMap
},
@@ -199,8 +207,12 @@ export const useFeatureFlagStore = defineStore(FEATURE_FLAG, {
flag.preferredState = targetState
this.writeToCookie()
this.writeToSession()
- if (name === "analytics") this.syncAnalyticsWithLocalStorage()
- } else warn(`Cannot set preferred state for non-switchable flag: ${name}`)
+ if (name === "analytics") {
+ this.syncAnalyticsWithLocalStorage()
+ }
+ } else {
+ warn(`Cannot set preferred state for non-switchable flag: ${name}`)
+ }
},
/**
* For Plausible to stop tracking `plausible_ignore` must be set in
diff --git a/frontend/src/stores/media/index.ts b/frontend/src/stores/media/index.ts
index 4e9ba59a2..67278640a 100644
--- a/frontend/src/stores/media/index.ts
+++ b/frontend/src/stores/media/index.ts
@@ -94,7 +94,9 @@ export const useMediaStore = defineStore("media", {
getItemById: (state) => {
return (mediaType: SupportedMediaType, id: string): Media | undefined => {
const itemFromSearchResults = state.results[mediaType].items[id]
- if (itemFromSearchResults) return itemFromSearchResults
+ if (itemFromSearchResults) {
+ return itemFromSearchResults
+ }
return useRelatedMediaStore().getItemById(id)
}
},
@@ -264,7 +266,9 @@ export const useMediaStore = defineStore("media", {
)
// Prevent the bunching of audio results at the end.
- if (nonImageIndex > newResults.length) break
+ if (nonImageIndex > newResults.length) {
+ break
+ }
}
}
@@ -330,18 +334,22 @@ export const useMediaStore = defineStore("media", {
error?: FetchingError
) {
switch (action) {
- case "reset":
+ case "reset": {
this._resetFetchState()
break
- case "start":
+ }
+ case "start": {
this._startFetching(mediaType)
break
- case "end":
+ }
+ case "end": {
this._endFetching(mediaType, error)
break
- case "finish":
+ }
+ case "finish": {
this._finishFetchingForQuery(mediaType)
break
+ }
}
},
diff --git a/frontend/src/stores/media/single-result.ts b/frontend/src/stores/media/single-result.ts
index c4971a901..0a85aa5cc 100644
--- a/frontend/src/stores/media/single-result.ts
+++ b/frontend/src/stores/media/single-result.ts
@@ -108,7 +108,9 @@ export const useSingleResultStore = defineStore("single-result", {
* itself later.
*/
setMediaById(type: SupportedMediaType, id: string) {
- if (this.mediaId === id && isMediaDetail(this.mediaItem, type)) return
+ if (this.mediaId === id && isMediaDetail(this.mediaItem, type)) {
+ return
+ }
const existingItem = useMediaStore().getItemById(type, id)
if (existingItem) {
this.setMediaItem(existingItem)
diff --git a/frontend/src/stores/search.ts b/frontend/src/stores/search.ts
index 301daeb82..6c15534fb 100644
--- a/frontend/src/stores/search.ts
+++ b/frontend/src/stores/search.ts
@@ -291,7 +291,9 @@ export const useSearchStore = defineStore("search", {
*/
setSearchTerm(q: string | undefined | null) {
const formattedTerm = q ? q.trim() : ""
- if (this.searchTerm === formattedTerm) return
+ if (this.searchTerm === formattedTerm) {
+ return
+ }
this.searchTerm = formattedTerm
this.localSearchTerm = formattedTerm
this.collectionParams = null
@@ -516,7 +518,9 @@ export const useSearchStore = defineStore("search", {
this.setSearchTerm(query.q)
this.searchType = pathToSearchType(path)
- if (!isSearchTypeSupported(this.searchType)) return
+ if (!isSearchTypeSupported(this.searchType)) {
+ return
+ }
const newFilterData = queryToFilterData({
query,
diff --git a/frontend/src/stores/ui.ts b/frontend/src/stores/ui.ts
index 0a123c63a..4a87c675c 100644
--- a/frontend/src/stores/ui.ts
+++ b/frontend/src/stores/ui.ts
@@ -153,8 +153,9 @@ export const useUiStore = defineStore("ui", {
if (
cookies.uiBreakpoint &&
Object.keys(ALL_SCREEN_SIZES).includes(cookies.uiBreakpoint)
- )
+ ) {
breakpoint = cookies.uiBreakpoint
+ }
this.updateBreakpoint(breakpoint)
if (typeof cookies.uiIsFilterDismissed === "boolean") {
diff --git a/frontend/src/utils/attribution-html.ts b/frontend/src/utils/attribution-html.ts
index 4c0222bd7..d40f72e4b 100644
--- a/frontend/src/utils/attribution-html.ts
+++ b/frontend/src/utils/attribution-html.ts
@@ -90,8 +90,11 @@ const fakeT = (
let text: string | undefined = undefined
segments.forEach((segment) => {
const piece = fraction[segment]
- if (typeof piece === "string") text = piece
- else fraction = piece
+ if (typeof piece === "string") {
+ text = piece
+ } else {
+ fraction = piece
+ }
})
return text ? fmt(text, replacements) : ""
}
@@ -165,7 +168,9 @@ export const getAttribution = (
includeIcons: true,
}
): string => {
- if (!mediaItem) return ""
+ if (!mediaItem) {
+ return ""
+ }
const isPd = isPublicDomain(mediaItem.license)
@@ -178,10 +183,15 @@ export const getAttribution = (
/* Title */
let title = mediaItem.originalTitle || tFn("genericTitle")
- if (!isPlaintext) title = escapeHtml(title)
- if (!isPlaintext && mediaItem.foreign_landing_url)
+ if (!isPlaintext) {
+ title = escapeHtml(title)
+ }
+ if (!isPlaintext && mediaItem.foreign_landing_url) {
title = extLink(mediaItem.foreign_landing_url, title)
- if (mediaItem.originalTitle) title = tFn("actualTitle", { title })
+ }
+ if (mediaItem.originalTitle) {
+ title = tFn("actualTitle", { title })
+ }
/* License */
@@ -195,11 +205,14 @@ export const getAttribution = (
const elements = getElements(mediaItem.license)
const icons = elements.map((element) => licenseElementImg(element))
// Icons are only rendered if present for every element
- if (!icons.includes("")) licenseIcons = icons.join("")
+ if (!icons.includes("")) {
+ licenseIcons = icons.join("")
+ }
}
let license = `${fullLicenseName} ${licenseIcons}`.trim()
- if (!isPlaintext && mediaItem.license_url)
+ if (!isPlaintext && mediaItem.license_url) {
license = extLink(`${mediaItem.license_url}?ref=openverse`, license)
+ }
/* Attribution */
@@ -220,9 +233,12 @@ export const getAttribution = (
if (mediaItem.creator) {
let creator = mediaItem.creator
- if (!isPlaintext) creator = escapeHtml(creator)
- if (!isPlaintext && mediaItem.creator_url)
+ if (!isPlaintext) {
+ creator = escapeHtml(creator)
+ }
+ if (!isPlaintext && mediaItem.creator_url) {
creator = extLink(mediaItem.creator_url, creator)
+ }
attributionParts.creator = tFn("creatorText", {
creatorName: creator,
})
diff --git a/frontend/src/utils/case.ts b/frontend/src/utils/case.ts
index 084202324..baaaf37a9 100644
--- a/frontend/src/utils/case.ts
+++ b/frontend/src/utils/case.ts
@@ -27,9 +27,15 @@ function split(input: string) {
let end = result.length
// Trim the delimiter from around the output string.
- while (result.charAt(start) === "\0") start++
- if (start === end) return []
- while (result.charAt(end - 1) === "\0") end--
+ while (result.charAt(start) === "\0") {
+ start++
+ }
+ if (start === end) {
+ return []
+ }
+ while (result.charAt(end - 1) === "\0") {
+ end--
+ }
return result.slice(start, end).split(/\0/g)
}
@@ -57,7 +63,9 @@ export function camelCase(input: string) {
const transform = pascalCaseTransformFactory()
return split(input)
.map((word, index) => {
- if (index === 0) return word.toLowerCase()
+ if (index === 0) {
+ return word.toLowerCase()
+ }
return transform(word, index)
})
.join("")
diff --git a/frontend/src/utils/decode-data.ts b/frontend/src/utils/decode-data.ts
index 3bb27f71a..f6d48cf8a 100644
--- a/frontend/src/utils/decode-data.ts
+++ b/frontend/src/utils/decode-data.ts
@@ -6,7 +6,9 @@
* @param data - the string to unescape so that it can be rendered
*/
export const decodeData = (data = ""): string => {
- if (!data) return ""
+ if (!data) {
+ return ""
+ }
try {
const regexes = [
diff --git a/frontend/src/utils/decode-media-data.ts b/frontend/src/utils/decode-media-data.ts
index 6dec35088..a1ebf4e66 100644
--- a/frontend/src/utils/decode-media-data.ts
+++ b/frontend/src/utils/decode-media-data.ts
@@ -26,7 +26,9 @@ const isFiletypeMatching = (extension: string, filetype?: string) => {
if (filetype === extension) {
return true
}
- if (!filetype) return false
+ if (!filetype) {
+ return false
+ }
return matchers.some((matcher) =>
Boolean(filetype.match(matcher) && extension.match(matcher))
)
diff --git a/frontend/src/utils/dom.ts b/frontend/src/utils/dom.ts
index 85f80c757..ab71ca004 100644
--- a/frontend/src/utils/dom.ts
+++ b/frontend/src/utils/dom.ts
@@ -4,8 +4,12 @@ import type { Ref, ComponentPublicInstance } from "vue"
export function getDomElement<T extends Element | ComponentPublicInstance>(
ref?: Ref<T | null>
): T | null {
- if (ref == null) return null
- if (ref.value == null) return null
+ if (ref == null) {
+ return null
+ }
+ if (ref.value == null) {
+ return null
+ }
return "$el" in ref.value ? (ref.value.$el as T | null) : ref.value
}
diff --git a/frontend/src/utils/errors.ts b/frontend/src/utils/errors.ts
index 64e3aa5a3..0d4c3fe5f 100644
--- a/frontend/src/utils/errors.ts
+++ b/frontend/src/utils/errors.ts
@@ -65,7 +65,9 @@ const isNonRetryableErrorStatusCode = (statusCode: number | undefined) => {
const isValidErrorCode = (
code: string | undefined | null
): code is ErrorCode => {
- if (!code) return false
+ if (!code) {
+ return false
+ }
return (errorCodes as readonly string[]).includes(code)
}
diff --git a/frontend/src/utils/focus-management.ts b/frontend/src/utils/focus-management.ts
index d5d418d16..b9db344ea 100644
--- a/frontend/src/utils/focus-management.ts
+++ b/frontend/src/utils/focus-management.ts
@@ -6,11 +6,17 @@ import type { Ref } from "vue"
function getOwnerDocument<T extends Element | Ref<Element | null>>(
element: T | null | undefined
) {
- if (typeof window === "undefined") return null
- if (element instanceof Node) return element.ownerDocument
+ if (typeof window === "undefined") {
+ return null
+ }
+ if (element instanceof Node) {
+ return element.ownerDocument
+ }
if (element && Object.prototype.hasOwnProperty.call(element, "value")) {
const domElement = getDomElement(element)
- if (domElement) return domElement.ownerDocument
+ if (domElement) {
+ return domElement.ownerDocument
+ }
}
return document
@@ -69,12 +75,16 @@ export const Direction = Object.freeze({ Next: 1, Previous: -1 })
export function getFocusableElements(
container: HTMLElement | null = document.body
) {
- if (container == null) return []
+ if (container == null) {
+ return []
+ }
return Array.from(container.querySelectorAll<HTMLElement>(focusableSelector))
}
export function isFocusableElement(element: HTMLElement) {
- if (element === getOwnerDocument(element)?.body) return false
+ if (element === getOwnerDocument(element)?.body) {
+ return false
+ }
return element.matches(focusableSelector)
}
@@ -99,12 +109,18 @@ export function sortByDomNode<T>(
const a = resolveKey(aItem)
const z = resolveKey(zItem)
- if (a === null || z === null) return 0
+ if (a === null || z === null) {
+ return 0
+ }
const position = a.compareDocumentPosition(z)
- if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1
- if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
+ return -1
+ }
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
+ return 1
+ }
return 0
})
}
@@ -123,8 +139,12 @@ export function focusIn(container: HTMLElement | HTMLElement[], focus: number) {
const active = ownerDocument.activeElement as HTMLElement
const direction = (() => {
- if (focus & (Focus.First | Focus.Next)) return Direction.Next
- if (focus & (Focus.Previous | Focus.Last)) return Direction.Previous
+ if (focus & (Focus.First | Focus.Next)) {
+ return Direction.Next
+ }
+ if (focus & (Focus.Previous | Focus.Last)) {
+ return Direction.Previous
+ }
throw new Error(
"Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last"
@@ -132,10 +152,18 @@ export function focusIn(container: HTMLElement | HTMLElement[], focus: number) {
})()
const startIndex = (() => {
- if (focus & Focus.First) return 0
- if (focus & Focus.Previous) return Math.max(0, elements.indexOf(active)) - 1
- if (focus & Focus.Next) return Math.max(0, elements.indexOf(active)) + 1
- if (focus & Focus.Last) return elements.length - 1
+ if (focus & Focus.First) {
+ return 0
+ }
+ if (focus & Focus.Previous) {
+ return Math.max(0, elements.indexOf(active)) - 1
+ }
+ if (focus & Focus.Next) {
+ return Math.max(0, elements.indexOf(active)) + 1
+ }
+ if (focus & Focus.Last) {
+ return elements.length - 1
+ }
throw new Error(
"Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last"
@@ -147,15 +175,21 @@ export function focusIn(container: HTMLElement | HTMLElement[], focus: number) {
let next = undefined
do {
// Guard against infinite loops
- if (offset >= total || offset + total <= 0) return FocusResult.Error
+ if (offset >= total || offset + total <= 0) {
+ return FocusResult.Error
+ }
let nextIdx = startIndex + offset
if (focus & Focus.WrapAround) {
nextIdx = (nextIdx + total) % total
} else {
- if (nextIdx < 0) return FocusResult.Underflow
- if (nextIdx >= total) return FocusResult.Overflow
+ if (nextIdx < 0) {
+ return FocusResult.Underflow
+ }
+ if (nextIdx >= total) {
+ return FocusResult.Overflow
+ }
}
next = elements[nextIdx]
diff --git a/frontend/src/utils/metadata.ts b/frontend/src/utils/metadata.ts
index 70466eab1..acc9e869f 100644
--- a/frontend/src/utils/metadata.ts
+++ b/frontend/src/utils/metadata.ts
@@ -20,8 +20,9 @@ const getImageType = (
}
const getAudioType = (audio: AudioDetail, i18n: NuxtI18nInstance) => {
- if (!audio.alt_files)
+ if (!audio.alt_files) {
return audio.filetype ?? i18n.t("mediaDetails.information.unknown")
+ }
const altFormats = audio.alt_files
.map((altFile) => altFile.filetype)
.filter((filetype) => filetype !== audio.filetype)
diff --git a/frontend/src/utils/reakit-utils/dom.ts b/frontend/src/utils/reakit-utils/dom.ts
index 42adda214..790e3b195 100644
--- a/frontend/src/utils/reakit-utils/dom.ts
+++ b/frontend/src/utils/reakit-utils/dom.ts
@@ -67,6 +67,8 @@ export function isVisible(element: Element) {
export function isInDocument(target: Element) {
const document = getDocument(target)
- if (target.tagName === "HTML") return true
+ if (target.tagName === "HTML") {
+ return true
+ }
return contains(document.body, target)
}
diff --git a/frontend/src/utils/reakit-utils/focus.ts b/frontend/src/utils/reakit-utils/focus.ts
index c5a104f7a..2407d619f 100644
--- a/frontend/src/utils/reakit-utils/focus.ts
+++ b/frontend/src/utils/reakit-utils/focus.ts
@@ -124,10 +124,16 @@ export function getFirstTabbableIn(
*/
export function hasFocus(element: Element) {
const activeElement = getActiveElement(element)
- if (!activeElement) return false
- if (activeElement === element) return true
+ if (!activeElement) {
+ return false
+ }
+ if (activeElement === element) {
+ return true
+ }
const activeDescendant = activeElement.getAttribute("aria-activedescendant")
- if (!activeDescendant) return false
+ if (!activeDescendant) {
+ return false
+ }
return activeDescendant === element.id
}
@@ -139,12 +145,22 @@ export function hasFocus(element: Element) {
*/
export function hasFocusWithin(element: Node | Element) {
const activeElement = getActiveElement(element)
- if (!activeElement) return false
- if (contains(element, activeElement)) return true
+ if (!activeElement) {
+ return false
+ }
+ if (contains(element, activeElement)) {
+ return true
+ }
const activeDescendant = activeElement.getAttribute("aria-activedescendant")
- if (!activeDescendant) return false
- if (!("id" in element)) return false
- if (activeDescendant === element.id) return true
+ if (!activeDescendant) {
+ return false
+ }
+ if (!("id" in element)) {
+ return false
+ }
+ if (activeDescendant === element.id) {
+ return true
+ }
return !!element.querySelector(`#${CSS.escape(activeDescendant)}`)
}
@@ -173,11 +189,17 @@ export function ensureFocus(
const element = el as HTMLElement
// TODO: Try to use queueMicrotask before requestAnimationFrame and dispatch
// focus events if the element is not focusable?
- if (isActive(element)) return -1
+ if (isActive(element)) {
+ return -1
+ }
element.focus({ preventScroll })
- if (isActive(element)) return -1
+ if (isActive(element)) {
+ return -1
+ }
return requestAnimationFrame(() => {
- if (isActive(element)) return
+ if (isActive(element)) {
+ return
+ }
element.focus({ preventScroll })
})
}
diff --git a/frontend/src/utils/search-query-transform.ts b/frontend/src/utils/search-query-transform.ts
index fe8525843..58fdcf7b8 100644
--- a/frontend/src/utils/search-query-transform.ts
+++ b/frontend/src/utils/search-query-transform.ts
@@ -214,7 +214,9 @@ export const areQueriesEqual = (
) as (keyof PaginatedSearchQuery)[]
const oldQueryKeys = queryKeys(oldQuery)
const newQueryKeys = queryKeys(newQuery)
- if (oldQueryKeys.length !== newQueryKeys.length) return false
+ if (oldQueryKeys.length !== newQueryKeys.length) {
+ return false
+ }
for (const key of oldQueryKeys) {
if (oldQuery[key] !== newQuery[key]) {
diff --git a/frontend/src/utils/string-to-boolean.ts b/frontend/src/utils/string-to-boolean.ts
index d6f7e61a7..76bdd0ffa 100644
--- a/frontend/src/utils/string-to-boolean.ts
+++ b/frontend/src/utils/string-to-boolean.ts
@@ -12,21 +12,28 @@
export const stringToBoolean = (value: string | boolean): boolean => {
// In case the string is already a boolean, return as-is.
// If `.env` vars are auto-cast to booleans, this will catch that.
- if (typeof value === "boolean") return value
+ if (typeof value === "boolean") {
+ return value
+ }
- if (!value) return false
+ if (!value) {
+ return false
+ }
value = value.toLowerCase().trim()
switch (value) {
case "true":
case "yes":
- case "1":
+ case "1": {
return true
+ }
case "false":
case "no":
- case "0":
+ case "0": {
return false
- default:
+ }
+ default: {
return Boolean(value)
+ }
}
}
diff --git a/frontend/src/utils/translation-banner.ts b/frontend/src/utils/translation-banner.ts
index ae6272ac0..b297ce969 100644
--- a/frontend/src/utils/translation-banner.ts
+++ b/frontend/src/utils/translation-banner.ts
@@ -5,7 +5,9 @@ const BASE_URL = "https://translate.wordpress.org/projects/meta/openverse/"
const MINIMUM_TRANSLATION_PERCENTAGE = 90
export const needsTranslationBanner = (locale: LocaleObject) => {
- if (!locale || locale.code === "en") return false
+ if (!locale || locale.code === "en") {
+ return false
+ }
return (locale.translated ?? 100) <= MINIMUM_TRANSLATION_PERCENTAGE
}
diff --git a/frontend/test/playwright/e2e/recent-searches.spec.ts b/frontend/test/playwright/e2e/recent-searches.spec.ts
index 316f3fb11..e205f5013 100644
--- a/frontend/test/playwright/e2e/recent-searches.spec.ts
+++ b/frontend/test/playwright/e2e/recent-searches.spec.ts
@@ -12,7 +12,9 @@ test.beforeEach(async ({ page }) => {
const executeSearches = async (page: Page) => {
const searches = ["honey", "galah"] // in that order
- for (const term of searches) await searchFromHeader(page, term)
+ for (const term of searches) {
+ await searchFromHeader(page, term)
+ }
return searches
}
diff --git a/frontend/test/playwright/utils/breakpoints.ts b/frontend/test/playwright/utils/breakpoints.ts
index df9b22d11..fa3c6e41e 100644
--- a/frontend/test/playwright/utils/breakpoints.ts
+++ b/frontend/test/playwright/utils/breakpoints.ts
@@ -137,8 +137,9 @@ const describeEachBreakpoint =
breakpoints.includes(
bp.replace("describe", "").toLowerCase() as Breakpoint
)
- )
+ ) {
describe(blockOrOptions, block)
+ }
})
}
diff --git a/frontend/test/playwright/utils/navigation.ts b/frontend/test/playwright/utils/navigation.ts
index f430841ee..3c63402a1 100644
--- a/frontend/test/playwright/utils/navigation.ts
+++ b/frontend/test/playwright/utils/navigation.ts
@@ -141,7 +141,9 @@ export const setContentSwitcherState = async (
const shouldBePressed = state === "open"
if (isDesktop) {
- if (isPressed === shouldBePressed) return null
+ if (isPressed === shouldBePressed) {
+ return null
+ }
return await buttonLocator.click()
}
@@ -175,7 +177,9 @@ export const searchTypes = {
export const isPageDesktop = (page: Page) => {
const pageWidth = page.viewportSize()?.width
- if (!pageWidth) return false
+ if (!pageWidth) {
+ return false
+ }
const desktopMinWidth = 1024
return pageWidth >= desktopMinWidth
}
diff --git a/frontend/test/proxy.js b/frontend/test/proxy.js
index e0dfdd3ce..9beb48974 100644
--- a/frontend/test/proxy.js
+++ b/frontend/test/proxy.js
@@ -135,8 +135,9 @@ const getBodyUtil = (tape) =>
* @type {TalkbackOptions['tapeDecorator']}
*/
const tapeDecorator = (tape) => {
- if (!tape.res || tape.req.url.endsWith("/thumb/") || tape.res.status >= 399)
+ if (!tape.res || tape.req.url.endsWith("/thumb/") || tape.res.status >= 399) {
return tape
+ }
const bodyUtil = getBodyUtil(tape)
const responseBody = bodyUtil.read(tape.res.body).toString()
diff --git a/frontend/test/unit/specs/stores/feature-flag-store.spec.js b/frontend/test/unit/specs/stores/feature-flag-store.spec.js
index 8475b1acd..bffb87439 100644
--- a/frontend/test/unit/specs/stores/feature-flag-store.spec.js
+++ b/frontend/test/unit/specs/stores/feature-flag-store.spec.js
@@ -82,10 +82,11 @@ describe("Feature flag store", () => {
({ doCookieInit, featureState }) => {
const flagName = "feat_switchable_optout"
const featureFlagStore = useFeatureFlagStore()
- if (doCookieInit)
+ if (doCookieInit) {
featureFlagStore.initFromCookies({
feat_switchable_optout: OFF,
})
+ }
expect(featureFlagStore.featureState(flagName)).toEqual(featureState)
expect(featureFlagStore.isOn(flagName)).toEqual(featureState === "on")
}
diff --git a/frontend/test/unit/test-utils/api-service-mock.ts b/frontend/test/unit/test-utils/api-service-mock.ts
index 3f4d548ef..bd1d4fb39 100644
--- a/frontend/test/unit/test-utils/api-service-mock.ts
+++ b/frontend/test/unit/test-utils/api-service-mock.ts
@@ -67,7 +67,9 @@ export const mockCreateApiService = (
})
createApiService.mockImplementation((options) => {
// Only ever generate the mock once
- if (apiService) return apiService
+ if (apiService) {
+ return apiService
+ }
apiService = originalApiService.createApiService(
options
diff --git a/packages/eslint-plugin/src/configs/index.ts b/packages/eslint-plugin/src/configs/index.ts
index 13363b2e9..16c8458d7 100644
--- a/packages/eslint-plugin/src/configs/index.ts
+++ b/packages/eslint-plugin/src/configs/index.ts
@@ -33,6 +33,8 @@ export const project: TSESLint.Linter.Config = {
semi: ["error", "never"],
"no-console": "off",
"unicorn/filename-case": ["error", { case: "kebabCase" }],
+ "unicorn/switch-case-braces": ["error"],
+ curly: ["error", "all"],
},
overrides: [
{
diff --git a/packages/eslint-plugin/src/rules/analytics-configuration.ts b/packages/eslint-plugin/src/rules/analytics-configuration.ts
index 0df9629af..d15d93c3e 100644
--- a/packages/eslint-plugin/src/rules/analytics-configuration.ts
+++ b/packages/eslint-plugin/src/rules/analytics-configuration.ts
@@ -164,7 +164,9 @@ export const analyticsConfiguration = OpenverseRule<Options, MessageIds>({
})
}
- if (!customEventNode.typeAnnotation) return
+ if (!customEventNode.typeAnnotation) {
+ return
+ }
if (isTypeAnnotationEmpty(customEventNode)) {
context.report({
@@ -202,15 +204,20 @@ export const analyticsConfiguration = OpenverseRule<Options, MessageIds>({
const isAnalyticsFile = context
.getFilename()
.endsWith("types/analytics.ts")
- if (!isAnalyticsFile) return
+ if (!isAnalyticsFile) {
+ return
+ }
if (
node.parent?.type !== "TSTypeAliasDeclaration" ||
node.parent?.typeAnnotation.type !== "TSTypeLiteral"
- )
+ ) {
return
+ }
node.parent.typeAnnotation.members.forEach((m) => {
- if (m.type === "TSPropertySignature") validateCustomEvent(m)
+ if (m.type === "TSPropertySignature") {
+ validateCustomEvent(m)
+ }
})
},
}