Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default createConfigForNuxt({
'.nuxt',
'dist',
'playground',
'specs',
'test',
'coverage',
'docs',
Expand All @@ -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: {
Expand Down Expand Up @@ -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
Expand Down
109 changes: 54 additions & 55 deletions specs/basic_usage.spec.ts

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions specs/browser_language_detection/no_prefix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ await setup({
cookieKey: 'my_custom_cookie_name',
redirectOn: 'root',
cookieCrossOrigin: true,
cookieSecure: true
}
}
}
cookieSecure: true,
},
},
},
})

test('detection with cookie', async () => {
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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' },
])
})

Expand All @@ -103,10 +103,10 @@ test('detection with browser', async () => {
public: {
i18n: {
detectBrowserLanguage: {
useCookie: false
}
}
}
useCookie: false,
},
},
},
})
const { page } = await renderPage('/', { locale: 'fr' })

Expand Down Expand Up @@ -139,9 +139,9 @@ test('disable', async () => {
await setServerRuntimeConfig({
public: {
i18n: {
detectBrowserLanguage: false
}
}
detectBrowserLanguage: false,
},
},
})

const { page } = await renderPage('/', { locale: 'en' })
Expand Down Expand Up @@ -173,10 +173,10 @@ test('fallback', async () => {
i18n: {
detectBrowserLanguage: {
useCookie: false,
fallbackLocale: 'fr'
}
}
}
fallbackLocale: 'fr',
},
},
},
})
const { page } = await renderPage('/', { locale: 'ja' })

Expand Down
42 changes: 21 additions & 21 deletions specs/browser_language_detection/prefix_and_default.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ await setup({
i18n: {
strategy: 'prefix_and_default',
detectBrowserLanguage: {
redirectOn: 'all'
}
}
}
redirectOn: 'all',
},
},
},
})

test('redirectOn: all', async () => {
Expand All @@ -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' })

Expand All @@ -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' })

Expand All @@ -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
Expand All @@ -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()
Expand Down
24 changes: 12 additions & 12 deletions specs/browser_language_detection/prefix_except_default.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ await setup({
detectBrowserLanguage: {
useCookie: true,
redirectOn: 'root',
alwaysRedirect: true
}
}
}
alwaysRedirect: true,
},
},
},
})

describe('`detectBrowserLanguage` using strategy `prefix_except_default`', async () => {
Expand All @@ -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()
Expand Down Expand Up @@ -61,10 +61,10 @@ describe('`detectBrowserLanguage` using strategy `prefix_except_default`', async
i18n: {
detectBrowserLanguage: {
useCookie: true,
redirectOn: 'root'
}
}
}
redirectOn: 'root',
},
},
},
})
})

Expand Down
11 changes: 6 additions & 5 deletions specs/custom_route_paths/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ await setup({
i18n: {
defaultLocale: 'en',
customRoutes: 'page',
detectBrowserLanguage: false
}
}
detectBrowserLanguage: false,
},
},
})

test('can access to custom route path', async () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
30 changes: 16 additions & 14 deletions specs/custom_route_paths/module_configration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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`
Expand Down Expand Up @@ -79,11 +79,12 @@ test('can not access to pick route path', async () => {
let res: Awaited<ReturnType<typeof page.goto>> | (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 () => {
Expand All @@ -100,11 +101,12 @@ test('can not access to disable route path', async () => {
let res: Awaited<ReturnType<typeof page.goto>> | (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 () => {
Expand Down
Loading
Loading