Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Sync pre-commit deps with package.json (#2546)
Olga Bulat6e1df6a6fb15
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex b21925a65..ad85790fa 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -89,9 +89,9 @@ repos:hooks:- id: prettieradditional_dependencies:- repo: https://github.com/koalaman/shellcheck-precommitrev: v0.9.0diff --git a/documentation/projects/proposals/visual_regression_testing/20220217-implementation_plan.md b/documentation/projects/proposals/visual_regression_testing/20220217-implementation_plan.mdindex 80299db47..dedf585a0 100644--- a/documentation/projects/proposals/visual_regression_testing/20220217-implementation_plan.md+++ b/documentation/projects/proposals/visual_regression_testing/20220217-implementation_plan.md@@ -316,15 +316,12 @@ export const testEachBreakpoint = () => Promise<void>) => {SCREEN_SIZES.forEach((screenWidth, breakpoint) => {- test.describe(- `screen at breakpoint ${breakpoint} with width ${screenWidth}`,- () => {- test(title, async ({ page, context, request }, testInfo) => {- await page.setViewportSize({ width: screenWidth, height: 700 })- await testCb(breakpoint, { page, context, request }, testInfo)- })- }- )+ test.describe(`screen at breakpoint ${breakpoint} with width ${screenWidth}`, () => {+ test(title, async ({ page, context, request }, testInfo) => {+ await page.setViewportSize({ width: screenWidth, height: 700 })+ await testCb(breakpoint, { page, context, request }, testInfo)+ })+ })})}```diff --git a/frontend/src/components/VButton.vue b/frontend/src/components/VButton.vueindex 0b063bfa2..e8a2abc05 100644--- a/frontend/src/components/VButton.vue+++ b/frontend/src/components/VButton.vue@@ -54,7 +54,7 @@ import type { ButtonForm } from "~/types/button"import VLink from "~/components/VLink.vue"export type ButtonProps = ProperlyExtractPropTypes<- NonNullable<typeof VButton["props"]>+ NonNullable<(typeof VButton)["props"]>>/**diff --git a/frontend/src/components/VHeader/VPageLinks.vue b/frontend/src/components/VHeader/VPageLinks.vueindex 25380d285..1a4ba5f25 100644--- a/frontend/src/components/VHeader/VPageLinks.vue+++ b/frontend/src/components/VHeader/VPageLinks.vue@@ -104,7 +104,7 @@ export default defineComponent({// so we need to close it manually.const onClick = () => emit("close")- const isLinkExternal = (item: typeof allPages[number]) =>+ const isLinkExternal = (item: (typeof allPages)[number]) =>!item.link.startsWith("/")const externalIconSize = computed(() => (props.isInModal ? 6 : 4))diff --git a/frontend/src/components/VHomeGallery/VHomeGallery.vue b/frontend/src/components/VHomeGallery/VHomeGallery.vueindex 871a2bd31..0cd4e706a 100644--- a/frontend/src/components/VHomeGallery/VHomeGallery.vue+++ b/frontend/src/components/VHomeGallery/VHomeGallery.vue@@ -63,7 +63,7 @@ export const GALLERY_SETS = ["olympics","random",] as const-export type GallerySet = typeof GALLERY_SETS[number]+export type GallerySet = (typeof GALLERY_SETS)[number]/*** Displays a grid of images for the homepage, with each image linking to itsdiff --git a/frontend/src/components/VSelectField/VSelectField.vue b/frontend/src/components/VSelectField/VSelectField.vueindex 345c5e380..bdaf64a3e 100644--- a/frontend/src/components/VSelectField/VSelectField.vue+++ b/frontend/src/components/VSelectField/VSelectField.vue@@ -45,7 +45,7 @@ export interface Choice {}export type SelectFieldProps = ProperlyExtractPropTypes<- NonNullable<typeof VSelectField["props"]>+ NonNullable<(typeof VSelectField)["props"]>>/**diff --git a/frontend/src/components/VTabs/VTabs.vue b/frontend/src/components/VTabs/VTabs.vueindex 2559a7909..d40ced2f9 100644--- a/frontend/src/components/VTabs/VTabs.vue+++ b/frontend/src/components/VTabs/VTabs.vue@@ -101,17 +101,17 @@ export default defineComponent({selectedId.value = idemit("change", id)},- registerTab(tab: typeof tabs["value"][number]) {+ registerTab(tab: (typeof tabs)["value"][number]) {if (!tabs.value.includes(tab)) tabs.value.push(tab)},- unregisterTab(tab: typeof tabs["value"][number]) {+ unregisterTab(tab: (typeof tabs)["value"][number]) {let idx = tabs.value.indexOf(tab)if (idx !== -1) tabs.value.splice(idx, 1)},- registerPanel(panel: typeof panels["value"][number]) {+ registerPanel(panel: (typeof panels)["value"][number]) {if (!panels.value.includes(panel)) panels.value.push(panel)},- unregisterPanel(panel: typeof panels["value"][number]) {+ unregisterPanel(panel: (typeof panels)["value"][number]) {let idx = panels.value.indexOf(panel)if (idx !== -1) panels.value.splice(idx, 1)},diff --git a/frontend/src/constants/audio.ts b/frontend/src/constants/audio.tsindex 7fcb13a8b..a12b44c49 100644--- a/frontend/src/constants/audio.ts+++ b/frontend/src/constants/audio.ts@@ -1,4 +1,4 @@-export type AudioLayout = typeof audioLayouts[number]+export type AudioLayout = (typeof audioLayouts)[number]export const audioLayouts = Object.freeze(["full","box",@@ -6,10 +6,10 @@ export const audioLayouts = Object.freeze(["global",] as const)-export type AudioSize = typeof audioSizes[number]+export type AudioSize = (typeof audioSizes)[number]export const audioSizes = Object.freeze(["s", "m", "l"] as const)-export type AudioStatus = typeof audioStatuses[number]+export type AudioStatus = (typeof audioStatuses)[number]export const audioStatuses = Object.freeze(["playing","paused",@@ -17,7 +17,7 @@ export const audioStatuses = Object.freeze(["loading",] as const)-export type AudioFeature = typeof audioFeatures[number]+export type AudioFeature = (typeof audioFeatures)[number]export const audioFeatures = Object.freeze(["timestamps","duration",@@ -48,4 +48,4 @@ export const statusVerbMap = Object.freeze({} as const)export const audioStatusVerbs = Object.values(statusVerbMap)-export type AudioStatusVerb = typeof audioStatusVerbs[number]+export type AudioStatusVerb = (typeof audioStatusVerbs)[number]diff --git a/frontend/src/constants/content-report.ts b/frontend/src/constants/content-report.tsindex 3d9efdf25..602445b78 100644--- a/frontend/src/constants/content-report.ts+++ b/frontend/src/constants/content-report.ts@@ -4,7 +4,7 @@ export const OTHER = "other"export const reasons = [DMCA, MATURE, OTHER] as const-export type ReportReason = typeof reasons[number]+export type ReportReason = (typeof reasons)[number]export const SENT = "sent"export const FAILED = "failed"@@ -12,7 +12,7 @@ export const WIP = "wip"export const statuses = [SENT, FAILED, WIP] as const-export type ReportStatus = typeof statuses[number]+export type ReportStatus = (typeof statuses)[number]export const DMCA_FORM_URL ="https://docs.google.com/forms/d/e/1FAIpQLSd0I8GsEbGQLdaX4K_F6V2NbHZqN137WMZgnptUpzwd-kbDKA/viewform"diff --git a/frontend/src/constants/deploy-env.ts b/frontend/src/constants/deploy-env.tsindex 3b52c0a21..f71d7482f 100644--- a/frontend/src/constants/deploy-env.ts+++ b/frontend/src/constants/deploy-env.ts@@ -7,4 +7,4 @@ export const PRODUCTION = "production"// increasing order of code-readiness, from local to production.export const DEPLOY_ENVS = [LOCAL, DEVELOPMENT, STAGING, PRODUCTION] as const-export type DeployEnv = typeof DEPLOY_ENVS[number]+export type DeployEnv = (typeof DEPLOY_ENVS)[number]diff --git a/frontend/src/constants/errors.ts b/frontend/src/constants/errors.tsindex 766c9c41e..9b48069ac 100644--- a/frontend/src/constants/errors.ts+++ b/frontend/src/constants/errors.ts@@ -8,4 +8,4 @@ export const SERVER_TIMEOUT = "SERVER_TIMEOUT"export const errorCodes = [NO_RESULT, SERVER_TIMEOUT] as const-export type ErrorCode = typeof errorCodes[number]+export type ErrorCode = (typeof errorCodes)[number]diff --git a/frontend/src/constants/feature-flag.ts b/frontend/src/constants/feature-flag.tsindex aca99ada9..5ddb96567 100644--- a/frontend/src/constants/feature-flag.ts+++ b/frontend/src/constants/feature-flag.ts@@ -4,18 +4,18 @@ export const SWITCHABLE = "switchable"export const FLAG_STATUSES = [ENABLED, DISABLED, SWITCHABLE] as const-export type FlagStatus = typeof FLAG_STATUSES[number]+export type FlagStatus = (typeof FLAG_STATUSES)[number]export const ON = "on"export const OFF = "off"export const FEATURE_STATES = [ON, OFF] as const-export type FeatureState = typeof FEATURE_STATES[number]+export type FeatureState = (typeof FEATURE_STATES)[number]export const SESSION = "session"export const COOKIE = "cookie"export const STORAGES = [SESSION, COOKIE] as const-export type Storage = typeof STORAGES[number]+export type Storage = (typeof STORAGES)[number]diff --git a/frontend/src/constants/license.ts b/frontend/src/constants/license.tsindex 97e42bcb0..8341d52f5 100644--- a/frontend/src/constants/license.ts+++ b/frontend/src/constants/license.ts@@ -18,11 +18,11 @@ export const ALL_LICENSES = [...DEPRECATED_CC_LICENSES,] as const-export type License = typeof ALL_LICENSES[number]+export type License = (typeof ALL_LICENSES)[number]export const LICENSE_VERSIONS = ["", "1.0", "2.0", "2.5", "3.0", "4.0"] as const-export type LicenseVersion = typeof LICENSE_VERSIONS[number]+export type LicenseVersion = (typeof LICENSE_VERSIONS)[number]/*** Each element of this array can be constructed into an SVG in Creative Commons'@@ -45,4 +45,4 @@ export const LICENSE_ICONS = ["share",] as const-export type LicenseElement = typeof LICENSE_ICONS[number]+export type LicenseElement = (typeof LICENSE_ICONS)[number]diff --git a/frontend/src/constants/media.ts b/frontend/src/constants/media.tsindex da2d9f711..d974f1042 100644--- a/frontend/src/constants/media.ts+++ b/frontend/src/constants/media.ts@@ -11,7 +11,7 @@ export const ALL_MEDIA = "all"*/export const mediaTypes = [IMAGE, AUDIO, VIDEO, MODEL_3D] as const-export type MediaType = typeof mediaTypes[number]+export type MediaType = (typeof mediaTypes)[number]/*** real media types that the API supports;@@ -21,11 +21,11 @@ export type MediaType = typeof mediaTypes[number]*/export const supportedMediaTypes = [IMAGE, AUDIO] as const-export type SupportedMediaType = typeof supportedMediaTypes[number]+export type SupportedMediaType = (typeof supportedMediaTypes)[number]export const searchTypes = [ALL_MEDIA, ...mediaTypes] as const-export type SearchType = typeof searchTypes[number]+export type SearchType = (typeof searchTypes)[number]/*** the types of content that users can search; `ALL_MEDIA` is also a valid@@ -33,7 +33,7 @@ export type SearchType = typeof searchTypes[number]*/export const supportedSearchTypes = [ALL_MEDIA, ...supportedMediaTypes] as const-export type SupportedSearchType = typeof supportedSearchTypes[number]+export type SupportedSearchType = (typeof supportedSearchTypes)[number]export type AdditionalSearchType = Exclude<SearchType, SupportedSearchType>diff --git a/frontend/src/data/api-service.ts b/frontend/src/data/api-service.tsindex 8752b585b..88d6c449e 100644--- a/frontend/src/data/api-service.ts+++ b/frontend/src/data/api-service.ts@@ -158,7 +158,7 @@ export const createApiService = ({*/post<T = unknown>(resource: string,- data: Parameters<typeof client["post"]>[1]+ data: Parameters<(typeof client)["post"]>[1]): Promise<AxiosResponse<T>> {return client.post(getResourceSlug(resource), data)},@@ -173,7 +173,7 @@ export const createApiService = ({update<T = unknown>(resource: string,slug: string,- data: Parameters<typeof client["put"]>[1],+ data: Parameters<(typeof client)["put"]>[1],headers: AxiosRequestConfig["headers"]): Promise<AxiosResponse<T>> {return client.put(`${getResourceSlug(resource)}${slug}`, data, {diff --git a/frontend/src/stores/feature-flag.ts b/frontend/src/stores/feature-flag.tsindex 59eb8f94a..1a2f1f664 100644--- a/frontend/src/stores/feature-flag.ts+++ b/frontend/src/stores/feature-flag.ts@@ -24,7 +24,7 @@ import type { Context } from "@nuxt/types"import type { Dictionary } from "vue-router/types/router"-type FlagName = keyof typeof featureData["features"]+type FlagName = keyof (typeof featureData)["features"]export interface FeatureFlagState {flags: Record<FlagName, FeatureFlag>}diff --git a/frontend/src/types/button.ts b/frontend/src/types/button.tsindex 351e9c34b..e44e1d8af 100644--- a/frontend/src/types/button.ts+++ b/frontend/src/types/button.ts@@ -1,6 +1,6 @@export const buttonForms = ["VLink", "button"] as const-export type ButtonForm = typeof buttonForms[number]+export type ButtonForm = (typeof buttonForms)[number]export const buttonVariants = ["plain",@@ -18,13 +18,13 @@ export const buttonVariants = ["transparent-gray","transparent-dark",] as const-export type ButtonVariant = typeof buttonVariants[number]+export type ButtonVariant = (typeof buttonVariants)[number]export const buttonSizes = ["large", "medium", "small", "disabled"] as const-export type ButtonSize = typeof buttonSizes[number]+export type ButtonSize = (typeof buttonSizes)[number]export const buttonTypes = ["button", "submit", "reset"] as const-export type ButtonType = typeof buttonTypes[number]+export type ButtonType = (typeof buttonTypes)[number]export const buttonConnections = ["start", "end", "none", "all"] as const-export type ButtonConnections = typeof buttonConnections[number]+export type ButtonConnections = (typeof buttonConnections)[number]diff --git a/frontend/src/types/item-group.ts b/frontend/src/types/item-group.tsindex 11434010e..6aaaee3fe 100644--- a/frontend/src/types/item-group.ts+++ b/frontend/src/types/item-group.ts@@ -5,13 +5,13 @@ export const itemGroupDirections = ["horizontal","columns",] as const-export type ItemGroupDirection = typeof itemGroupDirections[number]+export type ItemGroupDirection = (typeof itemGroupDirections)[number]export const itemGroupTypes = ["list", "menu", "radiogroup"] as const-export type ItemGroupType = typeof itemGroupTypes[number]+export type ItemGroupType = (typeof itemGroupTypes)[number]export const itemGroupSizes = ["small", "medium"] as const-export type ItemGroupSize = typeof itemGroupSizes[number]+export type ItemGroupSize = (typeof itemGroupSizes)[number]export type VIemGroupContext = {direction: ItemGroupDirectiondiff --git a/frontend/test/playwright/e2e/search-types.spec.ts b/frontend/test/playwright/e2e/search-types.spec.tsindex c31be9de6..b7ce7907e 100644--- a/frontend/test/playwright/e2e/search-types.spec.ts+++ b/frontend/test/playwright/e2e/search-types.spec.ts@@ -52,7 +52,7 @@ const audioConfig = {const searchTypes = [allContentConfig, imageConfig, audioConfig] as const-type SearchTypeConfig = typeof searchTypes[number]+type SearchTypeConfig = (typeof searchTypes)[number]async function checkLoadMore(page: Page, searchType: SearchTypeConfig) {const loadMoreSection = page.locator('[data-testid="load-more"]')diff --git a/frontend/test/playwright/utils/breakpoints.ts b/frontend/test/playwright/utils/breakpoints.tsindex 04291eb38..ac2575511 100644--- a/frontend/test/playwright/utils/breakpoints.ts+++ b/frontend/test/playwright/utils/breakpoints.ts@@ -28,7 +28,7 @@ export const mobileBreakpoints = ["md", "sm", "xs"] as constexport const isMobileBreakpoint = (bp: Breakpoint-): bp is typeof mobileBreakpoints[number] =>+): bp is (typeof mobileBreakpoints)[number] =>(mobileBreakpoints as unknown as string[]).includes(bp)// For desktop UA use the default@@ -63,44 +63,41 @@ const makeBreakpointDescribe =blockOrOptions: T,block?: T extends Record<string, unknown> ? BreakpointBlock : undefined) => {- test.describe(- `screen at breakpoint ${breakpoint} with width ${screenWidth}`,- () => {- const _block = (- typeof blockOrOptions === "function" ? blockOrOptions : block- ) as BreakpointBlock- const options =- typeof blockOrOptions !== "function"- ? { ...defaultOptions, ...blockOrOptions }- : defaultOptions-- test.use({- viewport: { width: screenWidth, height: 700 },- userAgent: options.uaMocking ? mockUaStrings[breakpoint] : undefined,- })-- const getConfigValues = (name: string) => ({- name: `${name}-${breakpoint}.png` as const,- })-- const expectSnapshot = async <T extends ScreenshotAble>(- name: string,- screenshotAble: T,- options?: Parameters<T["screenshot"]>[0],- snapshotOptions?: Parameters<ReturnType<Expect>["toMatchSnapshot"]>[0]- ) => {- const { name: snapshotName } = getConfigValues(name)- return expect(- await screenshotAble.screenshot(options)- ).toMatchSnapshot({+ test.describe(`screen at breakpoint ${breakpoint} with width ${screenWidth}`, () => {+ const _block = (+ typeof blockOrOptions === "function" ? blockOrOptions : block+ ) as BreakpointBlock+ const options =+ typeof blockOrOptions !== "function"+ ? { ...defaultOptions, ...blockOrOptions }+ : defaultOptions++ test.use({+ viewport: { width: screenWidth, height: 700 },+ userAgent: options.uaMocking ? mockUaStrings[breakpoint] : undefined,+ })++ const getConfigValues = (name: string) => ({+ name: `${name}-${breakpoint}.png` as const,+ })++ const expectSnapshot = async <T extends ScreenshotAble>(+ name: string,+ screenshotAble: T,+ options?: Parameters<T["screenshot"]>[0],+ snapshotOptions?: Parameters<ReturnType<Expect>["toMatchSnapshot"]>[0]+ ) => {+ const { name: snapshotName } = getConfigValues(name)+ return expect(await screenshotAble.screenshot(options)).toMatchSnapshot(+ {name: snapshotName,...snapshotOptions,- })- }-- _block({ breakpoint, getConfigValues, expectSnapshot })+ }+ )}- )++ _block({ breakpoint, getConfigValues, expectSnapshot })+ })}const capitalize = (s: string): Capitalize<typeof s> =>diff --git a/frontend/test/playwright/utils/navigation.ts b/frontend/test/playwright/utils/navigation.tsindex 16ef85549..823eaadf3 100644--- a/frontend/test/playwright/utils/navigation.ts+++ b/frontend/test/playwright/utils/navigation.ts@@ -62,8 +62,8 @@ export const renderingContexts = [] as constexport const renderModes = ["SSR", "CSR"] as const-export type RenderMode = typeof renderModes[number]-export type LanguageDirection = typeof languageDirections[number]+export type RenderMode = (typeof renderModes)[number]+export type LanguageDirection = (typeof languageDirections)[number]export function sleep(ms: number) {return new Promise<void>((resolve) => setTimeout(resolve, ms))diff --git a/frontend/test/storybook/visual-regression/v-footer.spec.ts b/frontend/test/storybook/visual-regression/v-footer.spec.tsindex 1ef9eed95..5cc38b864 100644--- a/frontend/test/storybook/visual-regression/v-footer.spec.ts+++ b/frontend/test/storybook/visual-regression/v-footer.spec.ts@@ -8,8 +8,8 @@ const footerKinds = ["internal", "content"] as constconst defaultUrl = "/iframe.html?id=components-vfooter--"const pageUrl = (- dir: typeof languageDirections[number],- footerKind: typeof footerKinds[number]+ dir: (typeof languageDirections)[number],+ footerKind: (typeof footerKinds)[number]) => {const url = `${defaultUrl}${footerKind}`return dir === "ltr" ? url : `${url}&globals=languageDirection:rtl`diff --git a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts b/frontend/test/storybook/visual-regression/v-header-internal.spec.tsindex aebcfccf7..e42485806 100644--- a/frontend/test/storybook/visual-regression/v-header-internal.spec.ts+++ b/frontend/test/storybook/visual-regression/v-header-internal.spec.ts@@ -6,7 +6,7 @@ import { languageDirections } from "~~/test/playwright/utils/navigation"const headerSelector = ".main-header"const defaultUrl ="/iframe.html?id=components-vheader-vheaderinternal--default-story"-const pageUrl = (dir: typeof languageDirections[number]) =>+const pageUrl = (dir: (typeof languageDirections)[number]) =>dir === "ltr" ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`test.describe.configure({ mode: "parallel" })diff --git a/frontend/test/storybook/visual-regression/v-media-reuse.spec.ts b/frontend/test/storybook/visual-regression/v-media-reuse.spec.tsindex 0cfe6b3e6..eb9dd7f80 100644--- a/frontend/test/storybook/visual-regression/v-media-reuse.spec.ts+++ b/frontend/test/storybook/visual-regression/v-media-reuse.spec.ts@@ -12,7 +12,7 @@ const tabs = []const defaultUrl ="/iframe.html?id=components-vmediainfo-vmediareuse--v-media-reuse"-const pageUrl = (dir: typeof languageDirections[number]) =>+const pageUrl = (dir: (typeof languageDirections)[number]) =>dir === "ltr" ? defaultUrl : `${defaultUrl}&globals=languageDirection:rtl`test.describe("media-reuse", () => {diff --git a/frontend/test/storybook/visual-regression/v-notitication-banner.spec.ts b/frontend/test/storybook/visual-regression/v-notitication-banner.spec.tsindex 641fc7c30..6b93db73e 100644--- a/frontend/test/storybook/visual-regression/v-notitication-banner.spec.ts+++ b/frontend/test/storybook/visual-regression/v-notitication-banner.spec.ts@@ -11,8 +11,8 @@ const defaultUrl ="/iframe.html?id=components-vnotificationbanner--default-story"const pageUrl = (- nature: typeof natures[number],- variant: typeof variants[number]+ nature: (typeof natures)[number],+ variant: (typeof variants)[number]) => {const url = `${defaultUrl}&args=nature:${nature};variant:${variant}`return url