diff --git a/eslint.config.mjs b/eslint.config.mjs index d0ca5c876..fc9a22f49 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -19,7 +19,6 @@ export default createConfigForNuxt({ '.nuxt', 'dist', 'playground', - 'specs', 'test', 'coverage', 'docs', @@ -35,6 +34,12 @@ export default createConfigForNuxt({ }, }, ) + .override('nuxt/tooling/unicorn', { + rules: { + 'unicorn/no-new-array': 'off', + 'unicorn/prefer-dom-node-text-content': 'off', + }, + }) .append( { rules: { @@ -76,6 +81,16 @@ export default createConfigForNuxt({ { rules: { '@typescript-eslint/ban-ts-comment': 'off' }, }, + { + files: ['**/fixtures/**', '**/fixture/**', '**/*-fixture/**'], + name: 'local/disables/fixtures', + rules: { + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/triple-slash-reference': 'off', + 'vue/multi-word-component-names': 'off', + 'vue/valid-v-for': 'off', + }, + }, ) // Generate type definitions for the eslint config diff --git a/specs/basic_usage.spec.ts b/specs/basic_usage.spec.ts index ce76c694f..f8e182fdb 100644 --- a/specs/basic_usage.spec.ts +++ b/specs/basic_usage.spec.ts @@ -1,7 +1,6 @@ -import { beforeAll, describe } from 'vitest' +import { beforeAll, describe, test, expect } from 'vitest' import { fileURLToPath } from 'node:url' import { setTestContext, setup, $fetch, url, useTestContext } from './utils' -import { test, expect } from 'vitest' import { assertLocaleHeadWithDom, assetLocaleHead, @@ -12,7 +11,7 @@ import { setServerRuntimeConfig, startServerWithRuntimeConfig, waitForLocaleNetwork, - waitForTransition + waitForTransition, } from './helper' import type { RouteLocation } from 'vue-router' @@ -27,14 +26,14 @@ describe('basic usage', async () => { i18n: { baseUrl: 'http://localhost:3000', skipSettingLocaleOnNavigate: undefined, - detectBrowserLanguage: undefined - } - } - } - } + detectBrowserLanguage: undefined, + }, + }, + }, + }, }) - let ctx + let ctx: ReturnType describe('general usage', async () => { test('basic usage', async () => { const { page } = await renderPage('/') @@ -49,7 +48,7 @@ describe('basic usage', async () => { expect(await page.locator('#locale-path-usages .nest-path a').getAttribute('href')).toEqual('/user/profile') expect(await page.locator('#locale-path-usages .nest-named a').getAttribute('href')).toEqual('/user/profile') expect(await page.locator('#locale-path-usages .object-with-named a').getAttribute('href')).toEqual( - '/category/nintendo' + '/category/nintendo', ) // URL path localizing with `NuxtLinkLocale` @@ -59,13 +58,13 @@ describe('basic usage', async () => { expect(await page.locator('#nuxt-link-locale-usages .nest-path a').getAttribute('href')).toEqual('/user/profile') expect(await page.locator('#nuxt-link-locale-usages .nest-named a').getAttribute('href')).toEqual('/user/profile') expect(await page.locator('#nuxt-link-locale-usages .object-with-named a').getAttribute('href')).toEqual( - '/category/nintendo' + '/category/nintendo', ) expect(await page.locator('#nuxt-link-locale-usages .external-url a').getAttribute('href')).toEqual( - 'https://nuxt.com/' + 'https://nuxt.com/', ) expect(await page.locator('#nuxt-link-locale-usages .target-blank-with-locale a').getAttribute('href')).toEqual( - '/fr/about' + '/fr/about', ) expect(await page.evaluate(() => history.state.hello)).toEqual(undefined) @@ -109,7 +108,7 @@ describe('basic usage', async () => { const pageDOMFrench = await getDom(pageHTMLFrench) expect(await pageDOMFrench.locator('#t-directive #t-directive-path')?.textContent()).toEqual('Bienvenue') expect(await pageDOMFrench.locator('#t-directive #t-directive-argument')?.textContent()).toEqual( - 'Bonjour directive!' + 'Bonjour directive!', ) }) @@ -124,7 +123,7 @@ describe('basic usage', async () => { const localeRoute = JSON.parse(await page.locator('#locale-route').innerText()) as RouteLocation // remove properties that vary based on test environment and vue-router version // we only need to know if the correct route (object) is returned - localeRoute.matched = localeRoute.matched.map(x => { + localeRoute.matched = localeRoute.matched.map((x) => { for (const component in x.components) { x.components[component] = {} } @@ -162,11 +161,11 @@ describe('basic usage', async () => { "path": "/nuxt-context-extension", "query": {}, } - ` + `, ) expect(await page.locator('#locale-head').innerText()).toMatchInlineSnapshot( - `"{ "htmlAttrs": { "lang": "en" }, "link": [ { "id": "i18n-xd", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "x-default" }, { "id": "i18n-alt-en", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "en" }, { "id": "i18n-alt-fr", "rel": "alternate", "href": "http://localhost:3000/fr/nuxt-context-extension", "hreflang": "fr" }, { "id": "i18n-alt-ja", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja" }, { "id": "i18n-alt-ja-JP", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "id": "i18n-alt-nl", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl" }, { "id": "i18n-alt-nl-NL", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "id": "i18n-alt-nl-BE", "rel": "alternate", "href": "http://localhost:3000/be/nuxt-context-extension", "hreflang": "nl-BE" }, { "id": "i18n-alt-kr", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr" }, { "id": "i18n-alt-kr-KO", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "id": "i18n-can", "rel": "canonical", "href": "http://localhost:3000/nuxt-context-extension" } ], "meta": [ { "id": "i18n-og-url", "property": "og:url", "content": "http://localhost:3000/nuxt-context-extension" }, { "id": "i18n-og", "property": "og:locale", "content": "en" }, { "id": "i18n-og-alt-fr", "property": "og:locale:alternate", "content": "fr" }, { "id": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "id": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "id": "i18n-og-alt-nl-BE", "property": "og:locale:alternate", "content": "nl_BE" }, { "id": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"` + `"{ "htmlAttrs": { "lang": "en" }, "link": [ { "id": "i18n-xd", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "x-default" }, { "id": "i18n-alt-en", "rel": "alternate", "href": "http://localhost:3000/nuxt-context-extension", "hreflang": "en" }, { "id": "i18n-alt-fr", "rel": "alternate", "href": "http://localhost:3000/fr/nuxt-context-extension", "hreflang": "fr" }, { "id": "i18n-alt-ja", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja" }, { "id": "i18n-alt-ja-JP", "rel": "alternate", "href": "http://localhost:3000/ja/nuxt-context-extension", "hreflang": "ja-JP" }, { "id": "i18n-alt-nl", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl" }, { "id": "i18n-alt-nl-NL", "rel": "alternate", "href": "http://localhost:3000/nl/nuxt-context-extension", "hreflang": "nl-NL" }, { "id": "i18n-alt-nl-BE", "rel": "alternate", "href": "http://localhost:3000/be/nuxt-context-extension", "hreflang": "nl-BE" }, { "id": "i18n-alt-kr", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr" }, { "id": "i18n-alt-kr-KO", "rel": "alternate", "href": "http://localhost:3000/kr/nuxt-context-extension", "hreflang": "kr-KO" }, { "id": "i18n-can", "rel": "canonical", "href": "http://localhost:3000/nuxt-context-extension" } ], "meta": [ { "id": "i18n-og-url", "property": "og:url", "content": "http://localhost:3000/nuxt-context-extension" }, { "id": "i18n-og", "property": "og:locale", "content": "en" }, { "id": "i18n-og-alt-fr", "property": "og:locale:alternate", "content": "fr" }, { "id": "i18n-og-alt-ja-JP", "property": "og:locale:alternate", "content": "ja_JP" }, { "id": "i18n-og-alt-nl-NL", "property": "og:locale:alternate", "content": "nl_NL" }, { "id": "i18n-og-alt-nl-BE", "property": "og:locale:alternate", "content": "nl_BE" }, { "id": "i18n-og-alt-kr-KO", "property": "og:locale:alternate", "content": "kr_KO" } ] }"`, ) }) @@ -180,7 +179,7 @@ describe('basic usage', async () => { await page.waitForURL(url('/fr')) expect(await page.locator('#register-module').innerText()).toEqual( - 'This is a merged module layer locale key in French' + 'This is a merged module layer locale key in French', ) }) @@ -191,7 +190,7 @@ describe('basic usage', async () => { const restore = await startServerWithRuntimeConfig( { public: { runtimeValue: 'The environment variable has changed!' } }, - true + true, ) await gotoPath(page, '/') @@ -205,14 +204,14 @@ describe('basic usage', async () => { expect(await page.locator('#i18n-layer-target').innerText()).toEqual('Hello world!') expect(await page.locator('#i18n-layer-parent-link').getAttribute('href')).toEqual('/layer-parent') expect(await page.locator('#i18n-layer-parent-child-link').getAttribute('href')).toEqual( - '/layer-parent/layer-child' + '/layer-parent/layer-child', ) await gotoPath(page, '/nl/layer-page') expect(await page.locator('#i18n-layer-target').innerText()).toEqual('Hallo wereld!') expect(await page.locator('#i18n-layer-parent-link').getAttribute('href')).toEqual('/nl/layer-ouder') expect(await page.locator('#i18n-layer-parent-child-link').getAttribute('href')).toEqual( - '/nl/layer-ouder/layer-kind' + '/nl/layer-ouder/layer-kind', ) }) @@ -230,7 +229,7 @@ describe('basic usage', async () => { await Promise.all([ waitForLocaleNetwork(page, 'fr', 'response'), - page.click(`#switch-locale-path-usages .switch-to-fr a`) + page.click(`#switch-locale-path-usages .switch-to-fr a`), ]) await page.waitForTimeout(100) @@ -279,7 +278,7 @@ describe('basic usage', async () => { // page path expect(JSON.parse(await page.locator('#home-use-async-data').innerText())).toMatchObject({ - aboutPath: '/nl/about' + aboutPath: '/nl/about', }) // current locale @@ -304,7 +303,7 @@ describe('basic usage', async () => { expect(await page.locator('#link-about-query-hash').getAttribute('href')).toEqual('/nl/about?foo=bar#my-hash') expect(await page.locator('#link-about-query-hash-object').getAttribute('href')).toEqual( - '/nl/about?foo=bar#my-hash' + '/nl/about?foo=bar#my-hash', ) }) @@ -328,7 +327,7 @@ describe('basic usage', async () => { expect(await page.locator('#module-layer-base-key').innerText()).toEqual('Layer base key overwritten!') expect(await page.locator('#module-layer-base-key-named').innerText()).toEqual( - 'Layer base key overwritten, greetings bar!' + 'Layer base key overwritten, greetings bar!', ) }) @@ -356,11 +355,11 @@ describe('basic usage', async () => { }) test('setLocale triggers runtime hooks', async () => { - let output: string[] = [] + const output: string[] = [] const ctx = useTestContext() ctx.serverProcess?.process?.on( 'message', - (msg: any) => msg.type === 'i18n:test-log' && msg.id === ctx.url?.split(':')[2]! && output.push(msg.data) + (msg: { type: string, id: string, data: string }) => msg.type === 'i18n:test-log' && msg.id === ctx.url?.split(':')[2] && output.push(msg.data), ) output.length = 0 await new Promise(resolve => setTimeout(resolve, 1)) // wait for process to be ready @@ -444,9 +443,9 @@ describe('basic usage', async () => { await setServerRuntimeConfig({ public: { i18n: { - baseUrl: configDomain - } - } + baseUrl: configDomain, + }, + }, }) const html = await $fetch('/?noncanonical&canonical') @@ -454,10 +453,10 @@ describe('basic usage', async () => { await assertLocaleHeadWithDom(dom, '#home-use-locale-head') const links = (await getDataFromDom(dom, '#home-use-locale-head')).link - const i18nCan = links.find(x => x.id === 'i18n-can') + const i18nCan = links.find((x: { id: string, href: string }) => x.id === 'i18n-can') expect(i18nCan.href).toContain(configDomain) expect(await dom.locator('#i18n-alt-fr')?.getAttribute('href')).toEqual( - 'https://runtime-config-domain.com/fr?canonical=' + 'https://runtime-config-domain.com/fr?canonical=', ) }) @@ -466,7 +465,7 @@ describe('basic usage', async () => { const html = await $fetch('/?noncanonical&canonical') const dom = await getDom(html) expect(await dom.locator('link[id=i18n-alt-fr]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/fr?canonical=' + 'http://localhost:3000/fr?canonical=', ) }) @@ -475,19 +474,19 @@ describe('basic usage', async () => { const product1Html = await $fetch('/products/big-chair?test=123&canonical=123') const product1Dom = await getDom(product1Html) expect(await product1Dom.locator('link[id=i18n-alt-nl]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/nl/products/grote-stoel?canonical=123' + 'http://localhost:3000/nl/products/grote-stoel?canonical=123', ) expect(await product1Dom.locator('#switch-locale-path-link-nl')?.getAttribute('href')).toEqual( - '/nl/products/grote-stoel?test=123&canonical=123' + '/nl/products/grote-stoel?test=123&canonical=123', ) const product2Html = await $fetch('/nl/products/rode-mok?test=123&canonical=123') const product2dom = await getDom(product2Html) expect(await product2dom.locator('link[id=i18n-alt-en]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/products/red-mug?canonical=123' + 'http://localhost:3000/products/red-mug?canonical=123', ) expect(await product2dom.locator('#switch-locale-path-link-en')?.getAttribute('href')).toEqual( - '/products/red-mug?test=123&canonical=123' + '/products/red-mug?test=123&canonical=123', ) }) @@ -496,19 +495,19 @@ describe('basic usage', async () => { const product1Html = await $fetch('/products/big-chair') const product1Dom = await getDom(product1Html) expect(await product1Dom.locator('link[id=i18n-alt-nl]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/nl/products/grote-stoel' + 'http://localhost:3000/nl/products/grote-stoel', ) expect(await product1Dom.locator('#switch-locale-path-link-nl')?.getAttribute('href')).toEqual( - '/nl/products/grote-stoel' + '/nl/products/grote-stoel', ) const product2Html = await $fetch('/nl/products/rode-mok') const product2dom = await getDom(product2Html) expect(await product2dom.locator('link[id=i18n-alt-en]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/products/red-mug' + 'http://localhost:3000/products/red-mug', ) expect(await product2dom.locator('#switch-locale-path-link-en')?.getAttribute('href')).toEqual( - '/products/red-mug' + '/products/red-mug', ) }) @@ -529,14 +528,14 @@ describe('basic usage', async () => { // LocaleDetector: header const resHeader = await $fetch('/api/server', { query: { key: 'snakeCaseText' }, - headers: { 'Accept-Language': 'fr' } + headers: { 'Accept-Language': 'fr' }, }) expect(resHeader?.snakeCaseText).toMatch('À-propos-de-ce-site') // LocaleDetector: cookie const resCookie = await $fetch('/api/server', { query: { key: 'snakeCaseText' }, - headers: { cookie: 'i18n_locale=fr;' } + headers: { cookie: 'i18n_locale=fr;' }, }) expect(resCookie?.snakeCaseText).toMatch('À-propos-de-ce-site') @@ -558,7 +557,7 @@ describe('basic usage', async () => { await gotoPath(page, '/nl/products/rode-mok') await page.waitForFunction( - () => document.querySelector('#switch-locale-path-link-en')?.getAttribute('href') === '/products/red-mug' + () => document.querySelector('#switch-locale-path-link-en')?.getAttribute('href') === '/products/red-mug', ) expect(await page.locator('#switch-locale-path-link-en').getAttribute('href')).toEqual('/products/red-mug') @@ -566,7 +565,7 @@ describe('basic usage', async () => { await page.locator('#params-add-query').clickNavigate() await page.waitForURL(url('/nl/products/rode-mok?test=123&canonical=123')) expect(await page.locator('#switch-locale-path-link-en').getAttribute('href')).toEqual( - '/products/red-mug?test=123&canonical=123' + '/products/red-mug?test=123&canonical=123', ) await page.locator('#params-remove-query').clickNavigate() @@ -577,22 +576,22 @@ describe('basic usage', async () => { const product1Html = await $fetch('/products/big-chair') const product1Dom = await getDom(product1Html) expect(await product1Dom.locator('link[id=i18n-alt-nl]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/nl/products/grote-stoel' + 'http://localhost:3000/nl/products/grote-stoel', ) const product2Html = await $fetch('/nl/products/rode-mok') const product2dom = await getDom(product2Html) expect(await product2dom.locator('link[id=i18n-alt-en]')?.getAttribute('href')).toEqual( - 'http://localhost:3000/products/red-mug' + 'http://localhost:3000/products/red-mug', ) }) test('(#2000) Should be able to load large vue-i18n messages', async () => { const restore = await startServerWithRuntimeConfig( { - public: { longTextTest: true } + public: { longTextTest: true }, }, - true + true, ) const { page } = await renderPage('/nl/long-text') @@ -644,7 +643,7 @@ describe('basic usage', async () => { await page.locator('#params-add-query').clickNavigate() await page.waitForURL(url('/nl/products/rode-mok?test=123&canonical=123')) expect(await page.locator('#switch-locale-path-link-en').getAttribute('href')).toEqual( - '/products/red-mug?test=123&canonical=123' + '/products/red-mug?test=123&canonical=123', ) await page.locator('#params-remove-query').clickNavigate() @@ -670,11 +669,11 @@ describe('basic usage', async () => { public: { i18n: { skipSettingLocaleOnNavigate: true, - detectBrowserLanguage: false - } - } + detectBrowserLanguage: false, + }, + }, }, - true + true, ) }) @@ -700,7 +699,7 @@ describe('basic usage', async () => { // page path expect(JSON.parse(await page.locator('#home-use-async-data').innerText())).toMatchObject({ aboutPath: '/about', - aboutTranslation: 'About us' + aboutTranslation: 'About us', }) expect(await page.getAttribute('#nuxt-locale-link-fr', 'href')).toEqual('/fr') diff --git a/specs/browser_language_detection/no_prefix.spec.ts b/specs/browser_language_detection/no_prefix.spec.ts index b9ef389a5..d21851d4e 100644 --- a/specs/browser_language_detection/no_prefix.spec.ts +++ b/specs/browser_language_detection/no_prefix.spec.ts @@ -15,10 +15,10 @@ await setup({ cookieKey: 'my_custom_cookie_name', redirectOn: 'root', cookieCrossOrigin: true, - cookieSecure: true - } - } - } + cookieSecure: true, + }, + }, + }, }) test('detection with cookie', async () => { @@ -30,22 +30,22 @@ test('detection with cookie', async () => { cookieKey: 'my_custom_cookie_name', redirectOn: 'root', cookieCrossOrigin: true, - cookieSecure: true - } - } - } + cookieSecure: true, + }, + }, + }, }) - const { page, requests, consoleLogs } = await renderPage('/', { locale: 'en' }) + const { page } = await renderPage('/', { locale: 'en' }) const ctx = await page.context() expect(await ctx.cookies()).toMatchObject([ - { name: 'my_custom_cookie_name', value: 'en', secure: true, sameSite: 'None' } + { name: 'my_custom_cookie_name', value: 'en', secure: true, sameSite: 'None' }, ]) // click `fr` lang switch link await Promise.all([waitForLocaleSwitch(page), page.locator('#set-locale-link-fr').click()]) expect(await ctx.cookies()).toMatchObject([ - { name: 'my_custom_cookie_name', value: 'fr', secure: true, sameSite: 'None' } + { name: 'my_custom_cookie_name', value: 'fr', secure: true, sameSite: 'None' }, ]) // navigate to about @@ -72,10 +72,10 @@ test('detection with cookie - overwrite unknown locale', async () => { cookieKey: 'my_custom_cookie_name', redirectOn: 'root', cookieCrossOrigin: true, - cookieSecure: true - } - } - } + cookieSecure: true, + }, + }, + }, }) const { page } = await renderPage('/', { locale: 'en' }) const ctx = page.context() @@ -87,13 +87,13 @@ test('detection with cookie - overwrite unknown locale', async () => { localeCookie!.value = 'unknown_locale' await ctx.addCookies([localeCookie!]) expect(await ctx.cookies()).toMatchObject([ - { name: 'my_custom_cookie_name', value: 'unknown_locale', secure: true, sameSite: 'None' } + { name: 'my_custom_cookie_name', value: 'unknown_locale', secure: true, sameSite: 'None' }, ]) // unknown locale cookie is overwritten to default locale await gotoPath(page, '/') expect(await ctx.cookies()).toMatchObject([ - { name: 'my_custom_cookie_name', value: 'en', secure: true, sameSite: 'None' } + { name: 'my_custom_cookie_name', value: 'en', secure: true, sameSite: 'None' }, ]) }) @@ -103,10 +103,10 @@ test('detection with browser', async () => { public: { i18n: { detectBrowserLanguage: { - useCookie: false - } - } - } + useCookie: false, + }, + }, + }, }) const { page } = await renderPage('/', { locale: 'fr' }) @@ -139,9 +139,9 @@ test('disable', async () => { await setServerRuntimeConfig({ public: { i18n: { - detectBrowserLanguage: false - } - } + detectBrowserLanguage: false, + }, + }, }) const { page } = await renderPage('/', { locale: 'en' }) @@ -173,10 +173,10 @@ test('fallback', async () => { i18n: { detectBrowserLanguage: { useCookie: false, - fallbackLocale: 'fr' - } - } - } + fallbackLocale: 'fr', + }, + }, + }, }) const { page } = await renderPage('/', { locale: 'ja' }) diff --git a/specs/browser_language_detection/prefix_and_default.spec.ts b/specs/browser_language_detection/prefix_and_default.spec.ts index 403fdee7a..3f4f569a4 100644 --- a/specs/browser_language_detection/prefix_and_default.spec.ts +++ b/specs/browser_language_detection/prefix_and_default.spec.ts @@ -11,10 +11,10 @@ await setup({ i18n: { strategy: 'prefix_and_default', detectBrowserLanguage: { - redirectOn: 'all' - } - } - } + redirectOn: 'all', + }, + }, + }, }) test('redirectOn: all', async () => { @@ -23,10 +23,10 @@ test('redirectOn: all', async () => { i18n: { detectBrowserLanguage: { alwaysRedirect: false, - redirectOn: 'no prefix' - } - } - } + redirectOn: 'no prefix', + }, + }, + }, }) const { page } = await renderPage('/blog/article', { locale: 'fr' }) @@ -49,12 +49,12 @@ test('redirectOn: no prefix', async () => { i18n: { detectBrowserLanguage: { alwaysRedirect: false, - redirectOn: 'no prefix' - } - } - } + redirectOn: 'no prefix', + }, + }, + }, }, - true + true, ) const { page } = await renderPage('/blog/article', { locale: 'fr' }) @@ -77,10 +77,10 @@ test('alwaysRedirect: all', async () => { i18n: { detectBrowserLanguage: { alwaysRedirect: true, - redirectOn: 'all' - } - } - } + redirectOn: 'all', + }, + }, + }, }) const blog = '/blog/article' const { page } = await renderPage(blog, { locale: 'en' }) // set browser locale @@ -104,10 +104,10 @@ test('alwaysRedirect: no prefix', async () => { i18n: { detectBrowserLanguage: { alwaysRedirect: true, - redirectOn: 'no prefix' - } - } - } + redirectOn: 'no prefix', + }, + }, + }, }) const { page } = await renderPage('/about', { locale: 'en' }) // set browser locale const ctx = await page.context() diff --git a/specs/browser_language_detection/prefix_except_default.spec.ts b/specs/browser_language_detection/prefix_except_default.spec.ts index d8d8c86d5..ecbcd1b76 100644 --- a/specs/browser_language_detection/prefix_except_default.spec.ts +++ b/specs/browser_language_detection/prefix_except_default.spec.ts @@ -13,10 +13,10 @@ await setup({ detectBrowserLanguage: { useCookie: true, redirectOn: 'root', - alwaysRedirect: true - } - } - } + alwaysRedirect: true, + }, + }, + }, }) describe('`detectBrowserLanguage` using strategy `prefix_except_default`', async () => { @@ -27,10 +27,10 @@ describe('`detectBrowserLanguage` using strategy `prefix_except_default`', async detectBrowserLanguage: { useCookie: true, redirectOn: 'root', - alwaysRedirect: true - } - } - } + alwaysRedirect: true, + }, + }, + }, }) const { page } = await renderPage('/', { locale: 'en' }) const ctx = page.context() @@ -61,10 +61,10 @@ describe('`detectBrowserLanguage` using strategy `prefix_except_default`', async i18n: { detectBrowserLanguage: { useCookie: true, - redirectOn: 'root' - } - } - } + redirectOn: 'root', + }, + }, + }, }) }) diff --git a/specs/custom_route_paths/component.spec.ts b/specs/custom_route_paths/component.spec.ts index 2dfda3f20..d9c872baa 100644 --- a/specs/custom_route_paths/component.spec.ts +++ b/specs/custom_route_paths/component.spec.ts @@ -11,9 +11,9 @@ await setup({ i18n: { defaultLocale: 'en', customRoutes: 'page', - detectBrowserLanguage: false - } - } + detectBrowserLanguage: false, + }, + }, }) test('can access to custom route path', async () => { @@ -75,12 +75,13 @@ test('can not access to disable route path', async () => { // attempting to goto /fr/disable instead of /fr/ignore-routes/disable since // that route has a catch all that would succeed res = await page.goto(url('/fr/disable')) - } catch (error: unknown) { + } + catch (error: unknown) { res = error as Error & { status: () => number } } // 404 - expect(res!.status()).toBe(404) // eslint-disable-line @typescript-eslint/no-non-null-assertion + expect(res!.status()).toBe(404) }) test('(#3831) nested index root custom routes', async () => { diff --git a/specs/custom_route_paths/module_configration.spec.ts b/specs/custom_route_paths/module_configration.spec.ts index 916d10e9e..59e020784 100644 --- a/specs/custom_route_paths/module_configration.spec.ts +++ b/specs/custom_route_paths/module_configration.spec.ts @@ -14,22 +14,22 @@ await setup({ customRoutes: 'config', pages: { 'category/[slug]': false, - history: { - fr: false + 'history': { + fr: false, }, 'about/index': { - fr: '/about-fr' + fr: '/about-fr', }, 'blog/index': { - en: '/news' + en: '/news', }, 'blog/article': { - en: '/news/article' - } + en: '/news/article', + }, }, - detectBrowserLanguage: false - } - } + detectBrowserLanguage: false, + }, + }, }) test('can access to custom route path', async () => { @@ -41,7 +41,7 @@ test('can access to custom route path', async () => { // page path expect(JSON.parse(await page.locator('#home-use-async-data').innerText())).toMatchObject({ - aboutPath: '/fr/about-fr' + aboutPath: '/fr/about-fr', }) // navigate to about page for `fr` @@ -79,11 +79,12 @@ test('can not access to pick route path', async () => { let res: Awaited> | (Error & { status: () => number }) | null = null try { res = await page.goto(url('/fr/history')) - } catch (error: unknown) { + } + catch (error: unknown) { res = error as Error & { status: () => number } } // 404 - expect(res!.status()).toBe(404) // eslint-disable-line @typescript-eslint/no-non-null-assertion + expect(res!.status()).toBe(404) }) test('can not access to disable route path', async () => { @@ -100,11 +101,12 @@ test('can not access to disable route path', async () => { let res: Awaited> | (Error & { status: () => number }) | null = null try { res = await page.goto(url('/fr/category/test')) - } catch (error: unknown) { + } + catch (error: unknown) { res = error as Error & { status: () => number } } // 404 - expect(res!.status()).toBe(404) // eslint-disable-line @typescript-eslint/no-non-null-assertion + expect(res!.status()).toBe(404) }) test('#3076 - layer with custom `srcDir`', async () => { diff --git a/specs/different_domains/different_domains.spec.ts b/specs/different_domains/different_domains.spec.ts index d94da3e62..54835affd 100644 --- a/specs/different_domains/different_domains.spec.ts +++ b/specs/different_domains/different_domains.spec.ts @@ -13,11 +13,11 @@ await setup({ i18n: { domainLocales: { kr: { - domain: 'kr.staging.nuxt-app.localhost' - } - } - } - } + domain: 'kr.staging.nuxt-app.localhost', + }, + }, + }, + }, }, i18n: { baseUrl: 'http://localhost:3000', @@ -26,24 +26,24 @@ await setup({ code: 'en', language: 'en', name: 'English', - domain: 'en.nuxt-app.localhost' + domain: 'en.nuxt-app.localhost', }, { code: 'fr', language: 'fr-FR', name: 'Français', - domain: 'fr.nuxt-app.localhost' + domain: 'fr.nuxt-app.localhost', }, { code: 'kr', language: 'ko-KR', name: '한국어', - domain: 'kr.nuxt-app.localhost' - } + domain: 'kr.nuxt-app.localhost', + }, ], strategy: 'no_prefix', detectBrowserLanguage: { - useCookie: true + useCookie: true, }, customRoutes: 'config', pages: { @@ -51,22 +51,22 @@ await setup({ en: '/localized-in-english', fr: '/localized-in-french', ja: '/localized-in-japanese', - nl: '/localized-in-dutch' - } - } - } - } + nl: '/localized-in-dutch', + }, + }, + }, + }, }) describe('detection locale with host on server', () => { test.each([ ['en', 'en.nuxt-app.localhost', 'Homepage'], - ['fr', 'fr.nuxt-app.localhost', 'Accueil'] + ['fr', 'fr.nuxt-app.localhost', 'Accueil'], ])('%s host', async (locale, host, header) => { const res = await undiciRequest('/', { headers: { - Host: host - } + Host: host, + }, }) const dom = await getDom(await res.body.text()) @@ -78,8 +78,8 @@ describe('detection locale with host on server', () => { test('detection locale with x-forwarded-host on server', async () => { const html = await $fetch('/', { headers: { - 'X-Forwarded-Host': 'fr.nuxt-app.localhost' - } + 'X-Forwarded-Host': 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(html) @@ -90,61 +90,61 @@ test('detection locale with x-forwarded-host on server', async () => { test('pass ` to props', async () => { const res = await undiciRequest('/', { headers: { - Host: 'fr.nuxt-app.localhost' - } + Host: 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(await res.body.text()) expect(await dom.locator('#switch-locale-path-usages .switch-to-en a').getAttribute('href')).toEqual( - `http://en.nuxt-app.localhost` + `http://en.nuxt-app.localhost`, ) expect(await dom.locator('#switch-locale-path-usages .switch-to-fr a').getAttribute('href')).toEqual( - `http://fr.nuxt-app.localhost` + `http://fr.nuxt-app.localhost`, ) }) test('layer provides locales with domains', async () => { const res = await undiciRequest('/', { headers: { - Host: 'fr.nuxt-app.localhost' - } + Host: 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(await res.body.text()) // `en` link uses project domain configuration, overrides layer expect(await dom.locator('#switch-locale-path-usages .switch-to-en a').getAttribute('href')).toEqual( - `http://en.nuxt-app.localhost` + `http://en.nuxt-app.localhost`, ) // `nl` link uses layer domain configuration expect(await dom.locator('#switch-locale-path-usages .switch-to-nl a').getAttribute('href')).toEqual( - `http://layer-nl.example.com` + `http://layer-nl.example.com`, ) // `ja` link uses layer domain configuration expect(await dom.locator('#switch-locale-path-usages .switch-to-ja a').getAttribute('href')).toEqual( - `http://layer-ja.example.com` + `http://layer-ja.example.com`, ) }) test('pass ` to props using domains from runtimeConfig', async () => { const res = await undiciRequest('/', { headers: { - Host: 'fr.nuxt-app.localhost' - } + Host: 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(await res.body.text()) expect(await dom.locator('#switch-locale-path-usages .switch-to-kr a').getAttribute('href')).toEqual( - `http://kr.staging.nuxt-app.localhost` + `http://kr.staging.nuxt-app.localhost`, ) }) test.each([ ['en.nuxt-app.localhost', 'Welcome'], - ['fr.nuxt-app.localhost', 'Bienvenue'] + ['fr.nuxt-app.localhost', 'Bienvenue'], ])('(#2374) detect %s with host on server', async (host, header) => { const res = await undiciRequest('/', { headers: { - host: host - } + host: host, + }, }) const dom = await getDom(await res.body.text()) expect(await dom.locator('#welcome-text').textContent()).toEqual(header) @@ -153,8 +153,8 @@ test.each([ test('(#2931) detect using runtimeConfig domain', async () => { const res = await undiciRequest('/', { headers: { - host: 'kr.staging.nuxt-app.localhost' - } + host: 'kr.staging.nuxt-app.localhost', + }, }) const dom = await getDom(await res.body.text()) expect(await dom.locator('#welcome-text').textContent()).toEqual('환영하다') @@ -163,34 +163,34 @@ test('(#2931) detect using runtimeConfig domain', async () => { test('(#2374) detect with x-forwarded-host on server', async () => { const html = await $fetch('/', { headers: { - 'X-Forwarded-Host': 'fr.nuxt-app.localhost' - } + 'X-Forwarded-Host': 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(html) expect(await dom.locator('#welcome-text').textContent()).toEqual('Bienvenue') }) -test("supports custom routes with `strategy: 'no_prefix'`", async () => { +test('supports custom routes with `strategy: \'no_prefix\'`', async () => { const res = await undiciRequest('/localized-in-french', { headers: { - host: 'fr.nuxt-app.localhost' - } + host: 'fr.nuxt-app.localhost', + }, }) const resBody = await res.body.text() const dom = await getDom(resBody) // `en` link uses project domain configuration, overrides layer expect(await dom.locator('#switch-locale-path-usages .switch-to-en a').getAttribute('href')).toEqual( - `http://en.nuxt-app.localhost/localized-in-english` + `http://en.nuxt-app.localhost/localized-in-english`, ) // `nl` link uses layer domain configuration expect(await dom.locator('#switch-locale-path-usages .switch-to-nl a').getAttribute('href')).toEqual( - `http://layer-nl.example.com/localized-in-dutch` + `http://layer-nl.example.com/localized-in-dutch`, ) // `ja` link uses layer domain configuration expect(await dom.locator('#switch-locale-path-usages .switch-to-ja a').getAttribute('href')).toEqual( - `http://layer-ja.example.com/localized-in-japanese` + `http://layer-ja.example.com/localized-in-japanese`, ) }) diff --git a/specs/different_domains/different_domains_base_path.spec.ts b/specs/different_domains/different_domains_base_path.spec.ts index 7055c856c..de0c10a27 100644 --- a/specs/different_domains/different_domains_base_path.spec.ts +++ b/specs/different_domains/different_domains_base_path.spec.ts @@ -1,6 +1,6 @@ -import { test, expect, describe } from 'vitest' +import { test, expect } from 'vitest' import { fileURLToPath } from 'node:url' -import { setup, $fetch, undiciRequest } from '../utils' +import { setup, undiciRequest } from '../utils' import { getDom } from '../helper' await setup({ @@ -9,7 +9,7 @@ await setup({ nuxtConfig: { extends: [fileURLToPath(new URL(`../fixtures/layers/layer-domain`, import.meta.url))], app: { - baseURL: '/base-path' + baseURL: '/base-path', }, i18n: { baseUrl: 'http://localhost:3000', @@ -18,24 +18,24 @@ await setup({ code: 'en', language: 'en', name: 'English', - domain: 'en.nuxt-app.localhost' + domain: 'en.nuxt-app.localhost', }, { code: 'fr', language: 'fr-FR', name: 'Français', - domain: 'fr.nuxt-app.localhost' + domain: 'fr.nuxt-app.localhost', }, { code: 'kr', language: 'ko-KR', name: '한국어', - domain: 'kr.nuxt-app.localhost' - } + domain: 'kr.nuxt-app.localhost', + }, ], strategy: 'no_prefix', detectBrowserLanguage: { - useCookie: true + useCookie: true, }, customRoutes: 'config', pages: { @@ -43,17 +43,17 @@ await setup({ en: '/localized-in-english', fr: '/localized-in-french', ja: '/localized-in-japanese', - nl: '/localized-in-dutch' - } - } - } - } + nl: '/localized-in-dutch', + }, + }, + }, + }, }) test('(#3628) `switchLocalePath` includes `app.baseURL`', async () => { const res = await undiciRequest('/base-path') const dom = await getDom(await res.body.text()) expect(await dom?.locator('#switch-locale-path-usages .switch-to-kr a')?.getAttribute('href')).toEqual( - `http://kr.nuxt-app.localhost/base-path` + `http://kr.nuxt-app.localhost/base-path`, ) }) diff --git a/specs/different_domains/different_domains_multi_locales_prefix.spec.ts b/specs/different_domains/different_domains_multi_locales_prefix.spec.ts index 3cd6a5cdd..73ef3a5af 100644 --- a/specs/different_domains/different_domains_multi_locales_prefix.spec.ts +++ b/specs/different_domains/different_domains_multi_locales_prefix.spec.ts @@ -15,38 +15,38 @@ await setup({ language: 'en', name: 'English', domain: 'nuxt-app.localhost', - domainDefault: true + domainDefault: true, }, { code: 'no', language: 'no-NO', name: 'Norwegian', - domain: 'nuxt-app.localhost' + domain: 'nuxt-app.localhost', }, { code: 'fr', language: 'fr-FR', name: 'Français', - domain: 'fr.nuxt-app.localhost' - } + domain: 'fr.nuxt-app.localhost', + }, ], strategy: 'prefix', detectBrowserLanguage: { - useCookie: true - } - } - } + useCookie: true, + }, + }, + }, }) describe('detection locale with host on server', () => { test.each([ ['en', 'nuxt-app.localhost', 'Homepage'], - ['fr', 'fr.nuxt-app.localhost', 'Accueil'] + ['fr', 'fr.nuxt-app.localhost', 'Accueil'], ])('%s host', async (locale, host, header) => { const res = await undiciRequest('/' + locale, { headers: { - Host: host - } + Host: host, + }, }) const dom = await getDom(await res.body.text()) @@ -58,8 +58,8 @@ describe('detection locale with host on server', () => { test('detection locale with x-forwarded-host on server', async () => { const html = await $fetch('/fr', { headers: { - 'X-Forwarded-Host': 'fr.nuxt-app.localhost' - } + 'X-Forwarded-Host': 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(html) @@ -70,17 +70,17 @@ test('detection locale with x-forwarded-host on server', async () => { test('pass ` to props', async () => { const res = await undiciRequest('/fr', { headers: { - Host: 'fr.nuxt-app.localhost' - } + Host: 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(await res.body.text()) expect(await dom.locator('#switch-locale-path-usages .switch-to-en a').getAttribute('href')).toEqual( - `http://nuxt-app.localhost/en` + `http://nuxt-app.localhost/en`, ) expect(await dom.locator('#switch-locale-path-usages .switch-to-no a').getAttribute('href')).toEqual( - `http://nuxt-app.localhost/no` + `http://nuxt-app.localhost/no`, ) expect(await dom.locator('#switch-locale-path-usages .switch-to-fr a').getAttribute('href')).toEqual( - `http://fr.nuxt-app.localhost/fr` + `http://fr.nuxt-app.localhost/fr`, ) }) diff --git a/specs/different_domains/different_domains_multi_locales_prefix_except_default.spec.ts b/specs/different_domains/different_domains_multi_locales_prefix_except_default.spec.ts index 3d2705465..fc30527b7 100644 --- a/specs/different_domains/different_domains_multi_locales_prefix_except_default.spec.ts +++ b/specs/different_domains/different_domains_multi_locales_prefix_except_default.spec.ts @@ -15,47 +15,47 @@ await setup({ language: 'en', name: 'English', domain: 'nuxt-app.localhost', - domainDefault: true + domainDefault: true, }, { code: 'no', language: 'no-NO', name: 'Norwegian', - domain: 'nuxt-app.localhost' + domain: 'nuxt-app.localhost', }, { code: 'fr', language: 'fr-FR', name: 'Français', domain: 'fr.nuxt-app.localhost', - domainDefault: true + domainDefault: true, }, { code: 'ja', language: 'jp-JA', name: 'Japan', domain: 'ja.nuxt-app.localhost', - domainDefault: true - } + domainDefault: true, + }, ], strategy: 'prefix_except_default', detectBrowserLanguage: { - useCookie: true - } - } - } + useCookie: true, + }, + }, + }, }) describe('detection locale with host on server', () => { test.each([ ['/', 'en', 'nuxt-app.localhost', 'Homepage'], ['/no', 'no', 'nuxt-app.localhost', 'Hjemmeside'], - ['/', 'fr', 'fr.nuxt-app.localhost', 'Accueil'] + ['/', 'fr', 'fr.nuxt-app.localhost', 'Accueil'], ])('%s host', async (path, locale, host, header) => { const res = await undiciRequest(path, { headers: { - Host: host - } + Host: host, + }, }) const dom = await getDom(await res.body.text()) @@ -67,8 +67,8 @@ describe('detection locale with host on server', () => { test('detection locale with x-forwarded-host on server', async () => { const html = await $fetch('/', { headers: { - 'X-Forwarded-Host': 'fr.nuxt-app.localhost' - } + 'X-Forwarded-Host': 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(html) @@ -79,17 +79,17 @@ test('detection locale with x-forwarded-host on server', async () => { test('pass ` to props', async () => { const res = await undiciRequest('/', { headers: { - Host: 'fr.nuxt-app.localhost' - } + Host: 'fr.nuxt-app.localhost', + }, }) const dom = await getDom(await res.body.text()) expect(await dom.locator('#switch-locale-path-usages .switch-to-en a').getAttribute('href')).toEqual( - `http://nuxt-app.localhost` + `http://nuxt-app.localhost`, ) expect(await dom.locator('#switch-locale-path-usages .switch-to-no a').getAttribute('href')).toEqual( - `http://nuxt-app.localhost/no` + `http://nuxt-app.localhost/no`, ) expect(await dom.locator('#switch-locale-path-usages .switch-to-fr a').getAttribute('href')).toEqual( - `http://fr.nuxt-app.localhost` + `http://fr.nuxt-app.localhost`, ) }) diff --git a/specs/different_domains/no_ssr.spec.ts b/specs/different_domains/no_ssr.spec.ts index 395b3e6df..006eb5914 100644 --- a/specs/different_domains/no_ssr.spec.ts +++ b/specs/different_domains/no_ssr.spec.ts @@ -10,30 +10,30 @@ await setup({ locales: [ { code: 'en', - domain: 'en.nuxt-app.localhost' + domain: 'en.nuxt-app.localhost', }, { code: 'fr', - domain: 'fr.nuxt-app.localhost' + domain: 'fr.nuxt-app.localhost', }, { code: 'nl', - domain: 'localhost' - } + domain: 'localhost', + }, ], - strategy: 'no_prefix' + strategy: 'no_prefix', }, - ssr: false - } + ssr: false, + }, }) test('(#2313) detection locale from domain', async () => { async function assertDifferentDomain(locale: string, browserLocale = 'en') { const page = await createPage(url('/'), { extraHTTPHeaders: { - 'X-Forwarded-Host': `${locale}.nuxt-app.localhost` + 'X-Forwarded-Host': `${locale}.nuxt-app.localhost`, }, - locale: browserLocale + locale: browserLocale, }) expect(await page.locator('#lang-switcher-current-locale code').innerText()).toEqual(locale) diff --git a/specs/empty_options.spec.ts b/specs/empty_options.spec.ts index ec6300d58..350919bcb 100644 --- a/specs/empty_options.spec.ts +++ b/specs/empty_options.spec.ts @@ -5,7 +5,7 @@ import { renderPage } from './helper' await setup({ rootDir: fileURLToPath(new URL(`./fixtures/empty_options`, import.meta.url)), - browser: true + browser: true, }) describe('inline options are handled correctly', async () => { diff --git a/specs/exclude_locales.spec.ts b/specs/exclude_locales.spec.ts index d9274b67a..b490c1bb7 100644 --- a/specs/exclude_locales.spec.ts +++ b/specs/exclude_locales.spec.ts @@ -10,11 +10,11 @@ await setup({ nuxtConfig: { i18n: { bundle: { - onlyLocales: 'en' + onlyLocales: 'en', }, - detectBrowserLanguage: false - } - } + detectBrowserLanguage: false, + }, + }, }) test('leave only English locale', async () => { diff --git a/specs/experimental/alternate_link_canonical_queries.spec.ts b/specs/experimental/alternate_link_canonical_queries.spec.ts index bcb5761c1..f0b8b5eef 100644 --- a/specs/experimental/alternate_link_canonical_queries.spec.ts +++ b/specs/experimental/alternate_link_canonical_queries.spec.ts @@ -11,10 +11,10 @@ await setup({ nuxtConfig: { i18n: { experimental: { - alternateLinkCanonicalQueries: false - } - } - } + alternateLinkCanonicalQueries: false, + }, + }, + }, }) describe('experimental.alternateLinkCanonicalQueries', async () => { @@ -23,19 +23,19 @@ describe('experimental.alternateLinkCanonicalQueries', async () => { const product1Html = await $fetch('/products/big-chair?test=123&canonical=123') const product1Dom = await getDom(product1Html) expect(await product1Dom.locator('#i18n-alt-nl').getAttribute('href')).toEqual( - 'http://localhost:3000/nl/products/grote-stoel?test=123&canonical=123' + 'http://localhost:3000/nl/products/grote-stoel?test=123&canonical=123', ) expect(await product1Dom.locator('#switch-locale-path-link-nl').getAttribute('href')).toEqual( - '/nl/products/grote-stoel?test=123&canonical=123' + '/nl/products/grote-stoel?test=123&canonical=123', ) const product2Html = await $fetch('/nl/products/rode-mok?test=123&canonical=123') const product2dom = await getDom(product2Html) expect(await product2dom.locator('#i18n-alt-en').getAttribute('href')).toEqual( - 'http://localhost:3000/products/red-mug?test=123&canonical=123' + 'http://localhost:3000/products/red-mug?test=123&canonical=123', ) expect(await product2dom.locator('#switch-locale-path-link-en').getAttribute('href')).toEqual( - '/products/red-mug?test=123&canonical=123' + '/products/red-mug?test=123&canonical=123', ) }) }) diff --git a/specs/experimental/experimental_seo.spec.ts b/specs/experimental/experimental_seo.spec.ts index 9f5076f7f..c9a6dadf3 100644 --- a/specs/experimental/experimental_seo.spec.ts +++ b/specs/experimental/experimental_seo.spec.ts @@ -11,10 +11,10 @@ await setup({ nuxtConfig: { i18n: { experimental: { - strictSeo: true - } - } - } + strictSeo: true, + }, + }, + }, }) describe('experimental.strictSeo', async () => { diff --git a/specs/experimental/scan_page_meta.spec.ts b/specs/experimental/scan_page_meta.spec.ts index ef53ae7ae..bb427985a 100644 --- a/specs/experimental/scan_page_meta.spec.ts +++ b/specs/experimental/scan_page_meta.spec.ts @@ -9,9 +9,9 @@ await setup({ // overrides nuxtConfig: { experimental: { - scanPageMeta: true - } - } + scanPageMeta: true, + }, + }, }) describe('Using Nuxt experimental feature `scanPageMeta`', async () => { diff --git a/specs/experimental/typed_pages.spec.ts b/specs/experimental/typed_pages.spec.ts index 6104f751f..63a603a64 100644 --- a/specs/experimental/typed_pages.spec.ts +++ b/specs/experimental/typed_pages.spec.ts @@ -9,9 +9,9 @@ await setup({ // overrides nuxtConfig: { experimental: { - typedPages: true - } - } + typedPages: true, + }, + }, }) describe('`experimental.typedPages` undefined or enabled', async () => { @@ -21,11 +21,11 @@ describe('`experimental.typedPages` undefined or enabled', async () => { fileURLToPath( new URL( `../fixtures/basic_usage/.nuxt/___experimental_typed_pages_spec_ts/types/typed-router-i18n.d.ts`, - import.meta.url - ) + import.meta.url, + ), ), - 'utf-8' - ) + 'utf-8', + ), ).toMatchInlineSnapshot(` "/* eslint-disable */ /* prettier-ignore */ diff --git a/specs/experimental/typed_pages_explicit_disable.spec.ts b/specs/experimental/typed_pages_explicit_disable.spec.ts index 1acf2a622..d0483c219 100644 --- a/specs/experimental/typed_pages_explicit_disable.spec.ts +++ b/specs/experimental/typed_pages_explicit_disable.spec.ts @@ -9,14 +9,14 @@ await setup({ // overrides nuxtConfig: { experimental: { - typedPages: true + typedPages: true, }, i18n: { experimental: { - typedPages: false - } - } - } + typedPages: false, + }, + }, + }, }) describe('`experimental.typedPages` explicitly disabled', async () => { @@ -26,10 +26,10 @@ describe('`experimental.typedPages` explicitly disabled', async () => { fileURLToPath( new URL( `../fixtures/basic_usage/.nuxt/___experimental_typed_pages_explicit_disable_spec_ts/types/typed-router-i18n.d.ts`, - import.meta.url - ) - ) - ) + import.meta.url, + ), + ), + ), ).rejects.toThrowError() }) }) diff --git a/specs/fixtures/basic/i18n/config/i18n.config.ts b/specs/fixtures/basic/i18n/config/i18n.config.ts index 6e4e06eac..5ca9f0903 100644 --- a/specs/fixtures/basic/i18n/config/i18n.config.ts +++ b/specs/fixtures/basic/i18n/config/i18n.config.ts @@ -11,9 +11,9 @@ export default { dynamic: 'Dynamique', pages: { blog: { - article: "Cette page d'article de blog" - } - } + article: 'Cette page d\'article de blog', + }, + }, }, en: { welcome: 'Welcome', @@ -24,14 +24,14 @@ export default { dynamic: 'Dynamic', pages: { blog: { - article: 'This is blog article page' - } - } - } + article: 'This is blog article page', + }, + }, + }, }, modifiers: { // @ts-ignore - snakeCase: (str: string) => str.split(' ').join('-') + snakeCase: (str: string) => str.split(' ').join('-'), }, - fallbackLocale: 'en' + fallbackLocale: 'en', } diff --git a/specs/fixtures/basic/nuxt.config.ts b/specs/fixtures/basic/nuxt.config.ts index 4d33da33d..5ed566e70 100644 --- a/specs/fixtures/basic/nuxt.config.ts +++ b/specs/fixtures/basic/nuxt.config.ts @@ -11,15 +11,15 @@ export default defineNuxtConfig({ { code: 'en', language: 'en', - name: 'English' + name: 'English', }, { code: 'fr', language: 'fr-FR', - name: 'Français' - } + name: 'Français', + }, ], defaultLocale: 'en', - vueI18n: './config/i18n.config.ts' - } + vueI18n: './config/i18n.config.ts', + }, }) diff --git a/specs/fixtures/basic/pages/about/index.vue b/specs/fixtures/basic/pages/about/index.vue index bc8ff5650..cb32375a3 100644 --- a/specs/fixtures/basic/pages/about/index.vue +++ b/specs/fixtures/basic/pages/about/index.vue @@ -11,14 +11,18 @@ const code = computed(() => { diff --git a/specs/fixtures/basic/pages/blog/article.vue b/specs/fixtures/basic/pages/blog/article.vue index cc74edf22..2aacabcbc 100644 --- a/specs/fixtures/basic/pages/blog/article.vue +++ b/specs/fixtures/basic/pages/blog/article.vue @@ -13,9 +13,7 @@ const code = computed(() => {

{{ t('pages.blog.article') }}

- code: {{ code }} + code: {{ code }}
diff --git a/specs/fixtures/basic/pages/blog/index.vue b/specs/fixtures/basic/pages/blog/index.vue index d6f64a820..782a1bf30 100644 --- a/specs/fixtures/basic/pages/blog/index.vue +++ b/specs/fixtures/basic/pages/blog/index.vue @@ -1,6 +1,10 @@ diff --git a/specs/fixtures/basic/pages/category/[slug].vue b/specs/fixtures/basic/pages/category/[slug].vue index f0dfe29e9..b37c1cc01 100644 --- a/specs/fixtures/basic/pages/category/[slug].vue +++ b/specs/fixtures/basic/pages/category/[slug].vue @@ -1,4 +1,9 @@ diff --git a/specs/fixtures/basic/pages/define-i18n-route-false.vue b/specs/fixtures/basic/pages/define-i18n-route-false.vue index ef1380a9c..b6208cade 100644 --- a/specs/fixtures/basic/pages/define-i18n-route-false.vue +++ b/specs/fixtures/basic/pages/define-i18n-route-false.vue @@ -1,7 +1,12 @@ diff --git a/specs/fixtures/basic/pages/history.vue b/specs/fixtures/basic/pages/history.vue index 778a61229..10acd47a6 100644 --- a/specs/fixtures/basic/pages/history.vue +++ b/specs/fixtures/basic/pages/history.vue @@ -8,7 +8,7 @@ defineI18nRoute({ paths: { en: '/our-history', - fr: '/notre-histoire' - } + fr: '/notre-histoire', + }, }) diff --git a/specs/fixtures/basic/pages/ignore-routes/pick.vue b/specs/fixtures/basic/pages/ignore-routes/pick.vue index 4ca5d868b..ae251d39b 100644 --- a/specs/fixtures/basic/pages/ignore-routes/pick.vue +++ b/specs/fixtures/basic/pages/ignore-routes/pick.vue @@ -1,6 +1,6 @@ diff --git a/specs/fixtures/basic/pages/index.vue b/specs/fixtures/basic/pages/index.vue index c389d5962..9f12ac083 100644 --- a/specs/fixtures/basic/pages/index.vue +++ b/specs/fixtures/basic/pages/index.vue @@ -9,8 +9,8 @@ const i18nHead = useLocaleHead({ seo: { canonicalQueries: ['page'] } }) const { data, refresh } = useAsyncData(`home-${locale.value}`, () => Promise.resolve({ aboutPath: localePath('about'), - aboutTranslation: t('about') - }) + aboutTranslation: t('about'), + }), ) watchEffect(() => { @@ -21,51 +21,75 @@ useHead(() => ({ title: t('home'), htmlAttrs: { lang: i18nHead.value.htmlAttrs!.lang, - dir: i18nHead.value.htmlAttrs!.dir + dir: i18nHead.value.htmlAttrs!.dir, }, link: [...(i18nHead.value.link || [])], - meta: [...(i18nHead.value.meta || [])] + meta: [...(i18nHead.value.meta || [])], })) diff --git a/specs/fixtures/basic/pages/index/nested-root-page.vue b/specs/fixtures/basic/pages/index/nested-root-page.vue index e69ae49a9..0e211d896 100644 --- a/specs/fixtures/basic/pages/index/nested-root-page.vue +++ b/specs/fixtures/basic/pages/index/nested-root-page.vue @@ -2,8 +2,8 @@ defineI18nRoute({ paths: { en: '/my-localized-nested-root-page', - fr: '/my-localized-nested-root-page-french' - } + fr: '/my-localized-nested-root-page-french', + }, }) diff --git a/specs/fixtures/basic/pages/products/[id].vue b/specs/fixtures/basic/pages/products/[id].vue index b5a2922d5..b7e51e44c 100644 --- a/specs/fixtures/basic/pages/products/[id].vue +++ b/specs/fixtures/basic/pages/products/[id].vue @@ -8,7 +8,7 @@ defineI18nRoute({ paths: { en: '/products/[id]', - fr: '/produits/[id]' - } + fr: '/produits/[id]', + }, }) diff --git a/specs/fixtures/basic/pages/user/profile.vue b/specs/fixtures/basic/pages/user/profile.vue index 6c50b8ae3..a5247084b 100644 --- a/specs/fixtures/basic/pages/user/profile.vue +++ b/specs/fixtures/basic/pages/user/profile.vue @@ -1,3 +1,5 @@ diff --git a/specs/fixtures/basic/plugins/detect-locale.server.ts b/specs/fixtures/basic/plugins/detect-locale.server.ts index dc322e888..729b8862c 100644 --- a/specs/fixtures/basic/plugins/detect-locale.server.ts +++ b/specs/fixtures/basic/plugins/detect-locale.server.ts @@ -9,5 +9,5 @@ export default defineNuxtPlugin({ // @ts-expect-error lacking types nuxtApp.ssrContext.payload.serverDetectedLocale = toValue(nuxtApp.$i18n.locale) - } + }, }) diff --git a/specs/fixtures/basic/plugins/set-locale-plugin.ts b/specs/fixtures/basic/plugins/set-locale-plugin.ts index 530afed87..8794a5265 100644 --- a/specs/fixtures/basic/plugins/set-locale-plugin.ts +++ b/specs/fixtures/basic/plugins/set-locale-plugin.ts @@ -1,6 +1,6 @@ import { defineNuxtPlugin } from '#imports' -export default defineNuxtPlugin(async nuxtApp => { +export default defineNuxtPlugin(async (nuxtApp) => { if ('pluginSetLocale' in nuxtApp._route.query && typeof nuxtApp._route.query.pluginSetLocale === 'string') { const app = useNuxtApp() await app.$i18n.setLocale(nuxtApp._route.query.pluginSetLocale) diff --git a/specs/fixtures/basic_usage/app/app.vue b/specs/fixtures/basic_usage/app/app.vue index 166723dd4..2c17dfd82 100644 --- a/specs/fixtures/basic_usage/app/app.vue +++ b/specs/fixtures/basic_usage/app/app.vue @@ -8,13 +8,16 @@ const skipSettingLocale = useRuntimeConfig().public.i18n.skipSettingLocaleOnNavi const pageTransition = { name: 'my', mode: 'out-in', - onBeforeEnter: async () => await finalizePendingLocaleChange() + onBeforeEnter: async () => await finalizePendingLocaleChange(), } diff --git a/specs/fixtures/basic_usage/app/app/router.options.ts b/specs/fixtures/basic_usage/app/app/router.options.ts index 1d7b78a60..f63524a28 100644 --- a/specs/fixtures/basic_usage/app/app/router.options.ts +++ b/specs/fixtures/basic_usage/app/app/router.options.ts @@ -11,5 +11,5 @@ export default { } return savedPosition || { top: 0 } - } + }, } diff --git a/specs/fixtures/basic_usage/app/components/LocalScope.vue b/specs/fixtures/basic_usage/app/components/LocalScope.vue index 379c09a08..e883f894b 100644 --- a/specs/fixtures/basic_usage/app/components/LocalScope.vue +++ b/specs/fixtures/basic_usage/app/components/LocalScope.vue @@ -4,6 +4,6 @@ diff --git a/specs/fixtures/basic_usage/app/layouts/default.vue b/specs/fixtures/basic_usage/app/layouts/default.vue index b256737cb..8e81e7474 100644 --- a/specs/fixtures/basic_usage/app/layouts/default.vue +++ b/specs/fixtures/basic_usage/app/layouts/default.vue @@ -12,14 +12,32 @@ const title = computed(() => `Page - ${t(route.meta?.title ?? '')}`)