Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Oct 18, 2024
1 parent 791187c commit 05174fc
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function getEntry(href: Href) {
};
}

function getUrl(href: Href, locale: typeof routing.locales[number]) {
function getUrl(href: Href, locale: (typeof routing.locales)[number]) {
const pathname = getPathname({locale, href});
return `${host}/${locale}${pathname === '/' ? '' : pathname}`;
}
Expand Down
5 changes: 4 additions & 1 deletion examples/example-app-router-playground/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ const withMdx = mdxPlugin();
export default withMdx(
withNextIntl({
trailingSlash: process.env.NEXT_PUBLIC_USE_CASE === 'trailing-slash',
basePath: process.env.NEXT_PUBLIC_USE_CASE === 'base-path' ? '/base/path' : undefined,
basePath:
process.env.NEXT_PUBLIC_USE_CASE === 'base-path'
? '/base/path'
: undefined,
experimental: {
staleTimes: {
// Next.js 14.2 broke `locale-prefix-never.spec.ts`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
getTranslations
} from 'next-intl/server';
import {ReactNode} from 'react';
import Navigation from '../../components/Navigation';
import {routing} from '@/i18n/routing';
import Navigation from '../../components/Navigation';

type Props = {
children: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Image from 'next/image';
import {useFormatter, useNow, useTimeZone, useTranslations} from 'next-intl';
import DropdownMenu from '@/components/DropdownMenu';
import RichText from '@/components/RichText';
import {Link} from '@/i18n/routing';
import AsyncComponent from '../../components/AsyncComponent';
import AsyncComponentWithNamespaceAndLocale from '../../components/AsyncComponentWithNamespaceAndLocale';
Expand All @@ -12,8 +14,6 @@ import LocaleSwitcher from '../../components/LocaleSwitcher';
import PageLayout from '../../components/PageLayout';
import MessagesAsPropsCounter from '../../components/client/01-MessagesAsPropsCounter';
import MessagesOnClientCounter from '../../components/client/02-MessagesOnClientCounter';
import DropdownMenu from '@/components/DropdownMenu';
import RichText from '@/components/RichText';

type Props = {
searchParams: Record<string, string>;
Expand Down
4 changes: 1 addition & 3 deletions examples/example-react-native/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
Expand Down
28 changes: 14 additions & 14 deletions packages/next-intl/.size-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,79 @@ import type {SizeLimitConfig} from 'size-limit';

const config: SizeLimitConfig = [
{
name: 'import * from \'next-intl\' (react-client)',
name: "import * from 'next-intl' (react-client)",
path: 'dist/production/index.react-client.js',
limit: '14.095 KB'
},
{
name: 'import * from \'next-intl\' (react-server)',
name: "import * from 'next-intl' (react-server)",
path: 'dist/production/index.react-server.js',
limit: '14.735 KB'
},
{
name: 'import {createSharedPathnamesNavigation} from \'next-intl/navigation\' (react-client)',
name: "import {createSharedPathnamesNavigation} from 'next-intl/navigation' (react-client)",
path: 'dist/production/navigation.react-client.js',
import: '{createSharedPathnamesNavigation}',
limit: '4.035 KB'
},
{
name: 'import {createLocalizedPathnamesNavigation} from \'next-intl/navigation\' (react-client)',
name: "import {createLocalizedPathnamesNavigation} from 'next-intl/navigation' (react-client)",
path: 'dist/production/navigation.react-client.js',
import: '{createLocalizedPathnamesNavigation}',
limit: '4.035 KB'
},
{
name: 'import {createNavigation} from \'next-intl/navigation\' (react-client)',
name: "import {createNavigation} from 'next-intl/navigation' (react-client)",
path: 'dist/production/navigation.react-client.js',
import: '{createNavigation}',
limit: '4.045 KB'
},
{
name: 'import {createSharedPathnamesNavigation} from \'next-intl/navigation\' (react-server)',
name: "import {createSharedPathnamesNavigation} from 'next-intl/navigation' (react-server)",
path: 'dist/production/navigation.react-server.js',
import: '{createSharedPathnamesNavigation}',
limit: '16.755 KB'
},
{
name: 'import {createLocalizedPathnamesNavigation} from \'next-intl/navigation\' (react-server)',
name: "import {createLocalizedPathnamesNavigation} from 'next-intl/navigation' (react-server)",
path: 'dist/production/navigation.react-server.js',
import: '{createLocalizedPathnamesNavigation}',
limit: '16.785 KB'
},
{
name: 'import {createNavigation} from \'next-intl/navigation\' (react-server)',
name: "import {createNavigation} from 'next-intl/navigation' (react-server)",
path: 'dist/production/navigation.react-server.js',
import: '{createNavigation}',
limit: '16.765 KB'
},
{
name: 'import * from \'next-intl/server\' (react-client)',
name: "import * from 'next-intl/server' (react-client)",
path: 'dist/production/server.react-client.js',
limit: '1 KB'
},
{
name: 'import * from \'next-intl/server\' (react-server)',
name: "import * from 'next-intl/server' (react-server)",
path: 'dist/production/server.react-server.js',
limit: '14.035 KB'
},
{
name: 'import createMiddleware from \'next-intl/middleware\'',
name: "import createMiddleware from 'next-intl/middleware'",
path: 'dist/production/middleware.js',
limit: '9.675 KB'
},
{
name: 'import * from \'next-intl/routing\'',
name: "import * from 'next-intl/routing'",
path: 'dist/production/routing.js',
limit: '1 KB'
},
{
name: 'import * from \'next-intl\' (react-client, ESM)',
name: "import * from 'next-intl' (react-client, ESM)",
path: 'dist/esm/index.react-client.js',
import: '*',
limit: '14.245 kB'
},
{
name: 'import {NextIntlProvider} from \'next-intl\' (react-client, ESM)',
name: "import {NextIntlProvider} from 'next-intl' (react-client, ESM)",
path: 'dist/esm/index.react-client.js',
import: '{NextIntlClientProvider}',
limit: '1.425 kB'
Expand Down
18 changes: 9 additions & 9 deletions packages/next-intl/src/navigation/createNavigation.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {render, screen} from '@testing-library/react';
import {
RedirectType,
redirect as nextRedirect,
permanentRedirect as nextPermanentRedirect,
redirect as nextRedirect,
useParams as nextUseParams
} from 'next/navigation';
import React from 'react';
import {renderToString} from 'react-dom/server';
import {it, describe, vi, expect, beforeEach} from 'vitest';
import {defineRouting, DomainsConfig, Pathnames} from '../routing';
import {beforeEach, describe, expect, it, vi} from 'vitest';
import {DomainsConfig, Pathnames, defineRouting} from '../routing';
import {getRequestLocale} from '../server/react-server/RequestLocale';
import createNavigationClient from './react-client/createNavigation';
import createNavigationServer from './react-server/createNavigation';
Expand Down Expand Up @@ -40,7 +40,7 @@ function mockCurrentLocale(locale: string) {

function mockLocation(location: Partial<typeof window.location>) {
delete (global.window as any).location;
global.window ??= Object.create(window);
global.window = Object.create(window);
(global.window as any).location = location;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ describe.each([
});

it('does not accept `query` on the root', () => {
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
() =>
getPathname({
href: '/about',
Expand All @@ -237,7 +237,7 @@ describe.each([
});

it('does not accept `params` on href', () => {
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
() =>
getPathname({
href: {
Expand All @@ -259,7 +259,7 @@ describe.each([
// works in either environment.

// @ts-expect-error -- Missing locale
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
() => getPathname({href: '/about'});
});

Expand Down Expand Up @@ -699,7 +699,7 @@ describe.each([

it('requires a locale', () => {
// @ts-expect-error -- Missing locale
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
() => getPathname({href: '/about'});
});
});
Expand Down Expand Up @@ -1010,7 +1010,7 @@ describe.each([

it('requires a locale', () => {
// @ts-expect-error -- Missing locale
// eslint-disable-next-line no-unused-expressions
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
() => getPathname({href: '/about'});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {fireEvent, render, screen} from '@testing-library/react';
import {PrefetchKind} from 'next/dist/client/components/router-reducer/router-reducer-types';
import {
useParams,
usePathname as useNextPathname,
useRouter as useNextRouter
useRouter as useNextRouter,
useParams
} from 'next/navigation';
import React from 'react';
import {beforeEach, describe, expect, it, vi} from 'vitest';
Expand All @@ -24,7 +24,7 @@ function mockLocation(
basePath?: string
) {
delete (global.window as any).location;
global.window ??= Object.create(window);
global.window = Object.create(window);
(global.window as any).location = location;

if (location.pathname) {
Expand Down Expand Up @@ -374,6 +374,7 @@ describe("localePrefix: 'always', with `basePath`", () => {
});

describe("localePrefix: 'always', with `pathnames`", () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {usePathname, useRouter} = createNavigation({
locales,
defaultLocale,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
useRouter as useNextRouter,
usePathname as useNextPathname
usePathname as useNextPathname,
useRouter as useNextRouter
} from 'next/navigation';
import {useMemo} from 'react';
import useLocale from '../../react-client/useLocale';
Expand Down
2 changes: 1 addition & 1 deletion packages/next-intl/src/navigation/shared/BaseLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import NextLink from 'next/link';
import {usePathname} from 'next/navigation';
import React, {
ComponentProps,
forwardRef,
MouseEvent,
forwardRef,
useEffect,
useState
} from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
} from 'next/navigation';
import React, {ComponentProps, forwardRef, use} from 'react';
import {
receiveRoutingConfig,
RoutingConfigLocalizedNavigation,
RoutingConfigSharedNavigation
RoutingConfigSharedNavigation,
receiveRoutingConfig
} from '../../routing/config';
import {
DomainConfig,
Expand Down
6 changes: 3 additions & 3 deletions packages/use-intl/.size-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import type {SizeLimitConfig} from 'size-limit';

const config: SizeLimitConfig = [
{
name: 'import * from \'use-intl\' (ESM)',
name: "import * from 'use-intl' (ESM)",
import: '*',
path: 'dist/esm/index.js',
limit: '14.125 kB'
},
{
name: 'import {IntlProvider, useLocale, useNow, useTimeZone, useMessages, useFormatter} from \'use-intl\' (ESM)',
name: "import {IntlProvider, useLocale, useNow, useTimeZone, useMessages, useFormatter} from 'use-intl' (ESM)",
path: 'dist/esm/index.js',
import:
'{IntlProvider, useLocale, useNow, useTimeZone, useMessages, useFormatter}',
limit: '2.865 kB'
},
{
name: 'import * from \'use-intl\' (CJS)',
name: "import * from 'use-intl' (CJS)",
path: 'dist/production/index.js',
limit: '15.65 kB'
}
Expand Down

0 comments on commit 05174fc

Please sign in to comment.